Lagrange
|
A general purpose polygonal mesh class. More...
#include <lagrange/SurfaceMesh.h>
Classes | |
struct | BareMeshTag |
Overload tag. More... | |
struct | ReservedAttributeIds |
Reserved attribute ids. More... | |
Public Types | |
using | Scalar = Scalar_ |
Mesh scalar type, used for vertex coordinates. | |
using | Index = Index_ |
Mesh index type, used for facet indices. | |
using | SignedIndex = std::make_signed_t< Index > |
Signed index type corresponding to the mesh index type. | |
using | SetVertexCoordinatesFunction = function_ref< void(Index v, span< Scalar > p)> |
Callback function to set vertex coordinates. More... | |
using | SetSingleFacetIndicesFunction = function_ref< void(span< Index > t)> |
Callback function to set indices of a single facet. More... | |
using | SetMultiFacetsIndicesFunction = function_ref< void(Index f, span< Index > t)> |
Callback function to set indices of a multiple facets. More... | |
using | GetFacetsSizeFunction = function_ref< Index(Index f)> |
Callback function to get a facet size (number of vertices in the facet). More... | |
using | GetEdgeVertices = function_ref< std::array< Index, 2 >(Index e)> |
Callback function to get the vertex indices of an edge endpoints in a user-provided ordering of a mesh edges. More... | |
Public Member Functions | |
template<typename SourceScalar , typename SourceIndex > | |
SurfaceMesh< TargetScalar, TargetIndex > | stripped_copy (const SurfaceMesh< SourceScalar, SourceIndex > &source_mesh) |
template<typename SourceScalar , typename SourceIndex > | |
SurfaceMesh< TargetScalar, TargetIndex > | stripped_move (SurfaceMesh< SourceScalar, SourceIndex > &&source_mesh) |
Mesh accessors | |
bool | is_triangle_mesh () const |
Whether the mesh must only contain triangular facets. More... | |
bool | is_quad_mesh () const |
Whether the mesh must only contains quadrilateral facets. More... | |
bool | is_regular () const |
Whether the mesh must only contains facets of equal sizes. More... | |
bool | is_hybrid () const |
Whether the mesh may contain facets of different sizes. More... | |
Index | get_dimension () const |
Retrieves the dimension of the mesh vertices. More... | |
Index | get_vertex_per_facet () const |
Retrieves the number of vertex per facet in a regular mesh. More... | |
Index | get_num_vertices () const |
Retrieves the number of vertices. More... | |
Index | get_num_facets () const |
Retrieves the number of facets. More... | |
Index | get_num_corners () const |
Retrieves the number of corners. More... | |
Index | get_num_edges () const |
Retrieves the number of edges. More... | |
span< const Scalar > | get_position (Index v) const |
Retrieves a read-only pointer to a vertex coordinates. More... | |
span< Scalar > | ref_position (Index v) |
Retrieves a writeable pointer to a vertex coordinates. More... | |
Index | get_facet_size (Index f) const |
Number of vertices in the facet. More... | |
Index | get_facet_vertex (Index f, Index lv) const |
Index of a vertex given from a facet + local index. More... | |
Index | get_facet_corner_begin (Index f) const |
First corner around the facet. More... | |
Index | get_facet_corner_end (Index f) const |
Index past the last corner around the facet. More... | |
Index | get_corner_vertex (Index c) const |
Retrieves the index of a vertex given its corner index. More... | |
Index | get_corner_facet (Index c) const |
Retrieves the index of a facet given its corner index. More... | |
span< const Index > | get_facet_vertices (Index f) const |
Retrieves a read-only pointer to a facet indices. More... | |
span< Index > | ref_facet_vertices (Index f) |
Retrieves a writable pointer to a facet indices. More... | |
Attribute construction | |
AttributeId | get_attribute_id (std::string_view name) const |
Retrieve an attribute id given its name. More... | |
std::string_view | get_attribute_name (AttributeId id) const |
Retrieve attribute name from its id. More... | |
template<typename ValueType > | |
AttributeId | create_attribute (std::string_view name, AttributeElement element, size_t num_channels=1, AttributeUsage usage=AttributeUsage::Vector, span< const ValueType > initial_values={}, span< const Index > initial_indices={}, AttributeCreatePolicy policy=AttributeCreatePolicy::ErrorIfReserved) |
Create a new attribute and return the newly created attribute id. More... | |
template<typename ValueType > | |
AttributeId | create_attribute (std::string_view name, AttributeElement element, AttributeUsage usage, size_t num_channels=1, span< const ValueType > initial_values={}, span< const Index > initial_indices={}, AttributeCreatePolicy policy=AttributeCreatePolicy::ErrorIfReserved) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Create a new attribute and return the newly created attribute id. More... | |
template<typename OtherScalar , typename OtherIndex > | |
AttributeId | create_attribute_from (std::string_view name, const SurfaceMesh< OtherScalar, OtherIndex > &source_mesh, std::string_view source_name={}) |
Creates an new attribute by creating a shallow copy of another mesh's attribute. More... | |
template<typename ValueType > | |
AttributeId | wrap_as_attribute (std::string_view name, AttributeElement element, AttributeUsage usage, size_t num_channels, span< ValueType > values_view) |
Wraps a writable external buffer as a mesh attribute. More... | |
template<typename ValueType > | |
AttributeId | wrap_as_attribute (std::string_view name, AttributeElement element, AttributeUsage usage, size_t num_channels, SharedSpan< ValueType > shared_values) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
template<typename ValueType > | |
AttributeId | wrap_as_const_attribute (std::string_view name, AttributeElement element, AttributeUsage usage, size_t num_channels, span< const ValueType > values_view) |
Wraps a read-only external buffer as a mesh attribute. More... | |
template<typename ValueType > | |
AttributeId | wrap_as_const_attribute (std::string_view name, AttributeElement element, AttributeUsage usage, size_t num_channels, SharedSpan< const ValueType > shared_values) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
template<typename ValueType > | |
AttributeId | wrap_as_indexed_attribute (std::string_view name, AttributeUsage usage, size_t num_values, size_t num_channels, span< ValueType > values_view, span< Index > indices_view) |
Wraps a writable external buffer as a mesh attribute. More... | |
template<typename ValueType > | |
AttributeId | wrap_as_indexed_attribute (std::string_view name, AttributeUsage usage, size_t num_values, size_t num_channels, SharedSpan< ValueType > shared_values, SharedSpan< Index > shared_indices) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
template<typename ValueType > | |
AttributeId | wrap_as_indexed_attribute (std::string_view name, AttributeUsage usage, size_t num_values, size_t num_channels, span< ValueType > values_view, SharedSpan< Index > shared_indices) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
template<typename ValueType > | |
AttributeId | wrap_as_indexed_attribute (std::string_view name, AttributeUsage usage, size_t num_values, size_t num_channels, SharedSpan< ValueType > shared_values, span< Index > indices_view) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
template<typename ValueType > | |
AttributeId | wrap_as_const_indexed_attribute (std::string_view name, AttributeUsage usage, size_t num_values, size_t num_channels, span< const ValueType > values_view, span< const Index > indices_view) |
Wraps a read-only external buffer as a mesh attribute. More... | |
template<typename ValueType > | |
AttributeId | wrap_as_const_indexed_attribute (std::string_view name, AttributeUsage usage, size_t num_values, size_t num_channels, SharedSpan< const ValueType > shared_values, SharedSpan< const Index > shared_indices) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
template<typename ValueType > | |
AttributeId | wrap_as_const_indexed_attribute (std::string_view name, AttributeUsage usage, size_t num_values, size_t num_channels, span< const ValueType > values_view, SharedSpan< const Index > shared_indices) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
template<typename ValueType > | |
AttributeId | wrap_as_const_indexed_attribute (std::string_view name, AttributeUsage usage, size_t num_values, size_t num_channels, SharedSpan< const ValueType > shared_values, span< const Index > indices_view) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
AttributeId | wrap_as_vertices (span< Scalar > vertices_view, Index num_vertices) |
Wraps a writable external buffer as mesh vertices coordinates. More... | |
AttributeId | wrap_as_vertices (SharedSpan< Scalar > shared_vertices, Index num_vertices) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
AttributeId | wrap_as_const_vertices (span< const Scalar > vertices_view, Index num_vertices) |
Wraps a read-only external buffer as mesh vertices coordinates. More... | |
AttributeId | wrap_as_const_vertices (SharedSpan< const Scalar > shared_vertices, Index num_vertices) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
AttributeId | wrap_as_facets (span< Index > facets_view, Index num_facets, Index vertex_per_facet) |
Wraps a writable external buffer as mesh facets for a regular mesh. More... | |
AttributeId | wrap_as_facets (SharedSpan< Index > shared_facets, Index num_facets, Index vertex_per_facet) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
AttributeId | wrap_as_const_facets (span< const Index > facets_view, Index num_facets, Index vertex_per_facet) |
Wraps a read-only external buffer as mesh facets for a regular mesh. More... | |
AttributeId | wrap_as_const_facets (SharedSpan< const Index > shared_facets, Index num_facets, Index vertex_per_facet) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
AttributeId | wrap_as_facets (span< Index > offsets_view, Index num_facets, span< Index > facets_view, Index num_corners) |
Wraps writable external buffers as mesh facets for a hybrid mesh. More... | |
AttributeId | wrap_as_facets (SharedSpan< Index > shared_offsets, Index num_facets, SharedSpan< Index > shared_facets, Index num_corners) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
AttributeId | wrap_as_facets (span< Index > offsets_view, Index num_facets, SharedSpan< Index > shared_facets, Index num_corners) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
AttributeId | wrap_as_facets (SharedSpan< Index > shared_offsets, Index num_facets, span< Index > facets_view, Index num_corners) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
AttributeId | wrap_as_const_facets (span< const Index > offsets_view, Index num_facets, span< const Index > facets_view, Index num_corners) |
Wraps read-only external buffers as mesh facets for a hybrid mesh. More... | |
AttributeId | wrap_as_const_facets (SharedSpan< const Index > shared_offsets, Index num_facets, SharedSpan< const Index > shared_facets, Index num_corners) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
AttributeId | wrap_as_const_facets (span< const Index > offsets_view, Index num_facets, SharedSpan< const Index > shared_facets, Index num_corners) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
AttributeId | wrap_as_const_facets (SharedSpan< const Index > shared_offsets, Index num_facets, span< const Index > facets_view, Index num_corners) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
AttributeId | duplicate_attribute (std::string_view old_name, std::string_view new_name) |
Duplicates an attribute. More... | |
void | rename_attribute (std::string_view old_name, std::string_view new_name) |
Rename an existing attribute. More... | |
void | delete_attribute (std::string_view name, AttributeDeletePolicy policy=AttributeDeletePolicy::ErrorIfReserved) |
Delete an attribute given by name. More... | |
template<typename ValueType > | |
std::shared_ptr< Attribute< ValueType > > | delete_and_export_attribute (std::string_view name, AttributeDeletePolicy delete_policy=AttributeDeletePolicy::ErrorIfReserved, AttributeExportPolicy export_policy=AttributeExportPolicy::CopyIfExternal) |
Delete an attribute and export its content in a writable shared_ptr. More... | |
template<typename ValueType > | |
std::shared_ptr< const Attribute< ValueType > > | delete_and_export_const_attribute (std::string_view name, AttributeDeletePolicy delete_policy=AttributeDeletePolicy::ErrorIfReserved, AttributeExportPolicy export_policy=AttributeExportPolicy::CopyIfExternal) |
Delete an attribute and export its content in a read-only shared_ptr. More... | |
template<typename ValueType > | |
auto | delete_and_export_indexed_attribute (std::string_view name, AttributeExportPolicy policy=AttributeExportPolicy::CopyIfExternal) -> std::shared_ptr< IndexedAttribute< ValueType, Index > > |
Delete an indexed attribute and export its content in a writable shared_ptr. More... | |
template<typename ValueType > | |
auto | delete_and_export_const_indexed_attribute (std::string_view name, AttributeExportPolicy policy=AttributeExportPolicy::CopyIfExternal) -> std::shared_ptr< const IndexedAttribute< ValueType, Index > > |
Delete an indexed attribute and export its content in a read-only shared_ptr. More... | |
Metadata attributes | |
AttributeId | create_metadata (std::string_view name, std::string_view value) |
Create a metadata attribute. More... | |
void | set_metadata (AttributeId id, std::string_view value) |
Write metadata attribute value. More... | |
void | set_metadata (std::string_view name, std::string_view value) |
Write metadata attribute value. More... | |
std::string_view | get_metadata (AttributeId id) const |
Read metadata attribute value. More... | |
std::string_view | get_metadata (std::string_view name) const |
Read metadata attribute value. More... | |
Attribute accessors | |
bool | has_attribute (std::string_view name) const |
Checks if an attribute of a given name is attached to the mesh. More... | |
template<typename ValueType > | |
bool | is_attribute_type (std::string_view name) const |
Checks whether the specified attribute is of a given type. More... | |
template<typename ValueType > | |
bool | is_attribute_type (AttributeId id) const |
Checks whether the specified attribute is of a given type. More... | |
bool | is_attribute_indexed (std::string_view name) const |
Determines whether the specified attribute is indexed. More... | |
bool | is_attribute_indexed (AttributeId id) const |
Determines whether the specified attribute is indexed. More... | |
void | seq_foreach_attribute_id (function_ref< void(AttributeId)> func) const |
Iterates over all attribute ids sequentially. More... | |
void | seq_foreach_attribute_id (function_ref< void(std::string_view, AttributeId)> func) const |
Iterates over all pairs of attribute names x ids sequentially. More... | |
void | par_foreach_attribute_id (function_ref< void(AttributeId)> func) const |
Iterates over all attribute ids in parallel. More... | |
void | par_foreach_attribute_id (function_ref< void(std::string_view, AttributeId)> func) const |
Iterates over all pairs of attribute names x ids in parallel. More... | |
const AttributeBase & | get_attribute_base (std::string_view name) const |
Gets a read-only reference to the base class of attribute given its name. More... | |
const AttributeBase & | get_attribute_base (AttributeId id) const |
Gets a read-only reference to an attribute given its id. More... | |
template<typename ValueType > | |
const Attribute< ValueType > & | get_attribute (std::string_view name) const |
Gets a read-only reference to an attribute given its name. More... | |
template<typename ValueType > | |
const Attribute< ValueType > & | get_attribute (AttributeId id) const |
Gets a read-only reference to an attribute given its id. More... | |
::lagrange::internal::weak_ptr< const AttributeBase > | _get_attribute_ptr (std::string_view name) const |
Gets a read-only weak pointer to the base attribute object. More... | |
::lagrange::internal::weak_ptr< const AttributeBase > | _get_attribute_ptr (AttributeId id) const |
Gets a read-only weak pointer to the base attribute object. More... | |
template<typename ValueType > | |
auto | get_indexed_attribute (std::string_view name) const -> const IndexedAttribute< ValueType, Index > & |
Gets a read-only reference to an indexed attribute given its name. More... | |
template<typename ValueType > | |
auto | get_indexed_attribute (AttributeId id) const -> const IndexedAttribute< ValueType, Index > & |
Gets a read-only reference to an indexed attribute given its id. More... | |
template<typename ValueType > | |
Attribute< ValueType > & | ref_attribute (std::string_view name) |
Gets a writable reference to an attribute given its name. More... | |
template<typename ValueType > | |
Attribute< ValueType > & | ref_attribute (AttributeId id) |
Gets a writable reference to an attribute given its id. More... | |
::lagrange::internal::weak_ptr< AttributeBase > | _ref_attribute_ptr (std::string_view name) |
Gets a weak pointer to the base attribute object. More... | |
::lagrange::internal::weak_ptr< AttributeBase > | _ref_attribute_ptr (AttributeId id) |
Gets a weak pointer to the base attribute object. More... | |
template<typename ValueType > | |
auto | ref_indexed_attribute (std::string_view name) -> IndexedAttribute< ValueType, Index > & |
Gets a writable reference to an indexed attribute given its name. More... | |
template<typename ValueType > | |
auto | ref_indexed_attribute (AttributeId id) -> IndexedAttribute< ValueType, Index > & |
Gets a writable reference to an indexed attribute given its id. More... | |
const Attribute< Scalar > & | get_vertex_to_position () const |
Gets a read-only reference to the vertex -> positions attribute. More... | |
Attribute< Scalar > & | ref_vertex_to_position () |
Gets a writable reference to the vertex -> positions attribute. More... | |
const Attribute< Index > & | get_corner_to_vertex () const |
Gets a read-only reference to the corner -> vertex id attribute. More... | |
Attribute< Index > & | ref_corner_to_vertex () |
Gets a writable reference to the corner -> vertex id attribute. More... | |
Mesh edges and connectivity | |
void | initialize_edges (span< const Index > edges={}) |
Initializes attributes associated to mesh edges and connectivity. More... | |
void | initialize_edges (Index num_user_edges, GetEdgeVertices get_user_edge) |
Initializes attributes associated to mesh edges and connectivity. More... | |
void | clear_edges () |
Clears attributes related to mesh edges and connectivity: More... | |
bool | has_edges () const |
Determines if the attributes associated to mesh edges and connectivity have been initialized. More... | |
Index | get_edge (Index f, Index lv) const |
Gets the edge index corresponding to (f, lv) – (f, lv+1). More... | |
Index | get_corner_edge (Index c) const |
Gets the edge index corresponding to a corner index. More... | |
Index | get_edge_from_corner (Index c) const |
Gets the edge index corresponding to a corner index. More... | |
std::array< Index, 2 > | get_edge_vertices (Index e) const |
Retrieve edge endpoints. More... | |
Index | find_edge_from_vertices (Index v0, Index v1) const |
Retrieve the edge index corresponding to (v0, v1). More... | |
Index | get_next_corner_around_facet (Index c) const |
Gets the next corner around the facet associated to a corner. More... | |
Index | get_first_corner_around_edge (Index e) const |
Get the index of the first corner around a given edge. More... | |
Index | get_next_corner_around_edge (Index c) const |
Gets the next corner around the edge associated to a corner. More... | |
Index | get_first_corner_around_vertex (Index v) const |
Get the index of the first corner around a given vertex. More... | |
Index | get_next_corner_around_vertex (Index c) const |
Gets the next corner around the vertex associated to a corner. More... | |
Index | count_num_corners_around_edge (Index e) const |
Count the number of corners incident to a given edge. More... | |
Index | count_num_corners_around_vertex (Index v) const |
Count the number of corners incident to a given vertex. More... | |
Index | get_one_facet_around_edge (Index e) const |
Get the index of one facet around a given edge. More... | |
Index | get_one_corner_around_edge (Index e) const |
Get the index of one corner around a given edge. More... | |
Index | get_one_corner_around_vertex (Index v) const |
Get the index of one corner around a given vertex. More... | |
bool | is_boundary_edge (Index e) const |
Determines whether the specified edge e is a boundary edge. More... | |
void | foreach_facet_around_edge (Index e, function_ref< void(Index)> func) const |
Applies a function to each facet around a prescribed edge. More... | |
void | foreach_facet_around_vertex (Index v, function_ref< void(Index)> func) const |
Applies a function to each facet around a prescribed vertex. More... | |
void | foreach_corner_around_edge (Index e, function_ref< void(Index)> func) const |
Applies a function to each corner around a prescribed edge. More... | |
void | foreach_corner_around_vertex (Index v, function_ref< void(Index)> func) const |
Applies a function to each corner around a prescribed vertex. More... | |
void | foreach_edge_around_vertex_with_duplicates (Index v, function_ref< void(Index)> func) const |
Applies a function to each edge around a prescribed vertex. More... | |
Protected Member Functions | |
SurfaceMesh (BareMeshTag tag) | |
Internal constructor. More... | |
template<typename ValueType > | |
AttributeId | create_attribute_internal (std::string_view name, AttributeElement element, AttributeUsage usage=AttributeUsage::Vector, size_t num_channels=1, span< const ValueType > initial_values={}, span< const Index > initial_indices={}) |
Same as create_attribute, but allows creation of reserved attributes. More... | |
template<typename ValueType > | |
void | set_attribute_default_internal (std::string_view name) |
Set attribute default value for known internal attributes. More... | |
void | reindex_vertices_internal (span< const Index > old_to_new) |
Reindex mesh vertices according to the given mapping. More... | |
std::pair< Index, Index > | reindex_facets_internal (span< const Index > old_to_new) |
Reindex mesh facets according to the given mapping. More... | |
template<AttributeElement element> | |
void | resize_elements_internal (Index num_elements) |
Resize the buffers associated to a specific element type in the mesh. More... | |
void | resize_vertices_internal (Index num_vertices) |
Resize the buffers associated to mesh vertices and their attributes. More... | |
void | resize_facets_internal (Index num_facets) |
Resize the buffers associated to mesh facets and their attributes. More... | |
void | resize_corners_internal (Index num_corners) |
Resize the buffers associated to mesh corners and their attributes. More... | |
void | resize_edges_internal (Index num_edges) |
Resize the buffers associated to mesh edges and their attributes. More... | |
span< Index > | reserve_indices_internal (Index num_facets, Index facet_size) |
Reserve index buffer for multiple facets of a given size. More... | |
span< Index > | reserve_indices_internal (span< const Index > facet_sizes) |
Reserve index buffer for multiple facets of a given size. More... | |
span< Index > | reserve_indices_internal (Index num_facets, GetFacetsSizeFunction get_facets_size) |
Reserve index buffer for multiple facets of a given size. More... | |
void | compute_corner_to_facet_internal (Index facet_begin, Index facet_end) |
Compute inverse mapping corner -> facet index for a specific range of facets. More... | |
void | initialize_edges_internal (Index num_user_edges=0, GetEdgeVertices *get_user_edge_ptr=nullptr) |
Initializes attributes associated to mesh edges and connectivity. More... | |
void | update_edges_range_internal (Index facet_begin, Index facet_end, Index num_user_edges=0, GetEdgeVertices *get_user_edge_ptr=nullptr) |
Update attributes associated to mesh edges and connectivity for a specific range of facets. More... | |
void | update_edges_last_internal (Index count, Index num_user_edges=0, GetEdgeVertices *get_user_edge_ptr=nullptr) |
Same as update_edges_range_internal, but operate on the last count facets in the mesh instead. More... | |
size_t | get_num_elements_internal (AttributeElement element) const |
Gets the number of mesh elements, based on an element type. More... | |
template<typename ValueType > | |
void | wrap_as_attribute_internal (Attribute< std::decay_t< ValueType > > &attr, size_t num_values, span< ValueType > values_view) |
Wrap a span in an attribute. More... | |
template<typename ValueType > | |
void | wrap_as_attribute_internal (Attribute< std::decay_t< ValueType > > &attr, size_t num_values, SharedSpan< ValueType > shared_values) |
Wrap a shared span in an attribute. More... | |
template<typename OffsetSpan , typename FacetSpan > | |
AttributeId | wrap_as_facets_internal (OffsetSpan offsets, Index num_facets, FacetSpan facets, Index num_corners) |
Wrap shared spans as offsets and facets. More... | |
template<typename ValueSpan , typename IndexSpan = span<Index>> | |
AttributeId | wrap_as_attribute_internal (std::string_view name, AttributeElement element, AttributeUsage usage, size_t num_values, size_t num_channels, ValueSpan values, IndexSpan indices={}) |
The most generic way of creating an attribute wrapped around external buffers. More... | |
Protected Attributes | |
Index | m_num_vertices = Index(0) |
Number of vertices. | |
Index | m_num_facets = Index(0) |
Number of facets. | |
Index | m_num_corners = Index(0) |
Number of corners. | |
Index | m_num_edges = Index(0) |
Number of edges. | |
Index | m_dimension = Index(3) |
Vertex dimension. | |
Index | m_vertex_per_facet = Index(0) |
Number of vertices per facet. Either constant (> 0) or variable (= 0). | |
value_ptr< AttributeManager > | m_attributes |
Attribute manager. Hidden implementation. | |
struct lagrange::SurfaceMesh::ReservedAttributeIds | m_reserved_ids |
Static Protected Attributes | |
struct { | |
std::string_view items [9] | |
} | s_reserved_names = {} |
Reserved attribute names. | |
Mesh construction | |
SurfaceMesh (Index dimension=3) | |
Default constructor. More... | |
~SurfaceMesh () | |
Default destructor. | |
SurfaceMesh (SurfaceMesh &&other) noexcept | |
Move constructor. More... | |
SurfaceMesh & | operator= (SurfaceMesh &&other) noexcept |
Assignment move operator. More... | |
SurfaceMesh (const SurfaceMesh &other) | |
Copy constructor. More... | |
SurfaceMesh & | operator= (const SurfaceMesh &other) |
Assignment copy operator. More... | |
void | add_vertex (span< const Scalar > p) |
Adds a vertex to the mesh. More... | |
void | add_vertex (std::initializer_list< const Scalar > p) |
Adds a vertex to the mesh. More... | |
void | add_vertices (Index num_vertices, span< const Scalar > coordinates={}) |
Adds multiple vertices to the mesh. More... | |
void | add_vertices (Index num_vertices, std::initializer_list< const Scalar > coordinates) |
Adds multiple vertices to the mesh. More... | |
void | add_vertices (Index num_vertices, SetVertexCoordinatesFunction set_vertex_coordinates) |
Adds multiple vertices to the mesh. More... | |
void | add_triangle (Index v0, Index v1, Index v2) |
Adds a triangular facet to the mesh. More... | |
void | add_triangles (Index num_facets, span< const Index > facet_indices={}) |
Adds multiple triangular facets to the mesh. More... | |
void | add_triangles (Index num_facets, std::initializer_list< const Index > facet_indices) |
Adds multiple triangular facets to the mesh. More... | |
void | add_triangles (Index num_facets, SetMultiFacetsIndicesFunction set_facets_indices) |
Adds multiple triangular facets to the mesh. More... | |
void | add_quad (Index v0, Index v1, Index v2, Index v3) |
Adds a quadrilateral facet to the mesh. More... | |
void | add_quads (Index num_facets, span< const Index > facet_indices={}) |
Adds multiple quadrilateral facets to the mesh. More... | |
void | add_quads (Index num_facets, std::initializer_list< const Index > facet_indices) |
Adds multiple quadrilateral facets to the mesh. More... | |
void | add_quads (Index num_facets, SetMultiFacetsIndicesFunction set_facets_indices) |
Adds multiple quadrilateral facets to the mesh. More... | |
void | add_polygon (Index facet_size) |
Adds a single (uninitialized) polygonal facet to the mesh. More... | |
void | add_polygon (span< const Index > facet_indices) |
Adds a single polygonal facet to the mesh. More... | |
void | add_polygon (std::initializer_list< const Index > facet_indices) |
Adds a single polygonal facet to the mesh. More... | |
void | add_polygon (Index facet_size, SetSingleFacetIndicesFunction set_facet_indices) |
Adds a single polygonal facet to the mesh. More... | |
void | add_polygons (Index num_facets, Index facet_size, span< const Index > facet_indices={}) |
Adds multiple polygonal facets of the same size to the mesh. More... | |
void | add_polygons (Index num_facets, Index facet_size, std::initializer_list< const Index > facet_indices) |
Adds multiple polygonal facets of the same size to the mesh. More... | |
void | add_polygons (Index num_facets, Index facet_size, SetMultiFacetsIndicesFunction set_facets_indices) |
Adds multiple polygonal facets of the same size to the mesh. More... | |
void | add_hybrid (span< const Index > facet_sizes, span< const Index > facet_indices={}) |
Adds multiple polygonal facets of different sizes to the mesh. More... | |
void | add_hybrid (std::initializer_list< const Index > facet_sizes, std::initializer_list< const Index > facet_indices) |
Adds multiple polygonal facets of different sizes to the mesh. More... | |
void | add_hybrid (Index num_facets, GetFacetsSizeFunction facet_sizes, SetMultiFacetsIndicesFunction set_facets_indices) |
Adds multiple polygonal facets of different sizes to the mesh. More... | |
void | remove_vertices (span< const Index > vertices_to_remove) |
Removes a list of vertices. More... | |
void | remove_vertices (std::initializer_list< const Index > vertices_to_remove) |
Removes a list of vertices. More... | |
void | remove_vertices (function_ref< bool(Index)> should_remove_func) |
Removes a list of vertices, defined by a predicate function. More... | |
void | remove_facets (span< const Index > facets_to_remove) |
Removes a list of facets. More... | |
void | remove_facets (std::initializer_list< const Index > facets_to_remove) |
Removes a list of facets. More... | |
void | remove_facets (function_ref< bool(Index)> should_remove_func) |
Removes a list of facets, defined by a predicate function. More... | |
void | clear_vertices () |
Clear buffer for mesh vertices and other vertex attributes. More... | |
void | clear_facets () |
Clear buffer for mesh facets and other facet/corner attributes. More... | |
void | shrink_to_fit () |
Shrink buffer capacities to fit current mesh attributes, deallocating any extra capacity. | |
void | compress_if_regular () |
Compress mesh storage if the mesh is regular. More... | |
template<typename OtherScalar , typename OtherIndex > | |
static SurfaceMesh | stripped_copy (const SurfaceMesh< OtherScalar, OtherIndex > &other) |
Copy constructor stripping away non-reserved attributes. More... | |
template<typename OtherScalar , typename OtherIndex > | |
static SurfaceMesh | stripped_move (SurfaceMesh< OtherScalar, OtherIndex > &&other) |
Move constructor stripping away non-reserved attributes. More... | |
Reserved attribute names and ids | |
AttributeId | attr_id_vertex_to_position () const |
Attribute id for vertex -> positions. More... | |
AttributeId | attr_id_vertex_to_positions () const |
Attribute id for vertex -> positions. More... | |
AttributeId | attr_id_corner_to_vertex () const |
Attribute id for corner -> vertex indices. More... | |
AttributeId | attr_id_facet_to_first_corner () const |
Attribute id for facet -> first corner index. More... | |
AttributeId | attr_id_corner_to_facet () const |
Attribute id for corner -> facet index. More... | |
AttributeId | attr_id_corner_to_edge () const |
Attribute id for corner -> edge indices. More... | |
AttributeId | attr_id_edge_to_first_corner () const |
Attribute id for edge -> first corner index. More... | |
AttributeId | attr_id_next_corner_around_edge () const |
Attribute id for corner -> next corner around edge. More... | |
AttributeId | attr_id_vertex_to_first_corner () const |
Attribute id for vertex -> first corner index. More... | |
AttributeId | attr_id_next_corner_around_vertex () const |
Attribute id for corner -> next corner around vertex. More... | |
static bool | attr_name_is_reserved (std::string_view name) |
Check whether the given name corresponds to a reserved attribute. More... | |
static constexpr std::string_view | attr_name_vertex_to_position () |
Attribute name for vertex -> position. More... | |
static constexpr std::string_view | attr_name_corner_to_vertex () |
Attribute name for corner -> vertex indices. More... | |
static constexpr std::string_view | attr_name_facet_to_first_corner () |
Attribute name for facet -> first corner index. More... | |
static constexpr std::string_view | attr_name_corner_to_facet () |
Attribute name for corner -> facet index. More... | |
static constexpr std::string_view | attr_name_corner_to_edge () |
Attribute name for corner -> edge indices. More... | |
static constexpr std::string_view | attr_name_edge_to_first_corner () |
Attribute name for edge -> first corner index. More... | |
static constexpr std::string_view | attr_name_next_corner_around_edge () |
Attribute name for corner -> next corner around edge. More... | |
static constexpr std::string_view | attr_name_vertex_to_first_corner () |
Attribute name for vertex -> first corner index. More... | |
static constexpr std::string_view | attr_name_next_corner_around_vertex () |
Attribute name for corner -> next corner around vertex. More... | |
A general purpose polygonal mesh class.
Scalar_ | Mesh scalar type. |
Index_ | Mesh index type. |
#include <lagrange/Attribute.h>
for manipulating non-indexed mesh attributes (e.g. vertex colors or facet normals).#include <lagrange/IndexedAttribute.h>
for manipulating indexed mesh attributes (e.g. UVs).#include <lagrange/views.h>
for Eigen matrix views over mesh attributes.#include <lagrange/foreach_attribute.h>
for iterating over mesh attributes.#include <lagrange/cast.h>
for casting between Scalar/Index types.#include <lagrange/map_attribute.h>
for converting attributes between mesh element types (e.g. vertex -> facet). using SetVertexCoordinatesFunction = function_ref<void(Index v, span<Scalar> p)> |
Callback function to set vertex coordinates.
[in] | v | Index of the vertex to set coordinates for (relative to the newly inserted vertices, i.e. starts at 0). |
[out] | p | Output coordinate buffer to write to. The output array will contain K elements to write to, where K is the dimension of the mesh (3 by default). |
using SetSingleFacetIndicesFunction = function_ref<void(span<Index> t)> |
Callback function to set indices of a single facet.
The facet size is fixed and known in advance by the user.
[out] | t | Output index buffer to write to. |
using SetMultiFacetsIndicesFunction = function_ref<void(Index f, span<Index> t)> |
Callback function to set indices of a multiple facets.
[in] | f | Index of the facet whose size to compute (relative to the newly inserted facets, starting with 0). |
[out] | t | Output index buffer to write to. You can query the size of the current output facet by calling t.size(). |
using GetFacetsSizeFunction = function_ref<Index(Index f)> |
Callback function to get a facet size (number of vertices in the facet).
[in] | f | Index of the facet whose size to compute (relative to the newly inserted facets, starting with 0). |
using GetEdgeVertices = function_ref<std::array<Index, 2>(Index e)> |
Callback function to get the vertex indices of an edge endpoints in a user-provided ordering of a mesh edges.
[in] | e | Index of the edge being queried. |
|
explicit |
Default constructor.
[in] | dimension | Vertex dimension. |
|
defaultnoexcept |
Move constructor.
other | Instance to move from. |
|
default |
Copy constructor.
[in] | other | Instance to copy from. |
|
explicitprotected |
Internal constructor.
[in] | tag | Tag to distinguish from the public constructor. |
|
defaultnoexcept |
Assignment move operator.
other | Instance to move from. |
|
default |
Assignment copy operator.
[in] | other | Instance to copy from. |
|
static |
Copy constructor stripping away non-reserved attributes.
Will internally cast the scalar and index type to the desired type. This static constructor is used internally to implement the more high-level cast
and filter_attribute
function.
[in] | other | Instance to copy from. |
OtherScalar | Other mesh scalar type. |
OtherIndex | Other mesh index type. |
|
static |
Move constructor stripping away non-reserved attributes.
Will internally cast the scalar and index type to the desired type. This static constructor is used internally to implement the more high-level cast
and filter_attribute
function.
[in] | other | Instance to move from. |
OtherScalar | Other mesh scalar type. |
OtherIndex | Other mesh index type. |
Adds a vertex to the mesh.
[in] | p | Vertex coordinates with the same dimensionality as the mesh. |
void add_vertex | ( | std::initializer_list< const Scalar > | p | ) |
Adds a vertex to the mesh.
[in] | p | Vertex coordinates with the same dimensionality as the mesh. |
Adds multiple vertices to the mesh.
[in] | num_vertices | Number of vertices to add. |
[in] | coordinates | A contiguous array of point coordinates (num_vertices x dimension). |
Adds multiple vertices to the mesh.
[in] | num_vertices | Number of vertices to add. |
[in] | coordinates | A contiguous array of point coordinates (num_vertices x dimension). |
void add_vertices | ( | Index | num_vertices, |
SetVertexCoordinatesFunction | set_vertex_coordinates | ||
) |
Adds multiple vertices to the mesh.
[in] | num_vertices | Number of vertices to add. |
[in] | set_vertex_coordinates | Function to set point coordinates of a given vertex. |
Adds a triangular facet to the mesh.
[in] | v0 | Index of the first vertex. |
[in] | v1 | Index of the second vertex. |
[in] | v2 | Index of the third vertex. |
Adds multiple triangular facets to the mesh.
[in] | num_facets | Number of facets to add. |
[in] | facet_indices | A contiguous array of corner indices, where facet_indices[3*i+k] is the index of the k-th corner of the i-th facet. |
Adds multiple triangular facets to the mesh.
[in] | num_facets | Number of facets to add. |
[in] | facet_indices | A contiguous array of corner indices, where facet_indices[3*i+k] is the index of the k-th corner of the i-th facet. |
void add_triangles | ( | Index | num_facets, |
SetMultiFacetsIndicesFunction | set_facets_indices | ||
) |
Adds multiple triangular facets to the mesh.
[in] | num_facets | Number of facets to add. |
[in] | set_facets_indices | Callable function to set vertex indices of a given facet. |
Adds a quadrilateral facet to the mesh.
[in] | v0 | Index of the first vertex. |
[in] | v1 | Index of the second vertex. |
[in] | v2 | Index of the third vertex. |
[in] | v3 | Index of the fourth vertex. |
Adds multiple quadrilateral facets to the mesh.
[in] | num_facets | Number of facets to add. |
[in] | facet_indices | A contiguous array of corner indices, where facet_indices[4*i+k] is the index of the k-th corner of the i-th facet. |
Adds multiple quadrilateral facets to the mesh.
[in] | num_facets | Number of facets to add. |
[in] | facet_indices | A contiguous array of corner indices, where facet_indices[4*i+k] is the index of the k-th corner of the i-th facet. |
void add_quads | ( | Index | num_facets, |
SetMultiFacetsIndicesFunction | set_facets_indices | ||
) |
Adds multiple quadrilateral facets to the mesh.
[in] | num_facets | Number of facets to add. |
[in] | set_facets_indices | Callable function to set vertex indices of a given facet. |
void add_polygon | ( | Index | facet_size | ) |
Adds a single (uninitialized) polygonal facet to the mesh.
Facet indices are set to 0.
[in] | facet_size | Number of vertices in the facet. |
Adds a single polygonal facet to the mesh.
[in] | facet_indices | A contiguous array of vertex indices in the facet. |
void add_polygon | ( | std::initializer_list< const Index > | facet_indices | ) |
Adds a single polygonal facet to the mesh.
[in] | facet_indices | A contiguous array of vertex indices in the facet. |
void add_polygon | ( | Index | facet_size, |
SetSingleFacetIndicesFunction | set_facet_indices | ||
) |
Adds a single polygonal facet to the mesh.
[in] | facet_size | Number of vertices in the facet. |
[in] | set_facet_indices | Callable function to retrieve facet indices. |
Adds multiple polygonal facets of the same size to the mesh.
[in] | num_facets | Number of facets to add. |
[in] | facet_size | Size of each facet to be added. |
[in] | facet_indices | A contiguous array of corner indices, where facet_indices[facet_size*i+k] is the index of the k-th corner of the i-th facet. |
void add_polygons | ( | Index | num_facets, |
Index | facet_size, | ||
std::initializer_list< const Index > | facet_indices | ||
) |
Adds multiple polygonal facets of the same size to the mesh.
[in] | num_facets | Number of facets to add. |
[in] | facet_size | Size of each facet to be added. |
[in] | facet_indices | A contiguous array of corner indices, where facet_indices[facet_size*i+k] is the index of the k-th corner of the i-th facet. |
void add_polygons | ( | Index | num_facets, |
Index | facet_size, | ||
SetMultiFacetsIndicesFunction | set_facets_indices | ||
) |
Adds multiple polygonal facets of the same size to the mesh.
[in] | num_facets | Number of facets to add. |
[in] | facet_size | Size of each facet to be added. |
[in] | set_facets_indices | Callable function to set vertex indices of a given facet. |
Adds multiple polygonal facets of different sizes to the mesh.
[in] | facet_sizes | A contiguous array representing the size of each facet to add. |
[in] | facet_indices | A contiguous array of corner indices, where facet_indices[sum(facet_sizes(j), j<=i) + k] is the index of the k-th corner of the i-th facet. |
void add_hybrid | ( | std::initializer_list< const Index > | facet_sizes, |
std::initializer_list< const Index > | facet_indices | ||
) |
Adds multiple polygonal facets of different sizes to the mesh.
[in] | facet_sizes | A contiguous array representing the size of each facet to add. |
[in] | facet_indices | A contiguous array of corner indices, where facet_indices[sum(facet_sizes(j), j<=i) + k] is the index of the k-th corner of the i-th facet. |
void add_hybrid | ( | Index | num_facets, |
GetFacetsSizeFunction | facet_sizes, | ||
SetMultiFacetsIndicesFunction | set_facets_indices | ||
) |
Adds multiple polygonal facets of different sizes to the mesh.
[in] | num_facets | Number of facets to add. |
[in] | facet_sizes | Callable function to retrieve the size of each facet to be added. |
[in] | set_facets_indices | Callable function to set vertex indices of a given facet. |
Removes a list of vertices.
The set of vertices should be provided as a sorted list, otherwise an exception is raised.
[in] | vertices_to_remove | The vertices to remove. |
void remove_vertices | ( | std::initializer_list< const Index > | vertices_to_remove | ) |
Removes a list of vertices.
The set of vertices should be provided as a sorted list, otherwise an exception is raised.
[in] | vertices_to_remove | The vertices to remove. |
void remove_vertices | ( | function_ref< bool(Index)> | should_remove_func | ) |
Removes a list of vertices, defined by a predicate function.
[in] | should_remove_func | Function to determine if a vertex of a particular index should be removed. |
Removes a list of facets.
The set of facets should be provided as a sorted list, otherwise an exception is raised.
[in] | facets_to_remove | The facets to remove. |
void remove_facets | ( | std::initializer_list< const Index > | facets_to_remove | ) |
Removes a list of facets.
The set of facets should be provided as a sorted list, otherwise an exception is raised.
[in] | facets_to_remove | The facets to remove. |
void remove_facets | ( | function_ref< bool(Index)> | should_remove_func | ) |
Removes a list of facets, defined by a predicate function.
[in] | should_remove_func | Function to determine if a facet of a particular index should be removed. |
void clear_vertices |
Clear buffer for mesh vertices and other vertex attributes.
Since this function also removes any invalid facet, the entire mesh will be cleared.
void clear_facets |
Clear buffer for mesh facets and other facet/corner attributes.
The resulting mesh will be a point cloud made of isolated vertices.
void compress_if_regular |
Compress mesh storage if the mesh is regular.
This iterates over all facets to check if the mesh is regular. If so the following attributes are removed:
bool is_triangle_mesh |
Whether the mesh must only contain triangular facets.
Accessors.
A mesh with no facet is considered a triangle mesh.
bool is_quad_mesh |
Whether the mesh must only contains quadrilateral facets.
A mesh with no facet is considered a quad mesh.
bool is_regular |
Whether the mesh must only contains facets of equal sizes.
A mesh with no facet is considered regular.
|
inline |
Whether the mesh may contain facets of different sizes.
This is the opposite of is_regular (an empty mesh is not considered hybrid).
|
inline |
Retrieves the dimension of the mesh vertices.
auto get_vertex_per_facet |
Retrieves the number of vertex per facet in a regular mesh.
If the mesh is a hybrid mesh, an exception is thrown.
|
inline |
Retrieves the number of vertices.
|
inline |
Retrieves the number of facets.
|
inline |
Retrieves the number of corners.
|
inline |
Retrieves the number of edges.
auto get_position | ( | Index | v | ) | const |
Retrieves a read-only pointer to a vertex coordinates.
[in] | v | Vertex index. |
auto ref_position | ( | Index | v | ) |
Retrieves a writeable pointer to a vertex coordinates.
[in] | v | Vertex index. |
Number of vertices in the facet.
[in] | f | Facet index. |
Index of a vertex given from a facet + local index.
[in] | f | Facet index. |
[in] | lv | Local vertex index inside the facet. |
auto get_facet_corner_begin | ( | Index | f | ) | const |
First corner around the facet.
[in] | f | Facet index. |
auto get_facet_corner_end | ( | Index | f | ) | const |
Index past the last corner around the facet.
[in] | f | Facet index. |
auto get_corner_vertex | ( | Index | c | ) | const |
Retrieves the index of a vertex given its corner index.
E.g. this can be used in conjunction with get_facet_corner_begin and get_facet_corner_end to iterate over the vertices of a facet.
[in] | c | Corner index. |
auto get_corner_facet | ( | Index | c | ) | const |
Retrieves the index of a facet given its corner index.
If the mesh is regular, this is simply the corner index / num of vertex per facet. If the mesh is a hybrid polygonal mesh, this mapping is stored in a reserved attribute.s
[in] | c | Corner index. |
auto get_facet_vertices | ( | Index | f | ) | const |
Retrieves a read-only pointer to a facet indices.
[in] | f | Facet index. |
auto ref_facet_vertices | ( | Index | f | ) |
Retrieves a writable pointer to a facet indices.
[in] | f | Facet index. |
AttributeId get_attribute_id | ( | std::string_view | name | ) | const |
Retrieve an attribute id given its name.
If the attribute doesn't exist, invalid_attribute_id() is returned instead.
[in] | name | Attribute name. |
std::string_view get_attribute_name | ( | AttributeId | id | ) | const |
Retrieve attribute name from its id.
[in] | id | Attribute id. |
Exception | if id is invalid. |
AttributeId create_attribute | ( | std::string_view | name, |
AttributeElement | element, | ||
size_t | num_channels = 1 , |
||
AttributeUsage | usage = AttributeUsage::Vector , |
||
span< const ValueType > | initial_values = {} , |
||
span< const Index > | initial_indices = {} , |
||
AttributeCreatePolicy | policy = AttributeCreatePolicy::ErrorIfReserved |
||
) |
Create a new attribute and return the newly created attribute id.
A mesh attribute is stored as a row-major R x C matrix. The number of rows (R) is determined by the number of elements in the mesh that the attribute is attached to. The number of columns (C) is determined by the user when the attribute is created (num_channels), and cannot be modified afterwards. Note that the attribute tag determines how many channels are acceptable for certain types of attributes.
[in] | name | Attribute name to create. |
[in] | element | Mesh element to which the attribute is attached to (Vertex, Facet, etc.). |
[in] | num_channels | The number of channels for the attribute. Cannot be modified once the attribute has been created. |
[in] | usage | Tag to indicate how the values are modified under rigid transformation. |
[in] | initial_values | A span of initial values to populate the attribute values with. The data is copied into the attribute. If the span is provided, it must have the right dimension (number of elements x number of channels). |
[in] | initial_indices | A span of initial values to populate the attribute indices with. If the attribute element type is not Indexed, providing a non-empty value for this argument will result in a runtime error. The data is copied into the attribute. If the span is provided, it must have the right dimension (number of corners). |
[in] | policy | Attribute creation policy. By default using a reserved attribute name (starting with a "$") will throw an exception. |
ValueType | Value type for the attribute. |
AttributeId create_attribute | ( | std::string_view | name, |
AttributeElement | element, | ||
AttributeUsage | usage, | ||
size_t | num_channels = 1 , |
||
span< const ValueType > | initial_values = {} , |
||
span< const Index > | initial_indices = {} , |
||
AttributeCreatePolicy | policy = AttributeCreatePolicy::ErrorIfReserved |
||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Create a new attribute and return the newly created attribute id.
A mesh attribute is stored as a row-major R x C matrix. The number of rows (R) is determined by the number of elements in the mesh that the attribute is attached to. The number of columns (C) is determined by the user when the attribute is created (num_channels), and cannot be modified afterwards. Note that the attribute tag determines how many channels are acceptable for certain types of attributes.
[in] | name | Attribute name to create. |
[in] | element | Mesh element to which the attribute is attached to (Vertex, Facet, etc.). |
[in] | usage | Tag to indicate how the values are modified under rigid transformation. |
[in] | num_channels | The number of channels for the attribute. Cannot be modified once the attribute has been created. |
[in] | initial_values | A span of initial values to populate the attribute values with. The data is copied into the attribute. If the span is provided, it must have the right dimension (number of elements x number of channels). |
[in] | initial_indices | A span of initial values to populate the attribute indices with. If the attribute element type is not Indexed, providing a non-empty value for this argument will result in a runtime error. The data is copied into the attribute. If the span is provided, it must have the right dimension (number of corners). |
[in] | policy | Attribute creation policy. By default using a reserved attribute name (starting with a "$") will throw an exception. |
ValueType | Value type for the attribute. |
AttributeId create_attribute_from | ( | std::string_view | name, |
const SurfaceMesh< OtherScalar, OtherIndex > & | source_mesh, | ||
std::string_view | source_name = {} |
||
) |
Creates an new attribute by creating a shallow copy of another mesh's attribute.
The mesh can reference itself. This only performs a shallow copy, sharing the underlying data buffer. If either meshes performs a write operation, a deep copy will be performed (the modifications are not shared). Note that if the number of elements differs between the source and target meshes, an exception is raised.
[in] | name | Attribute name to create. |
[in] | source_mesh | Source mesh from which to copy the attribute from. The mesh can reference itself. |
[in] | source_name | Attribute name to copy from. If left empty, the target attribute name will be used. |
OtherScalar | Source mesh scalar type. |
OtherIndex | Source mesh index type. |
AttributeId wrap_as_attribute | ( | std::string_view | name, |
AttributeElement | element, | ||
AttributeUsage | usage, | ||
size_t | num_channels, | ||
span< ValueType > | values_view | ||
) |
Wraps a writable external buffer as a mesh attribute.
The buffer must remain valid during the lifetime of the mesh object (and any derived meshes that might have been copied from it).
[in] | name | Attribute name to create. |
[in] | element | Mesh element to which the attribute is attached to (Vertex, Facet, etc.). The element type must not be Indexed. Please use wrap_as_indexed_attribute for that. |
[in] | usage | Tag to indicate how the values are modified under rigid transformation. |
[in] | num_channels | The number of channels for the attribute. Cannot be modified once the attribute has been created. |
[in] | values_view | A span of the external buffer to use as storage for the attribute values. The provided span must have enough capacity to hold (number of elements x number of channels) items. It is ok to provide a span with a larger capacity than needed, which will allow for the mesh to grow. |
ValueType | Value type for the attribute. |
AttributeId wrap_as_attribute | ( | std::string_view | name, |
AttributeElement | element, | ||
AttributeUsage | usage, | ||
size_t | num_channels, | ||
SharedSpan< ValueType > | shared_values | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
shared_values
. AttributeId wrap_as_const_attribute | ( | std::string_view | name, |
AttributeElement | element, | ||
AttributeUsage | usage, | ||
size_t | num_channels, | ||
span< const ValueType > | values_view | ||
) |
Wraps a read-only external buffer as a mesh attribute.
The buffer must remain valid during the lifetime of the mesh object (and any derived meshes that might have been copied from it). Any operation that attempts to write data to the attribute will throw a runtime exception.
[in] | name | Attribute name to create. |
[in] | element | Mesh element to which the attribute is attached to (Vertex, Facet, etc.). The element type must not be Indexed. Please use wrap_as_indexed_attribute for that. |
[in] | usage | Tag to indicate how the values are modified under rigid transformation. |
[in] | num_channels | The number of channels for the attribute. Cannot be modified once the attribute has been created. |
[in] | values_view | A span of the external buffer to use as storage for the attribute values. The provided span must have a size >= (number of elements x number of channels) items. It is ok to provide a span with a larger capacity than needed. |
ValueType | Value type for the attribute. |
AttributeId wrap_as_const_attribute | ( | std::string_view | name, |
AttributeElement | element, | ||
AttributeUsage | usage, | ||
size_t | num_channels, | ||
SharedSpan< const ValueType > | shared_values | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
shared_values
. AttributeId wrap_as_indexed_attribute | ( | std::string_view | name, |
AttributeUsage | usage, | ||
size_t | num_values, | ||
size_t | num_channels, | ||
span< ValueType > | values_view, | ||
span< Index > | indices_view | ||
) |
Wraps a writable external buffer as a mesh attribute.
The buffer must remain valid during the lifetime of the mesh object (and any derived meshes that might have been copied from it).
[in] | name | Attribute name to create. |
[in] | usage | Tag to indicate how the values are modified under rigid transformation. |
[in] | num_values | Initial number of rows in the value buffer for the attribute. |
[in] | num_channels | The number of channels for the attribute. Cannot be modified once the attribute has been created. |
[in] | values_view | A span of the external buffer to use as storage for the attribute values. The provided span must have enough capacity to hold (number of values x number of channels) items. It is ok to provide a span with a larger capacity than needed, which will allow for the attribute to grow. |
[in] | indices_view | A span of the external buffer to use as storage for the attribute indices. The provided span must have enough capacity to hold (number of corners) items. It is ok to provide a span with a larger capacity than needed, which will allow for the attribute to grow. |
ValueType | Value type for the attribute. |
AttributeId wrap_as_indexed_attribute | ( | std::string_view | name, |
AttributeUsage | usage, | ||
size_t | num_values, | ||
size_t | num_channels, | ||
SharedSpan< ValueType > | shared_values, | ||
SharedSpan< Index > | shared_indices | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
shared_values
and shared_indices
. AttributeId wrap_as_indexed_attribute | ( | std::string_view | name, |
AttributeUsage | usage, | ||
size_t | num_values, | ||
size_t | num_channels, | ||
span< ValueType > | values_view, | ||
SharedSpan< Index > | shared_indices | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
shared_indices
. AttributeId wrap_as_indexed_attribute | ( | std::string_view | name, |
AttributeUsage | usage, | ||
size_t | num_values, | ||
size_t | num_channels, | ||
SharedSpan< ValueType > | shared_values, | ||
span< Index > | indices_view | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
shared_values
. AttributeId wrap_as_const_indexed_attribute | ( | std::string_view | name, |
AttributeUsage | usage, | ||
size_t | num_values, | ||
size_t | num_channels, | ||
span< const ValueType > | values_view, | ||
span< const Index > | indices_view | ||
) |
Wraps a read-only external buffer as a mesh attribute.
The buffer must remain valid during the lifetime of the mesh object (and any derived meshes that might have been copied from it). Any operation that attempts to write data to the attribute will throw a runtime exception.
[in] | name | Attribute name to create. |
[in] | usage | Tag to indicate how the values are modified under rigid transformation. |
[in] | num_values | Initial number of rows in the value buffer for the attribute. |
[in] | num_channels | The number of channels for the attribute. Cannot be modified once the attribute has been created. |
[in] | values_view | A span of the external buffer to use as storage for the attribute values. The provided span must have enough capacity to hold (number of values x number of channels) items. It is ok to provide a span with a larger capacity than needed, which will allow for the attribute to grow. |
[in] | indices_view | A span of the external buffer to use as storage for the attribute indices. The provided span must have enough capacity to hold (number of corners) items. It is ok to provide a span with a larger capacity than needed, which will allow for the attribute to grow. |
ValueType | Value type for the attribute. |
AttributeId wrap_as_const_indexed_attribute | ( | std::string_view | name, |
AttributeUsage | usage, | ||
size_t | num_values, | ||
size_t | num_channels, | ||
SharedSpan< const ValueType > | shared_values, | ||
SharedSpan< const Index > | shared_indices | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
shared_values
and shared_indices
. AttributeId wrap_as_const_indexed_attribute | ( | std::string_view | name, |
AttributeUsage | usage, | ||
size_t | num_values, | ||
size_t | num_channels, | ||
span< const ValueType > | values_view, | ||
SharedSpan< const Index > | shared_indices | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
shared_indices
. AttributeId wrap_as_const_indexed_attribute | ( | std::string_view | name, |
AttributeUsage | usage, | ||
size_t | num_values, | ||
size_t | num_channels, | ||
SharedSpan< const ValueType > | shared_values, | ||
span< const Index > | indices_view | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
shared_values
. AttributeId wrap_as_vertices | ( | span< Scalar > | vertices_view, |
Index | num_vertices | ||
) |
Wraps a writable external buffer as mesh vertices coordinates.
The buffer must remain valid during the lifetime of the mesh object (and any derived meshes that might have been copied from it). The user must provide the new number of vertices to resize the mesh with.
[in] | vertices_view | A span of the external buffer to use as storage for mesh vertices. The provided span must have a size >= (num vertices x mesh dimension). It is ok to provide a span larger than needed. |
[in] | num_vertices | Number of vertices to resize the mesh with. |
AttributeId wrap_as_vertices | ( | SharedSpan< Scalar > | shared_vertices, |
Index | num_vertices | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
shared_vertices
. AttributeId wrap_as_const_vertices | ( | span< const Scalar > | vertices_view, |
Index | num_vertices | ||
) |
Wraps a read-only external buffer as mesh vertices coordinates.
The buffer must remain valid during the lifetime of the mesh object (and any derived meshes that might have been copied from it). The user must provide the new number of vertices to resize the mesh with. Any operation that attempts to write to mesh vertices will throw a runtime exception.
[in] | vertices_view | A span of the external buffer to use as storage for mesh vertices. The provided span must have a size >= (num vertices x mesh dimension). It is ok to provide a span larger than needed. |
[in] | num_vertices | Number of vertices to resize the mesh with. |
AttributeId wrap_as_const_vertices | ( | SharedSpan< const Scalar > | shared_vertices, |
Index | num_vertices | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
shared_vertices
. AttributeId wrap_as_facets | ( | span< Index > | facets_view, |
Index | num_facets, | ||
Index | vertex_per_facet | ||
) |
Wraps a writable external buffer as mesh facets for a regular mesh.
The buffer must remain valid during the lifetime of the mesh object (and any derived meshes that might have been copied from it). The user must provide the new number of facets to resize the mesh with.
[in] | facets_view | A span of the external buffer to use as storage for mesh facet indices. The provided span must have a size >= (num_facets x vertex_per_facet). It is ok to provide a span larger than needed. |
[in] | num_facets | Number of facets to resize the mesh with. |
[in] | vertex_per_facet | Number of vertices per facet in the provided span. |
AttributeId wrap_as_facets | ( | SharedSpan< Index > | shared_facets, |
Index | num_facets, | ||
Index | vertex_per_facet | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
shared_facets
. AttributeId wrap_as_const_facets | ( | span< const Index > | facets_view, |
Index | num_facets, | ||
Index | vertex_per_facet | ||
) |
Wraps a read-only external buffer as mesh facets for a regular mesh.
The buffer must remain valid during the lifetime of the mesh object (and any derived meshes that might have been copied from it). The user must provide the new number of facets to resize the mesh with. Any operation that attempts to write to mesh facets will throw a runtime exception.
[in] | facets_view | A span of the external buffer to use as storage for mesh facet indices. The provided span must have a size >= (num_facets x vertex_per_facet). It is ok to provide a span larger than needed. |
[in] | num_facets | Number of facets to resize the mesh with. |
[in] | vertex_per_facet | Number of vertices per facet in the provided span. |
AttributeId wrap_as_const_facets | ( | SharedSpan< const Index > | shared_facets, |
Index | num_facets, | ||
Index | vertex_per_facet | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
shared_facets
. AttributeId wrap_as_facets | ( | span< Index > | offsets_view, |
Index | num_facets, | ||
span< Index > | facets_view, | ||
Index | num_corners | ||
) |
Wraps writable external buffers as mesh facets for a hybrid mesh.
The buffer must remain valid during the lifetime of the mesh object (and any derived meshes that might have been copied from it). The user must provide the new number of facets to resize the mesh with.
[in] | offsets_view | A span of the external buffer to use as storage for mesh offset indices (facet -> first corner index). The provided span must have a size >= num_facets. It is ok to provide a span larger than needed. |
[in] | num_facets | Number of facets to resize the mesh with. |
[in] | facets_view | A span of the external buffer to use as storage for mesh facet indices (corner -> vertex index). The provided span must have a size >= num_corners. It is ok to provide a span larger than needed. |
[in] | num_corners | Total number of facet corners in the resized mesh. |
AttributeId wrap_as_facets | ( | SharedSpan< Index > | shared_offsets, |
Index | num_facets, | ||
SharedSpan< Index > | shared_facets, | ||
Index | num_corners | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
shared_offsets
and shared_facets
. AttributeId wrap_as_facets | ( | span< Index > | offsets_view, |
Index | num_facets, | ||
SharedSpan< Index > | shared_facets, | ||
Index | num_corners | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
shared_facets
. AttributeId wrap_as_facets | ( | SharedSpan< Index > | shared_offsets, |
Index | num_facets, | ||
span< Index > | facets_view, | ||
Index | num_corners | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
shared_offsets
. AttributeId wrap_as_const_facets | ( | span< const Index > | offsets_view, |
Index | num_facets, | ||
span< const Index > | facets_view, | ||
Index | num_corners | ||
) |
Wraps read-only external buffers as mesh facets for a hybrid mesh.
The buffer must remain valid during the lifetime of the mesh object (and any derived meshes that might have been copied from it). The user must provide the new number of facets to resize the mesh with. Any operation that attempts to write to mesh facets will throw a runtime exception.
[in] | offsets_view | A span of the external buffer to use as storage for mesh offset indices (facet -> first corner index). The provided span must have a size >= num_facets. It is ok to provide a span larger than needed. |
[in] | num_facets | Number of facets to resize the mesh with. |
[in] | facets_view | A span of the external buffer to use as storage for mesh facet indices (corner -> vertex index). The provided span must have a size >= num_corners. It is ok to provide a span larger than needed. |
[in] | num_corners | Total number of facet corners in the resized mesh. |
AttributeId wrap_as_const_facets | ( | SharedSpan< const Index > | shared_offsets, |
Index | num_facets, | ||
SharedSpan< const Index > | shared_facets, | ||
Index | num_corners | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
shared_offsets
and shared_facets
. AttributeId wrap_as_const_facets | ( | span< const Index > | offsets_view, |
Index | num_facets, | ||
SharedSpan< const Index > | shared_facets, | ||
Index | num_corners | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
shared_facets
. AttributeId wrap_as_const_facets | ( | SharedSpan< const Index > | shared_offsets, |
Index | num_facets, | ||
span< const Index > | facets_view, | ||
Index | num_corners | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
shared_offsets
. AttributeId duplicate_attribute | ( | std::string_view | old_name, |
std::string_view | new_name | ||
) |
Duplicates an attribute.
This creates a shallow copy of the data, until a write operation occurs on either attribute. The new name must not belong to an existing attribute.
[in] | old_name | Old attribute name to duplicate. |
[in] | new_name | New attribute name to create. |
void rename_attribute | ( | std::string_view | old_name, |
std::string_view | new_name | ||
) |
Rename an existing attribute.
Attribute id remains unchanged.
[in] | old_name | Old attribute name. |
[in] | new_name | New attribute name. |
void delete_attribute | ( | std::string_view | name, |
AttributeDeletePolicy | policy = AttributeDeletePolicy::ErrorIfReserved |
||
) |
Delete an attribute given by name.
The attribute must exist. If the attribute is a reserved name (starts with a "$"), then you must specify force=true to delete the attribute.
[in] | name | Attribute name. |
[in] | policy | Delete policy for reserved attribute names. |
std::shared_ptr< Attribute< ValueType > > delete_and_export_attribute | ( | std::string_view | name, |
AttributeDeletePolicy | delete_policy = AttributeDeletePolicy::ErrorIfReserved , |
||
AttributeExportPolicy | export_policy = AttributeExportPolicy::CopyIfExternal |
||
) |
Delete an attribute and export its content in a writable shared_ptr.
The attribute must exist.
[in] | name | Attribute name |
[in] | delete_policy | Delete policy for reserved attribute names. |
[in] | export_policy | Export policy for non-owned buffers. |
ValueType | Value type for the attribute. |
std::shared_ptr< const Attribute< ValueType > > delete_and_export_const_attribute | ( | std::string_view | name, |
AttributeDeletePolicy | delete_policy = AttributeDeletePolicy::ErrorIfReserved , |
||
AttributeExportPolicy | export_policy = AttributeExportPolicy::CopyIfExternal |
||
) |
Delete an attribute and export its content in a read-only shared_ptr.
The attribute must exist.
[in] | name | Attribute name |
[in] | delete_policy | Delete policy for reserved attribute names. |
[in] | export_policy | Export policy for non-owned buffers. |
ValueType | Value type for the attribute. |
auto delete_and_export_indexed_attribute | ( | std::string_view | name, |
AttributeExportPolicy | policy = AttributeExportPolicy::CopyIfExternal |
||
) | -> std::shared_ptr<IndexedAttribute<ValueType, Index>> |
Delete an indexed attribute and export its content in a writable shared_ptr.
The attribute must exist.
[in] | name | Attribute name |
[in] | policy | Export policy for non-owned buffers. |
ValueType | Value type for the attribute. |
auto delete_and_export_const_indexed_attribute | ( | std::string_view | name, |
AttributeExportPolicy | policy = AttributeExportPolicy::CopyIfExternal |
||
) | -> std::shared_ptr<const IndexedAttribute<ValueType, Index>> |
Delete an indexed attribute and export its content in a read-only shared_ptr.
The attribute must exist.
[in] | name | Attribute name |
[in] | policy | Export policy for non-owned buffers. |
ValueType | Value type for the attribute. |
AttributeId create_metadata | ( | std::string_view | name, |
std::string_view | value | ||
) |
Create a metadata attribute.
Internally, a metadata attribute is simply a regular mesh attribute with the following properties:
AttributeElement::Value
AttributeUsage::String
uint8_t
void set_metadata | ( | AttributeId | id, |
std::string_view | value | ||
) |
void set_metadata | ( | std::string_view | name, |
std::string_view | value | ||
) |
std::string_view get_metadata | ( | AttributeId | id | ) | const |
std::string_view get_metadata | ( | std::string_view | name | ) | const |
bool has_attribute | ( | std::string_view | name | ) | const |
Checks if an attribute of a given name is attached to the mesh.
[in] | name | Attribute name. |
bool is_attribute_type | ( | std::string_view | name | ) | const |
Checks whether the specified attribute is of a given type.
[in] | name | Name of the attribute to test. |
ValueType | Attribute type to test against. |
bool is_attribute_type | ( | AttributeId | id | ) | const |
Checks whether the specified attribute is of a given type.
[in] | id | Id of the attribute to test. |
ValueType | Attribute type to test against. |
bool is_attribute_indexed | ( | std::string_view | name | ) | const |
Determines whether the specified attribute is indexed.
[in] | name | Name of the attribute to test. |
bool is_attribute_indexed | ( | AttributeId | id | ) | const |
Determines whether the specified attribute is indexed.
[in] | id | Id of the attribute to test. |
void seq_foreach_attribute_id | ( | function_ref< void(AttributeId)> | func | ) | const |
Iterates over all attribute ids sequentially.
This function is intended to be a low-level operator. For convenience functions to visit mesh attributes. See foreach_attribute.h for more information.
[in] | func | Function to iterate over attributes ids. |
void seq_foreach_attribute_id | ( | function_ref< void(std::string_view, AttributeId)> | func | ) | const |
Iterates over all pairs of attribute names x ids sequentially.
This function is intended to be a low-level operator. For convenience functions to visit mesh attributes. See foreach_attribute.h for more information.
[in] | func | Function to iterate over attributes names x ids. |
void par_foreach_attribute_id | ( | function_ref< void(AttributeId)> | func | ) | const |
Iterates over all attribute ids in parallel.
This function is intended to be a low-level operator. For convenience functions to visit mesh attributes. See foreach_attribute.h for more information.
[in] | func | Function to iterate over attributes ids. |
void par_foreach_attribute_id | ( | function_ref< void(std::string_view, AttributeId)> | func | ) | const |
Iterates over all pairs of attribute names x ids in parallel.
This function is intended to be a low-level operator. For convenience functions to visit mesh attributes. See foreach_attribute.h for more information.
[in] | func | Function to iterate over attributes names x ids. |
const AttributeBase & get_attribute_base | ( | std::string_view | name | ) | const |
Gets a read-only reference to the base class of attribute given its name.
[in] | name | Attribute name. |
const AttributeBase & get_attribute_base | ( | AttributeId | id | ) | const |
Gets a read-only reference to an attribute given its id.
[in] | id | Attribute id. |
const Attribute< ValueType > & get_attribute | ( | std::string_view | name | ) | const |
Gets a read-only reference to an attribute given its name.
[in] | name | Attribute name. |
ValueType | Scalar type stored in the attribute. |
const Attribute< ValueType > & get_attribute | ( | AttributeId | id | ) | const |
Gets a read-only reference to an attribute given its id.
[in] | id | Attribute id. |
ValueType | Scalar type stored in the attribute. |
internal::weak_ptr< const AttributeBase > _get_attribute_ptr | ( | std::string_view | name | ) | const |
Gets a read-only weak pointer to the base attribute object.
[in] | name | Attribute name. |
internal::weak_ptr< const AttributeBase > _get_attribute_ptr | ( | AttributeId | id | ) | const |
Gets a read-only weak pointer to the base attribute object.
[in] | id | Attribute id. |
auto get_indexed_attribute | ( | std::string_view | name | ) | const -> const IndexedAttribute<ValueType, Index>& |
Gets a read-only reference to an indexed attribute given its name.
[in] | name | Attribute name. |
ValueType | Scalar type stored in the attribute. |
auto get_indexed_attribute | ( | AttributeId | id | ) | const -> const IndexedAttribute<ValueType, Index>& |
Gets a read-only reference to an indexed attribute given its id.
[in] | id | Attribute id. |
ValueType | Scalar type stored in the attribute. |
Attribute< ValueType > & ref_attribute | ( | std::string_view | name | ) |
Gets a writable reference to an attribute given its name.
If the attribute is a shallow copy with shared ownership, calling this function will result in a copy of the data.
[in] | name | Attribute name. |
ValueType | Scalar type stored in the attribute. |
Attribute< ValueType > & ref_attribute | ( | AttributeId | id | ) |
Gets a writable reference to an attribute given its id.
If the attribute is a shallow copy with shared ownership, calling this function will result in a copy of the data.
[in] | id | Attribute id. |
ValueType | Scalar type stored in the attribute. |
internal::weak_ptr< AttributeBase > _ref_attribute_ptr | ( | std::string_view | name | ) |
Gets a weak pointer to the base attribute object.
[in] | name | Attribute name. |
internal::weak_ptr< AttributeBase > _ref_attribute_ptr | ( | AttributeId | id | ) |
Gets a weak pointer to the base attribute object.
[in] | id | Attribute id. |
auto ref_indexed_attribute | ( | std::string_view | name | ) | -> IndexedAttribute<ValueType, Index>& |
Gets a writable reference to an indexed attribute given its name.
If the attribute is a shallow copy with shared ownership, calling this function will result in a copy of the data.
[in] | name | Attribute name. |
ValueType | Scalar type stored in the attribute. |
auto ref_indexed_attribute | ( | AttributeId | id | ) | -> IndexedAttribute<ValueType, Index>& |
Gets a writable reference to an indexed attribute given its id.
If the attribute is a shallow copy with shared ownership, calling this function will result in a copy of the data.
[in] | id | Attribute id. |
ValueType | Scalar type stored in the attribute. |
auto get_vertex_to_position |
Gets a read-only reference to the vertex -> positions attribute.
auto ref_vertex_to_position |
Gets a writable reference to the vertex -> positions attribute.
auto get_corner_to_vertex |
Gets a read-only reference to the corner -> vertex id attribute.
auto ref_corner_to_vertex |
Gets a writable reference to the corner -> vertex id attribute.
|
static |
Check whether the given name corresponds to a reserved attribute.
Reserved attributes are attributes whose name starts with a "$".
[in] | name | Attribute name. |
|
inlinestaticconstexpr |
Attribute name for vertex -> position.
|
inlinestaticconstexpr |
Attribute name for corner -> vertex indices.
|
inlinestaticconstexpr |
Attribute name for facet -> first corner index.
|
inlinestaticconstexpr |
Attribute name for corner -> facet index.
|
inlinestaticconstexpr |
Attribute name for corner -> edge indices.
|
inlinestaticconstexpr |
Attribute name for edge -> first corner index.
|
inlinestaticconstexpr |
Attribute name for corner -> next corner around edge.
|
inlinestaticconstexpr |
Attribute name for vertex -> first corner index.
|
inlinestaticconstexpr |
Attribute name for corner -> next corner around vertex.
|
inline |
Attribute id for vertex -> positions.
|
inline |
Attribute id for vertex -> positions.
|
inline |
Attribute id for corner -> vertex indices.
|
inline |
Attribute id for facet -> first corner index.
|
inline |
Attribute id for corner -> facet index.
|
inline |
Attribute id for corner -> edge indices.
|
inline |
Attribute id for edge -> first corner index.
|
inline |
Attribute id for corner -> next corner around edge.
|
inline |
Attribute id for vertex -> first corner index.
|
inline |
Attribute id for corner -> next corner around vertex.
Initializes attributes associated to mesh edges and connectivity.
Mesh edges and connectivity.
If a user-defined ordering of the mesh edges is provided, it must be a valid indexing (all edges should appear in the provided array).
[in] | edges | M x 2 continuous array of mapping edge -> vertices, where M is the number of edges in the mesh. |
void initialize_edges | ( | Index | num_user_edges, |
GetEdgeVertices | get_user_edge | ||
) |
Initializes attributes associated to mesh edges and connectivity.
In this overload, a user-defined ordering of the mesh edges is provided via a function callback. The user-provided ordering must be a valid indexing (all edges should appear exactly once).
[in] | num_user_edges | Number of edges in the user-provided ordering. If it does not match the actual number of mesh edges after initialization, an exception is raised. |
[in] | get_user_edge | Callback function to retrieve the vertices endpoints of an edge given its user-provided index. |
void clear_edges |
Clears attributes related to mesh edges and connectivity:
This method also sets the number of mesh edges to 0, effectively resizing all user-defined edge attributes to 0.
|
inline |
Determines if the attributes associated to mesh edges and connectivity have been initialized.
Gets the edge index corresponding to (f, lv) – (f, lv+1).
[in] | f | Facet index. |
[in] | lv | Local vertex index [0, get_vertex_per_facet()[. |
auto get_corner_edge | ( | Index | c | ) | const |
Gets the edge index corresponding to a corner index.
Given a face (v0, ..., vk) with associated corners (c0, ..., ck), the edge associated to corner ci is the edge between (vi, vi+1), as determined by the corner_to_edge_mapping function.
[in] | c | Corner index. |
auto get_edge_from_corner | ( | Index | c | ) | const |
Gets the edge index corresponding to a corner index.
Given a face (v0, ..., vk) with associated corners (c0, ..., ck), the edge associated to corner ci is the edge between (vi, vi+1), as determined by the corner_to_edge_mapping function.
[in] | c | Corner index. |
auto get_edge_vertices | ( | Index | e | ) | const |
Retrieve edge endpoints.
[in] | e | Queried edge index. |
Retrieve the edge index corresponding to (v0, v1).
[in] | v0,v1 | The vertex indices for edge end points. |
invalid<Index>()
. Gets the next corner around the facet associated to a corner.
If the corner c
has local index lv
, the first corner of the facet is c0
, and the facet has nv
vertices, this function returns c0 + (lv + 1) % nv
.
[in] | c | Corner index. |
auto get_first_corner_around_edge | ( | Index | e | ) | const |
Get the index of the first corner around a given edge.
[in] | e | Queried edge index. |
auto get_next_corner_around_edge | ( | Index | c | ) | const |
Gets the next corner around the edge associated to a corner.
If the corner is the last one in the chain, this function returns INVALID<Index>.
[in] | c | Corner index. |
auto get_first_corner_around_vertex | ( | Index | v | ) | const |
Get the index of the first corner around a given vertex.
[in] | v | Queried vertex index. |
auto get_next_corner_around_vertex | ( | Index | c | ) | const |
Gets the next corner around the vertex associated to a corner.
If the corner is the last one in the chain, this function returns INVALID<Index>.
[in] | c | Corner index. |
auto count_num_corners_around_edge | ( | Index | e | ) | const |
Count the number of corners incident to a given edge.
[in] | e | Queried edge index. |
auto count_num_corners_around_vertex | ( | Index | v | ) | const |
Count the number of corners incident to a given vertex.
[in] | v | Queried vertex index. |
auto get_one_facet_around_edge | ( | Index | e | ) | const |
Get the index of one facet around a given edge.
[in] | e | Queried edge index. |
auto get_one_corner_around_edge | ( | Index | e | ) | const |
Get the index of one corner around a given edge.
[in] | e | Queried edge index. |
auto get_one_corner_around_vertex | ( | Index | v | ) | const |
Get the index of one corner around a given vertex.
[in] | v | Queried vertex index. |
bool is_boundary_edge | ( | Index | e | ) | const |
Determines whether the specified edge e is a boundary edge.
[in] | e | Queried edge index. |
void foreach_facet_around_edge | ( | Index | e, |
function_ref< void(Index)> | func | ||
) | const |
Applies a function to each facet around a prescribed edge.
[in] | e | Queried edge index. |
[in] | func | Callback to apply to each incident facet. |
void foreach_facet_around_vertex | ( | Index | v, |
function_ref< void(Index)> | func | ||
) | const |
Applies a function to each facet around a prescribed vertex.
[in] | v | Queried vertex index. |
[in] | func | Callback to apply to each incident facet. |
void foreach_corner_around_edge | ( | Index | e, |
function_ref< void(Index)> | func | ||
) | const |
Applies a function to each corner around a prescribed edge.
[in] | e | Queried edge index. |
[in] | func | Callback to apply to each incident corner. |
void foreach_corner_around_vertex | ( | Index | v, |
function_ref< void(Index)> | func | ||
) | const |
Applies a function to each corner around a prescribed vertex.
[in] | v | Queried vertex index. |
[in] | func | Callback to apply to each incident corner. |
void foreach_edge_around_vertex_with_duplicates | ( | Index | v, |
function_ref< void(Index)> | func | ||
) | const |
Applies a function to each edge around a prescribed vertex.
The function will be applied repeatedly to each incident edges (once for each facet incident to the query vertex).
[in] | v | Queried vertex index. |
[in] | func | Callback to apply to each incident edge. |
|
protected |
Same as create_attribute, but allows creation of reserved attributes.
[in] | name | Attribute name to create. |
[in] | element | Mesh element to which the attribute is attached to (Vertex, Facet, etc.). |
[in] | usage | Tag to indicate how the values are modified under rigid transformation. |
[in] | num_channels | The number of channels for the attribute. Cannot be modified once the attribute has been created. |
[in] | initial_values | A span of initial values to populate the attribute values with. The data is copied into the attribute. If the span is provided, it must have the right dimension (number of elements x number of channels). |
[in] | initial_indices | A span of initial values to populate the attribute indices with. If the attribute element type is not Indexed, providing a non-empty value for this argument will result in a runtime error. The data is copied into the attribute. If the span is provided, it must have the right dimension (number of corners). |
ValueType | Value type for the attribute. |
|
protected |
Set attribute default value for known internal attributes.
[in] | name | Name of the attribute being set. |
ValueType | Value type for the attribute. |
Reindex mesh vertices according to the given mapping.
It is ok to map several vertices to the same index. The mapping must form an increasing sequence, such that it is possible to copy values without an intermediate buffer. Elements mapped to invalid<Index>() will not be copied.
[in] | old_to_new | Mapping old vertex index -> new vertex index. |
Reindex mesh facets according to the given mapping.
Facet corners will be copied accordingly. It is ok to map several facets to the same index. The mapping must form an increasing sequence, such that it is possible to copy values without an intermediate buffer. Elements mapped to invalid<Index>() will not be copied.
[in] | old_to_new | Mapping old facet index -> new facet index. |
|
protected |
Resize the buffers associated to a specific element type in the mesh.
Newly inserted elements will be default-initialized.
[in] | num_elements | New number of elements. |
element | Element type to resize (vertices, facets, etc.). |
|
protected |
Resize the buffers associated to mesh vertices and their attributes.
Newly inserted elements will be default-initialized.
[in] | num_vertices | New number of vertices. |
|
protected |
Resize the buffers associated to mesh facets and their attributes.
Newly inserted elements will be default-initialized.
[in] | num_facets | New number of facets. |
|
protected |
Resize the buffers associated to mesh corners and their attributes.
Newly inserted elements will be default-initialized.
[in] | num_corners | New number of corners. |
|
protected |
Resize the buffers associated to mesh edges and their attributes.
Newly inserted elements will be default-initialized.
[in] | num_edges | New number of edges. |
Reserve index buffer for multiple facets of a given size.
If storage needs to be changed to a hybrid format, allocates facet offsets as necessary.
[in] | num_facets | Number of facets to add. |
[in] | facet_size | Size of each facet to add. |
Reserve index buffer for multiple facets of a given size.
If storage needs to be changed to a hybrid format, allocates facet offsets as necessary.
[in] | facet_sizes | A contiguous array representing the size of each facet to add. |
|
protected |
Reserve index buffer for multiple facets of a given size.
If storage needs to be changed to a hybrid format, allocates facet offsets as necessary.
[in] | num_facets | Number of facets to add. |
[in] | get_facets_size | Callable function to retrieve the size of each facet to be added. |
Compute inverse mapping corner -> facet index for a specific range of facets.
[in] | facet_begin | First facet in the range. |
[in] | facet_end | Index beyond the last facet in the range. |
|
protected |
Initializes attributes associated to mesh edges and connectivity.
Internal method to avoid code duplication.
[in] | num_user_edges | Number of edges in the user-provided ordering. |
[in] | get_user_edge_ptr | Callback function to retrieve the vertices endpoints of an edge given its user-provided index. |
|
protected |
Update attributes associated to mesh edges and connectivity for a specific range of facets.
Corner chains are recomputed for the affected facet corners, unused edge indices are recycled and edge attributes are resized accordingly.
This function is called internally when edge attributes are initialized, when new facets are added to the mesh, or manually after a user updates facet indices.
If a user-defined ordering of the mesh edges is provided, it must be a valid indexing for the newly added edges (i.e. all edges that were not already present in the mesh must appear exactly once in the user-provided array).
[in] | facet_begin | First facet in the range. |
[in] | facet_end | Index beyond the last facet in the range. |
[in] | num_user_edges | Number of edges in the user-provided ordering. |
[in] | get_user_edge_ptr | Callback function to retrieve the vertices endpoints of an edge given its user-provided index. |
|
protected |
Same as update_edges_range_internal, but operate on the last count facets in the mesh instead.
[in] | count | Number of facets to update. |
[in] | num_user_edges | Number of edges in the user-provided ordering. |
[in] | get_user_edge_ptr | Callback function to retrieve the vertices endpoints of an edge given its user-provided index. |
|
protected |
Gets the number of mesh elements, based on an element type.
If the queried element type is edges, and edge data has not been initialized, an exception is thrown.
[in] | element | Type of element (vertex, facet, etc.). |
|
protected |
Wrap a span in an attribute.
ValueType | The attribute value type. |
[in] | attr | The attribute object. |
[in] | num_values | The number of elements to wrap. |
[in] | values_view | A view of the raw buffer. Its size must sufficiently large to hold at least num_values elements. |
|
protected |
Wrap a shared span in an attribute.
The attribute object will take a share of the memory ownership of the external buffer referred by the shared span so that it will stay alive as long as the attribute is using it.
ValueType | The attribute value type. |
[in] | attr | The attribute object. |
[in] | num_values | The number of elements to wrap. |
[in] | shared_values | A shared span object with memory ownership tracking support. Its size must sufficiently large to hold at least num_values elements. |
|
protected |
Wrap shared spans as offsets and facets.
OffsetSpan | The offset span type. Should be either span<T> or SharedSpan<T> . |
FacetSpan | The facet span type. Should be either span<T> or SharedSpan<T> . |
offsets | The offset span. Its size should be >= num_facets . |
num_facets | The number of facets. |
facets | The facet span. Its size should be >= num_corners . |
num_corners | The number of corners. |
|
protected |
The most generic way of creating an attribute wrapped around external buffers.
Based on the element
type, it will create either a normal attribute or an indexed attribute. The generated attribute will have the same "const-ness" as the value_type
of the span. If a SharedSpan is used, the attribute will participate in ownership sharing of the buffer it uses.
ValueSpan | The value span type. Should be either span<T> or SharedSpan<T> . |
IndexSpan | The index span type. Should be either span<T> or SharedSpan<T> . |
name | The attribute name. |
element | The attribute element type. |
usage | The attribute usage type. |
num_values | The number of values. |
num_channels | The number of channels. |
values | The value span. Its size should be >= num_values * num_channels. |
indices | The index span. Its size should be >= the number of corresponding elements. It is only used for creating indexed attribute. |
std::string_view items[9] |