Attributes Management
This section explains how to define, check, and remove attributes in RXMeshStatic
. Attributes in RXMesh are strongly typed and always associated with a specific mesh element (vertex, edge, or face). You can create attributes from scratch, load them from data in memory, or copy the shape and layout from an existing attribute.
For manipulating attribute values—access, memory movement, or math—see the Attributes section.
Adding Attributes
From Scratch
Used when you want to allocate a new attribute with no initial values. You specify the number of values per element, where they should be allocated (host/device), and the layout (SoA or AoS).
rx.add_vertex_attribute<float>("vColor", 3); // RGB color
rx.add_edge_attribute<int>("eFlags", 1); // One integer flag per edge
rx.add_face_attribute<double>("area", 1); // Scalar per face
Relevant functions:
add_vertex_attribute<T>(name, num_attributes, location, layout)
add_edge_attribute<T>(...)
add_face_attribute<T>(...)
add_attribute<T, HandleT>(...)
— generic version that uses the handle type.
From Existing Data
Used when you already have attribute values stored in memory (e.g., parsed from a file or generated by preprocessing).
// Per-vertex 3D coordinates
std::vector<std::vector<float>> coords = ...;
rx.add_vertex_attribute(coords, "vertex_positions");
// Per-face scalar value
std::vector<int> face_labels = ...;
rx.add_face_attribute(face_labels, "fLabels");
Functions:
add_vertex_attribute<T>(std::vector<std::vector<T>>, name, layout)
add_face_attribute<T>(std::vector<std::vector<T>>, name, layout)
add_vertex_attribute<T>(std::vector<T>, name, layout)
add_face_attribute<T>(std::vector<T>, name, layout)
These methods copy the input data to both host and device and allocate storage accordingly.
From Existing Attribute (Same Shape)
Used when you want to allocate an attribute that has the same layout, memory location, and shape as an existing one.
Functions:
add_vertex_attribute_like<T>(name, other)
add_edge_attribute_like<T>(...)
add_face_attribute_like<T>(...)
add_attribute_like<T, HandleT>(...)
— type inferred fromHandleT
Checking for Existence
To check if an attribute with a given name is already defined:
Function:
does_attribute_exist(name)
Removing Attributes
To delete an attribute from RXMesh and release its memory:
Function:
remove_attribute(name)