Lagrange
SurfaceMesh< Scalar_, Index_ > Class Template Reference

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 Scalarget_position (Index v) const
 Retrieves a read-only pointer to a vertex coordinates. More...
 
span< Scalarref_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 Indexget_facet_vertices (Index f) const
 Retrieves a read-only pointer to a facet indices. More...
 
span< Indexref_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 AttributeBaseget_attribute_base (std::string_view name) const
 Gets a read-only reference to the base class of attribute given its name. More...
 
const AttributeBaseget_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, Indexreindex_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< Indexreserve_indices_internal (Index num_facets, Index facet_size)
 Reserve index buffer for multiple facets of a given size. More...
 
span< Indexreserve_indices_internal (span< const Index > facet_sizes)
 Reserve index buffer for multiple facets of a given size. More...
 
span< Indexreserve_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...
 
SurfaceMeshoperator= (SurfaceMesh &&other) noexcept
 Assignment move operator. More...
 
 SurfaceMesh (const SurfaceMesh &other)
 Copy constructor. More...
 
SurfaceMeshoperator= (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...
 

Detailed Description

template<typename Scalar_, typename Index_>
class lagrange::SurfaceMesh< Scalar_, Index_ >

A general purpose polygonal mesh class.

Template Parameters
Scalar_Mesh scalar type.
Index_Mesh index type.
See also
Related documentation:
Related headers:

Member Typedef Documentation

◆ SetVertexCoordinatesFunction

Callback function to set vertex coordinates.

Parameters
[in]vIndex of the vertex to set coordinates for (relative to the newly inserted vertices, i.e. starts at 0).
[out]pOutput 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).
See also
add_vertices

◆ SetSingleFacetIndicesFunction

Callback function to set indices of a single facet.

The facet size is fixed and known in advance by the user.

Parameters
[out]tOutput index buffer to write to.
See also
add_polygon

◆ SetMultiFacetsIndicesFunction

Callback function to set indices of a multiple facets.

Parameters
[in]fIndex of the facet whose size to compute (relative to the newly inserted facets, starting with 0).
[out]tOutput index buffer to write to. You can query the size of the current output facet by calling t.size().
See also
add_triangles, add_quads, add_polygons, add_hybrid

◆ GetFacetsSizeFunction

Callback function to get a facet size (number of vertices in the facet).

Parameters
[in]fIndex of the facet whose size to compute (relative to the newly inserted facets, starting with 0).
See also
add_hybrid

◆ GetEdgeVertices

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.

Parameters
[in]eIndex of the edge being queried.
Returns
A pair of indices for the vertex endpoints.

Constructor & Destructor Documentation

◆ SurfaceMesh() [1/4]

SurfaceMesh ( Index  dimension = 3)
explicit

Default constructor.

Parameters
[in]dimensionVertex dimension.

◆ SurfaceMesh() [2/4]

SurfaceMesh ( SurfaceMesh< Scalar_, Index_ > &&  other)
defaultnoexcept

Move constructor.

Parameters
otherInstance to move from.

◆ SurfaceMesh() [3/4]

SurfaceMesh ( const SurfaceMesh< Scalar_, Index_ > &  other)
default

Copy constructor.

Parameters
[in]otherInstance to copy from.

◆ SurfaceMesh() [4/4]

SurfaceMesh ( BareMeshTag  tag)
explicitprotected

Internal constructor.

Parameters
[in]tagTag to distinguish from the public constructor.

Member Function Documentation

◆ operator=() [1/2]

SurfaceMesh< Scalar, Index > & operator= ( SurfaceMesh< Scalar_, Index_ > &&  other)
defaultnoexcept

Assignment move operator.

Parameters
otherInstance to move from.
Returns
The result of the assignment.

◆ operator=() [2/2]

SurfaceMesh< Scalar, Index > & operator= ( const SurfaceMesh< Scalar_, Index_ > &  other)
default

Assignment copy operator.

Parameters
[in]otherInstance to copy from.
Returns
The result of the copy.

◆ stripped_copy()

static SurfaceMesh stripped_copy ( const SurfaceMesh< OtherScalar, OtherIndex > &  other)
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.

Note
Should this function take an optional list of attribute ids to preserve, and/or provide stable attribute ids?
Parameters
[in]otherInstance to copy from.
Template Parameters
OtherScalarOther mesh scalar type.
OtherIndexOther mesh index type.
Returns
The result of the copy.
See also
cast
filter_attributes

◆ stripped_move()

static SurfaceMesh stripped_move ( SurfaceMesh< OtherScalar, OtherIndex > &&  other)
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.

Note
Should this function take an optional list of attribute ids to preserve, and/or provide stable attribute ids?
Parameters
[in]otherInstance to move from.
Template Parameters
OtherScalarOther mesh scalar type.
OtherIndexOther mesh index type.
Returns
The result of the move.
See also
cast
filter_attributes

◆ add_vertex() [1/2]

void add_vertex ( span< const Scalar p)

Adds a vertex to the mesh.

Parameters
[in]pVertex coordinates with the same dimensionality as the mesh.

◆ add_vertex() [2/2]

void add_vertex ( std::initializer_list< const Scalar p)

Adds a vertex to the mesh.

Parameters
[in]pVertex coordinates with the same dimensionality as the mesh.

◆ add_vertices() [1/3]

void add_vertices ( Index  num_vertices,
span< const Scalar coordinates = {} 
)

Adds multiple vertices to the mesh.

Parameters
[in]num_verticesNumber of vertices to add.
[in]coordinatesA contiguous array of point coordinates (num_vertices x dimension).

◆ add_vertices() [2/3]

void add_vertices ( Index  num_vertices,
std::initializer_list< const Scalar coordinates 
)

Adds multiple vertices to the mesh.

Parameters
[in]num_verticesNumber of vertices to add.
[in]coordinatesA contiguous array of point coordinates (num_vertices x dimension).

◆ add_vertices() [3/3]

void add_vertices ( Index  num_vertices,
SetVertexCoordinatesFunction  set_vertex_coordinates 
)

Adds multiple vertices to the mesh.

Parameters
[in]num_verticesNumber of vertices to add.
[in]set_vertex_coordinatesFunction to set point coordinates of a given vertex.

◆ add_triangle()

void add_triangle ( Index  v0,
Index  v1,
Index  v2 
)

Adds a triangular facet to the mesh.

Parameters
[in]v0Index of the first vertex.
[in]v1Index of the second vertex.
[in]v2Index of the third vertex.

◆ add_triangles() [1/3]

void add_triangles ( Index  num_facets,
span< const Index facet_indices = {} 
)

Adds multiple triangular facets to the mesh.

Warning
If the mesh contains edge/connectivity attributes, this function will throw an exception if you pass an empty buffer of facet indices. This is because it is impossible to update edge/connectivity information if the facet buffer is directly modified by the user. Instead, the correct facet indices must be provided when the facet is constructed.
Parameters
[in]num_facetsNumber of facets to add.
[in]facet_indicesA contiguous array of corner indices, where facet_indices[3*i+k] is the index of the k-th corner of the i-th facet.

◆ add_triangles() [2/3]

void add_triangles ( Index  num_facets,
std::initializer_list< const Index facet_indices 
)

Adds multiple triangular facets to the mesh.

Warning
If the mesh contains edge/connectivity attributes, this function will throw an exception if you pass an empty buffer of facet indices. This is because it is impossible to update edge/connectivity information if the facet buffer is directly modified by the user. Instead, the correct facet indices must be provided when the facet is constructed.
Parameters
[in]num_facetsNumber of facets to add.
[in]facet_indicesA contiguous array of corner indices, where facet_indices[3*i+k] is the index of the k-th corner of the i-th facet.

◆ add_triangles() [3/3]

void add_triangles ( Index  num_facets,
SetMultiFacetsIndicesFunction  set_facets_indices 
)

Adds multiple triangular facets to the mesh.

Parameters
[in]num_facetsNumber of facets to add.
[in]set_facets_indicesCallable function to set vertex indices of a given facet.

◆ add_quad()

void add_quad ( Index  v0,
Index  v1,
Index  v2,
Index  v3 
)

Adds a quadrilateral facet to the mesh.

Parameters
[in]v0Index of the first vertex.
[in]v1Index of the second vertex.
[in]v2Index of the third vertex.
[in]v3Index of the fourth vertex.

◆ add_quads() [1/3]

void add_quads ( Index  num_facets,
span< const Index facet_indices = {} 
)

Adds multiple quadrilateral facets to the mesh.

Warning
If the mesh contains edge/connectivity attributes, this function will throw an exception if you pass an empty buffer of facet indices. This is because it is impossible to update edge/connectivity information if the facet buffer is directly modified by the user. Instead, the correct facet indices must be provided when the facet is constructed.
Parameters
[in]num_facetsNumber of facets to add.
[in]facet_indicesA contiguous array of corner indices, where facet_indices[4*i+k] is the index of the k-th corner of the i-th facet.

◆ add_quads() [2/3]

void add_quads ( Index  num_facets,
std::initializer_list< const Index facet_indices 
)

Adds multiple quadrilateral facets to the mesh.

Warning
If the mesh contains edge/connectivity attributes, this function will throw an exception if you pass an empty buffer of facet indices. This is because it is impossible to update edge/connectivity information if the facet buffer is directly modified by the user. Instead, the correct facet indices must be provided when the facet is constructed.
Parameters
[in]num_facetsNumber of facets to add.
[in]facet_indicesA contiguous array of corner indices, where facet_indices[4*i+k] is the index of the k-th corner of the i-th facet.

◆ add_quads() [3/3]

void add_quads ( Index  num_facets,
SetMultiFacetsIndicesFunction  set_facets_indices 
)

Adds multiple quadrilateral facets to the mesh.

Parameters
[in]num_facetsNumber of facets to add.
[in]set_facets_indicesCallable function to set vertex indices of a given facet.

◆ add_polygon() [1/4]

void add_polygon ( Index  facet_size)

Adds a single (uninitialized) polygonal facet to the mesh.

Facet indices are set to 0.

Parameters
[in]facet_sizeNumber of vertices in the facet.

◆ add_polygon() [2/4]

void add_polygon ( span< const Index facet_indices)

Adds a single polygonal facet to the mesh.

Parameters
[in]facet_indicesA contiguous array of vertex indices in the facet.

◆ add_polygon() [3/4]

void add_polygon ( std::initializer_list< const Index facet_indices)

Adds a single polygonal facet to the mesh.

Parameters
[in]facet_indicesA contiguous array of vertex indices in the facet.

◆ add_polygon() [4/4]

void add_polygon ( Index  facet_size,
SetSingleFacetIndicesFunction  set_facet_indices 
)

Adds a single polygonal facet to the mesh.

Parameters
[in]facet_sizeNumber of vertices in the facet.
[in]set_facet_indicesCallable function to retrieve facet indices.

◆ add_polygons() [1/3]

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.

Warning
If the mesh contains edge/connectivity attributes, this function will throw an exception if you pass an empty buffer of facet indices. This is because it is impossible to update edge/connectivity information if the facet buffer is directly modified by the user. Instead, the correct facet indices must be provided when the facet is constructed.
Parameters
[in]num_facetsNumber of facets to add.
[in]facet_sizeSize of each facet to be added.
[in]facet_indicesA 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.

◆ add_polygons() [2/3]

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.

Warning
If the mesh contains edge/connectivity attributes, this function will throw an exception if you pass an empty buffer of facet indices. This is because it is impossible to update edge/connectivity information if the facet buffer is directly modified by the user. Instead, the correct facet indices must be provided when the facet is constructed.
Parameters
[in]num_facetsNumber of facets to add.
[in]facet_sizeSize of each facet to be added.
[in]facet_indicesA 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.

◆ add_polygons() [3/3]

void add_polygons ( Index  num_facets,
Index  facet_size,
SetMultiFacetsIndicesFunction  set_facets_indices 
)

Adds multiple polygonal facets of the same size to the mesh.

Parameters
[in]num_facetsNumber of facets to add.
[in]facet_sizeSize of each facet to be added.
[in]set_facets_indicesCallable function to set vertex indices of a given facet.

◆ add_hybrid() [1/3]

void add_hybrid ( span< const Index facet_sizes,
span< const Index facet_indices = {} 
)

Adds multiple polygonal facets of different sizes to the mesh.

Warning
If the mesh contains edge/connectivity attributes, this function will throw an exception if you pass an empty buffer of facet indices. This is because it is impossible to update edge/connectivity information if the facet buffer is directly modified by the user. Instead, the correct facet indices must be provided when the facet is constructed.
Parameters
[in]facet_sizesA contiguous array representing the size of each facet to add.
[in]facet_indicesA 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.

◆ add_hybrid() [2/3]

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.

Warning
If the mesh contains edge/connectivity attributes, this function will throw an exception if you pass an empty buffer of facet indices. This is because it is impossible to update edge/connectivity information if the facet buffer is directly modified by the user. Instead, the correct facet indices must be provided when the facet is constructed.
Parameters
[in]facet_sizesA contiguous array representing the size of each facet to add.
[in]facet_indicesA 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.

◆ add_hybrid() [3/3]

void add_hybrid ( Index  num_facets,
GetFacetsSizeFunction  facet_sizes,
SetMultiFacetsIndicesFunction  set_facets_indices 
)

Adds multiple polygonal facets of different sizes to the mesh.

Parameters
[in]num_facetsNumber of facets to add.
[in]facet_sizesCallable function to retrieve the size of each facet to be added.
[in]set_facets_indicesCallable function to set vertex indices of a given facet.

◆ remove_vertices() [1/3]

void remove_vertices ( span< 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.

Note
This function will remove any facet incident to a removed vertex.
Parameters
[in]vertices_to_removeThe vertices to remove.

◆ remove_vertices() [2/3]

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.

Note
This function will remove any facet incident to a removed vertex.
Parameters
[in]vertices_to_removeThe vertices to remove.

◆ remove_vertices() [3/3]

void remove_vertices ( function_ref< bool(Index)>  should_remove_func)

Removes a list of vertices, defined by a predicate function.

Note
This function will remove any facet incident to a removed vertex.
Parameters
[in]should_remove_funcFunction to determine if a vertex of a particular index should be removed.

◆ remove_facets() [1/3]

void remove_facets ( span< 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.

Note
This function does not remove any isolated vertex that occurs due to facet removal.
Parameters
[in]facets_to_removeThe facets to remove.

◆ remove_facets() [2/3]

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.

Note
This function does not remove any isolated vertex that occurs due to facet removal.
Parameters
[in]facets_to_removeThe facets to remove.

◆ remove_facets() [3/3]

void remove_facets ( function_ref< bool(Index)>  should_remove_func)

Removes a list of facets, defined by a predicate function.

Note
This function does not remove any isolated vertex that occurs due to facet removal.
Parameters
[in]should_remove_funcFunction to determine if a facet of a particular index should be removed.

◆ clear_vertices()

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.

◆ clear_facets()

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.

◆ compress_if_regular()

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:

  • "$facet_to_first_corner"
  • "$corner_to_facet"

◆ is_triangle_mesh()

bool is_triangle_mesh

Whether the mesh must only contain triangular facets.

Accessors.

A mesh with no facet is considered a triangle mesh.

Note
A mesh with hybrid storage may still be a triangle mesh, which this method does not check.
Returns
True if triangle mesh, False otherwise.

◆ is_quad_mesh()

bool is_quad_mesh

Whether the mesh must only contains quadrilateral facets.

A mesh with no facet is considered a quad mesh.

Note
A mesh with hybrid storage may still be a quad mesh, which this method does not check.
Returns
True if quad mesh, False otherwise.

◆ is_regular()

bool is_regular

Whether the mesh must only contains facets of equal sizes.

A mesh with no facet is considered regular.

Note
A mesh with hybrid storage may still be have regular facet sizes, which this method does not check.
Returns
True if regular, False otherwise.

◆ is_hybrid()

bool is_hybrid ( ) const
inline

Whether the mesh may contain facets of different sizes.

This is the opposite of is_regular (an empty mesh is not considered hybrid).

Note
A mesh with hybrid storage may still have all its facet be the same size, which this method does not check.
Returns
True if hybrid, False otherwise.

◆ get_dimension()

Index get_dimension ( ) const
inline

Retrieves the dimension of the mesh vertices.

Returns
The mesh dimension.

◆ get_vertex_per_facet()

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.

Returns
The number of vertices per facet.

◆ get_num_vertices()

Index get_num_vertices ( ) const
inline

Retrieves the number of vertices.

Returns
The number of vertices.

◆ get_num_facets()

Index get_num_facets ( ) const
inline

Retrieves the number of facets.

Returns
The number of facets.

◆ get_num_corners()

Index get_num_corners ( ) const
inline

Retrieves the number of corners.

Returns
The number of corners.

◆ get_num_edges()

Index get_num_edges ( ) const
inline

Retrieves the number of edges.

Returns
The number of edges.

◆ get_position()

auto get_position ( Index  v) const

Retrieves a read-only pointer to a vertex coordinates.

Parameters
[in]vVertex index.
Returns
Point coordinates of the queried vertex.

◆ ref_position()

auto ref_position ( Index  v)

Retrieves a writeable pointer to a vertex coordinates.

Parameters
[in]vVertex index.
Returns
Point coordinates of the queried vertex.

◆ get_facet_size()

Index get_facet_size ( Index  f) const
inline

Number of vertices in the facet.

Parameters
[in]fFacet index.
Returns
Number of vertices in the queried facet.

◆ get_facet_vertex()

Index get_facet_vertex ( Index  f,
Index  lv 
) const
inline

Index of a vertex given from a facet + local index.

Parameters
[in]fFacet index.
[in]lvLocal vertex index inside the facet.
Returns
Index of the vertex in the mesh.

◆ get_facet_corner_begin()

auto get_facet_corner_begin ( Index  f) const

First corner around the facet.

Parameters
[in]fFacet index.
Returns
First corner index for the queried facet.

◆ get_facet_corner_end()

auto get_facet_corner_end ( Index  f) const

Index past the last corner around the facet.

Parameters
[in]fFacet index.
Returns
Index past the last corner index for the queried facet.

◆ get_corner_vertex()

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.

Parameters
[in]cCorner index.
Returns
Index of the vertex in the mesh.

◆ get_corner_facet()

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

Parameters
[in]cCorner index.
Returns
Index of the facet containing this corner.

◆ get_facet_vertices()

auto get_facet_vertices ( Index  f) const

Retrieves a read-only pointer to a facet indices.

Parameters
[in]fFacet index.
Returns
A pointer to the facet vertices.

◆ ref_facet_vertices()

auto ref_facet_vertices ( Index  f)

Retrieves a writable pointer to a facet indices.

Warning
If the mesh contains edge/connectivity attributes, this function will throw an exception. This is because it is impossible to update edge/connectivity information if the facet buffer is directly modified by the user. Instead, the correct facet indices must be provided when the facet is constructed.
Parameters
[in]fFacet index.
Returns
A pointer to the facet vertices.

◆ get_attribute_id()

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.

Parameters
[in]nameAttribute name.
Returns
The attribute identifier.

◆ get_attribute_name()

std::string_view get_attribute_name ( AttributeId  id) const

Retrieve attribute name from its id.

Parameters
[in]idAttribute id.
Returns
Attribute's name.
Exceptions
Exceptionif id is invalid.

◆ create_attribute() [1/2]

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.

Parameters
[in]nameAttribute name to create.
[in]elementMesh element to which the attribute is attached to (Vertex, Facet, etc.).
[in]num_channelsThe number of channels for the attribute. Cannot be modified once the attribute has been created.
[in]usageTag to indicate how the values are modified under rigid transformation.
[in]initial_valuesA 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_indicesA 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]policyAttribute creation policy. By default using a reserved attribute name (starting with a "$") will throw an exception.
Template Parameters
ValueTypeValue type for the attribute.
Returns
The attribute identifier.
See also
AttributeUsage

◆ create_attribute() [2/2]

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.

Parameters
[in]nameAttribute name to create.
[in]elementMesh element to which the attribute is attached to (Vertex, Facet, etc.).
[in]usageTag to indicate how the values are modified under rigid transformation.
[in]num_channelsThe number of channels for the attribute. Cannot be modified once the attribute has been created.
[in]initial_valuesA 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_indicesA 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]policyAttribute creation policy. By default using a reserved attribute name (starting with a "$") will throw an exception.
Template Parameters
ValueTypeValue type for the attribute.
Returns
The attribute identifier.
See also
AttributeUsage

◆ create_attribute_from()

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.

Parameters
[in]nameAttribute name to create.
[in]source_meshSource mesh from which to copy the attribute from. The mesh can reference itself.
[in]source_nameAttribute name to copy from. If left empty, the target attribute name will be used.
Template Parameters
OtherScalarSource mesh scalar type.
OtherIndexSource mesh index type.
Returns
The attribute identifier.

◆ wrap_as_attribute() [1/2]

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).

Parameters
[in]nameAttribute name to create.
[in]elementMesh 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]usageTag to indicate how the values are modified under rigid transformation.
[in]num_channelsThe number of channels for the attribute. Cannot be modified once the attribute has been created.
[in]values_viewA 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.
Template Parameters
ValueTypeValue type for the attribute.
Returns
The attribute identifier.

◆ wrap_as_attribute() [2/2]

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.

Note
This function differs from the prevous version by participating in shared ownership management of the buffer referred by shared_values.

◆ wrap_as_const_attribute() [1/2]

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.

Parameters
[in]nameAttribute name to create.
[in]elementMesh 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]usageTag to indicate how the values are modified under rigid transformation.
[in]num_channelsThe number of channels for the attribute. Cannot be modified once the attribute has been created.
[in]values_viewA 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.
Template Parameters
ValueTypeValue type for the attribute.
Returns
The attribute identifier.

◆ wrap_as_const_attribute() [2/2]

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.

Note
This function differs from the prevous version by participating in shared ownership management of the buffer referred by shared_values.

◆ wrap_as_indexed_attribute() [1/4]

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).

Parameters
[in]nameAttribute name to create.
[in]usageTag to indicate how the values are modified under rigid transformation.
[in]num_valuesInitial number of rows in the value buffer for the attribute.
[in]num_channelsThe number of channels for the attribute. Cannot be modified once the attribute has been created.
[in]values_viewA 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_viewA 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.
Template Parameters
ValueTypeValue type for the attribute.
Returns
The attribute identifier.

◆ wrap_as_indexed_attribute() [2/4]

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.

Note
This function differs from the prevous version by participating in shared ownership management of the buffer referred by shared_values and shared_indices.

◆ wrap_as_indexed_attribute() [3/4]

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.

Note
This function differs from the prevous version by participating in shared ownership management of the buffer referred by shared_indices.

◆ wrap_as_indexed_attribute() [4/4]

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.

Note
This function differs from the prevous version by participating in shared ownership management of the buffer referred by shared_values.

◆ wrap_as_const_indexed_attribute() [1/4]

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.

Parameters
[in]nameAttribute name to create.
[in]usageTag to indicate how the values are modified under rigid transformation.
[in]num_valuesInitial number of rows in the value buffer for the attribute.
[in]num_channelsThe number of channels for the attribute. Cannot be modified once the attribute has been created.
[in]values_viewA 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_viewA 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.
Template Parameters
ValueTypeValue type for the attribute.
Returns
The attribute identifier.

◆ wrap_as_const_indexed_attribute() [2/4]

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.

Note
This function differs from the prevous version by participating in shared ownership management of the buffers referred by shared_values and shared_indices.

◆ wrap_as_const_indexed_attribute() [3/4]

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.

Note
This function differs from the prevous version by participating in shared ownership management of the buffer referred by shared_indices.

◆ wrap_as_const_indexed_attribute() [4/4]

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.

Note
This function differs from the prevous version by participating in shared ownership management of the buffer referred by shared_values.

◆ wrap_as_vertices() [1/2]

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.

Note
The mesh dimension cannot be changed, and is determined by the mesh constructor.
Parameters
[in]vertices_viewA 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_verticesNumber of vertices to resize the mesh with.
Returns
The attribute identifier.

◆ wrap_as_vertices() [2/2]

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.

Note
This function differs from the prevous version by participating in shared ownership management of the buffer referred by shared_vertices.

◆ wrap_as_const_vertices() [1/2]

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.

Note
The mesh dimension cannot be changed, and is determined by the mesh constructor.
Parameters
[in]vertices_viewA 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_verticesNumber of vertices to resize the mesh with.
Returns
The attribute identifier.

◆ wrap_as_const_vertices() [2/2]

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.

Note
This function differs from the prevous version by participating in shared ownership management of the buffer referred by shared_vertices.

◆ wrap_as_facets() [1/6]

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.

Parameters
[in]facets_viewA 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_facetsNumber of facets to resize the mesh with.
[in]vertex_per_facetNumber of vertices per facet in the provided span.
Returns
The attribute identifier.

◆ wrap_as_facets() [2/6]

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.

Note
This function differs from the prevous version by participating in shared ownership management of the buffer referred by shared_facets.

◆ wrap_as_const_facets() [1/6]

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.

Parameters
[in]facets_viewA 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_facetsNumber of facets to resize the mesh with.
[in]vertex_per_facetNumber of vertices per facet in the provided span.
Returns
The attribute identifier.

◆ wrap_as_const_facets() [2/6]

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.

Note
This function differs from the prevous version by participating in shared ownership management of the buffer referred by shared_facets.

◆ wrap_as_facets() [3/6]

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.

Parameters
[in]offsets_viewA 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_facetsNumber of facets to resize the mesh with.
[in]facets_viewA 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_cornersTotal number of facet corners in the resized mesh.
Returns
The attribute identifier.

◆ wrap_as_facets() [4/6]

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.

Note
This function differs from the prevous version by participating in shared ownership management of the buffers referred by shared_offsets and shared_facets.

◆ wrap_as_facets() [5/6]

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.

Note
This function differs from the prevous version by participating in shared ownership management of the buffer referred by shared_facets.

◆ wrap_as_facets() [6/6]

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.

Note
This function differs from the prevous version by participating in shared ownership management of the buffer referred by shared_offsets.

◆ wrap_as_const_facets() [3/6]

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.

Parameters
[in]offsets_viewA 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_facetsNumber of facets to resize the mesh with.
[in]facets_viewA 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_cornersTotal number of facet corners in the resized mesh.
Returns
The attribute identifier.

◆ wrap_as_const_facets() [4/6]

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.

Note
This function differs from the prevous version by participating in shared ownership management of the buffers referred by shared_offsets and shared_facets.

◆ wrap_as_const_facets() [5/6]

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.

Note
This function differs from the prevous version by participating in shared ownership management of the buffer referred by shared_facets.

◆ wrap_as_const_facets() [6/6]

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.

Note
This function differs from the prevous version by participating in shared ownership management of the buffer referred by shared_offsets.

◆ duplicate_attribute()

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.

Parameters
[in]old_nameOld attribute name to duplicate.
[in]new_nameNew attribute name to create.
Returns
The attribute identifier for the new attribute.

◆ rename_attribute()

void rename_attribute ( std::string_view  old_name,
std::string_view  new_name 
)

Rename an existing attribute.

Attribute id remains unchanged.

Parameters
[in]old_nameOld attribute name.
[in]new_nameNew attribute name.

◆ delete_attribute()

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.

Note
There is no performance benefit in deleting an attribute given by id only, as we would need to free its name from the list of existing attributes anyway.
Parameters
[in]nameAttribute name.
[in]policyDelete policy for reserved attribute names.

◆ delete_and_export_attribute()

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.

  • If the content is managed by the mesh:
    1. If it is uniquely owned, no copy is performed.
    2. If ownership is shared, a copy is performed (just like any other copy-on-write operation).
  • If the content points to an external buffer, a policy flag determines what happens.
Parameters
[in]nameAttribute name
[in]delete_policyDelete policy for reserved attribute names.
[in]export_policyExport policy for non-owned buffers.
Template Parameters
ValueTypeValue type for the attribute.
Returns
A shared pointer holding the attribute data.

◆ delete_and_export_const_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.

  • If the content is managed by the mesh:
    1. If it is uniquely owned, no copy is performed.
    2. If ownership is shared, a copy is performed (just like any other copy-on-write operation).
  • If the content points to an external buffer, a policy flag determines what happens.
Parameters
[in]nameAttribute name
[in]delete_policyDelete policy for reserved attribute names.
[in]export_policyExport policy for non-owned buffers.
Template Parameters
ValueTypeValue type for the attribute.
Returns
A shared pointer holding the attribute data.

◆ delete_and_export_indexed_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.

  • If the content is managed by the mesh:
    1. If it is uniquely owned, no copy is performed.
    2. If ownership is shared, a copy is performed (just like any other copy-on-write operation).
  • If the content points to an external buffer, a policy flag determines what happens.
Parameters
[in]nameAttribute name
[in]policyExport policy for non-owned buffers.
Template Parameters
ValueTypeValue type for the attribute.
Returns
A shared pointer holding the attribute data.

◆ delete_and_export_const_indexed_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.

  • If the content is managed by the mesh:
    1. If it is uniquely owned, no copy is performed.
    2. If ownership is shared, a copy is performed (just like any other copy-on-write operation).
  • If the content points to an external buffer, a policy flag determines what happens.
Parameters
[in]nameAttribute name
[in]policyExport policy for non-owned buffers.
Template Parameters
ValueTypeValue type for the attribute.
Returns
A shared pointer holding the attribute data.

◆ create_metadata()

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:

  • Element type is AttributeElement::Value
  • Usage is AttributeUsage::String
  • ValueType is uint8_t
  • Number of channels is 1.
Parameters
nameAttribute name.
valueAttribute default value.
Returns
AttributeId Id of the newly created attribute

◆ set_metadata() [1/2]

void set_metadata ( AttributeId  id,
std::string_view  value 
)

Write metadata attribute value.

Parameters
idAttribute id.
valueAttribute value.

◆ set_metadata() [2/2]

void set_metadata ( std::string_view  name,
std::string_view  value 
)

Write metadata attribute value.

Parameters
[in]nameThe name
valueAttribute value.
idAttribute id.

◆ get_metadata() [1/2]

std::string_view get_metadata ( AttributeId  id) const

Read metadata attribute value.

Parameters
idAttribute id.
Returns
Attribute value.

◆ get_metadata() [2/2]

std::string_view get_metadata ( std::string_view  name) const

Read metadata attribute value.

Parameters
nameAttribute name.
Returns
Attribute value.

◆ has_attribute()

bool has_attribute ( std::string_view  name) const

Checks if an attribute of a given name is attached to the mesh.

Note
Attribute ids can be reused after deletion, so it does not make sense to test if an attribute exist based on an attribute id.
Parameters
[in]nameAttribute name.
Returns
True if the attribute exists, False otherwise.

◆ is_attribute_type() [1/2]

bool is_attribute_type ( std::string_view  name) const

Checks whether the specified attribute is of a given type.

Parameters
[in]nameName of the attribute to test.
Template Parameters
ValueTypeAttribute type to test against.
Returns
True if the specified attribute has the given type, False otherwise.

◆ is_attribute_type() [2/2]

bool is_attribute_type ( AttributeId  id) const

Checks whether the specified attribute is of a given type.

Parameters
[in]idId of the attribute to test.
Template Parameters
ValueTypeAttribute type to test against.
Returns
True if the specified attribute has the given type, False otherwise.

◆ is_attribute_indexed() [1/2]

bool is_attribute_indexed ( std::string_view  name) const

Determines whether the specified attribute is indexed.

Parameters
[in]nameName of the attribute to test.
Returns
True if the specified attribute is indexed, False otherwise.

◆ is_attribute_indexed() [2/2]

bool is_attribute_indexed ( AttributeId  id) const

Determines whether the specified attribute is indexed.

Parameters
[in]idId of the attribute to test.
Returns
True if the specified attribute is indexed, False otherwise.

◆ seq_foreach_attribute_id() [1/2]

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.

See also
foreach_attribute.h
Parameters
[in]funcFunction to iterate over attributes ids.

◆ seq_foreach_attribute_id() [2/2]

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.

See also
foreach_attribute.h
Parameters
[in]funcFunction to iterate over attributes names x ids.

◆ par_foreach_attribute_id() [1/2]

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.

See also
foreach_attribute.h
Parameters
[in]funcFunction to iterate over attributes ids.

◆ par_foreach_attribute_id() [2/2]

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.

See also
foreach_attribute.h
Parameters
[in]funcFunction to iterate over attributes names x ids.

◆ get_attribute_base() [1/2]

const AttributeBase & get_attribute_base ( std::string_view  name) const

Gets a read-only reference to the base class of attribute given its name.

Parameters
[in]nameAttribute name.
Returns
The attribute reference.

◆ get_attribute_base() [2/2]

const AttributeBase & get_attribute_base ( AttributeId  id) const

Gets a read-only reference to an attribute given its id.

Parameters
[in]idAttribute id.
Returns
The attribute reference.

◆ get_attribute() [1/2]

const Attribute< ValueType > & get_attribute ( std::string_view  name) const

Gets a read-only reference to an attribute given its name.

Parameters
[in]nameAttribute name.
Template Parameters
ValueTypeScalar type stored in the attribute.
Returns
The attribute reference.

◆ get_attribute() [2/2]

const Attribute< ValueType > & get_attribute ( AttributeId  id) const

Gets a read-only reference to an attribute given its id.

Parameters
[in]idAttribute id.
Template Parameters
ValueTypeScalar type stored in the attribute.
Returns
The attribute reference.

◆ _get_attribute_ptr() [1/2]

internal::weak_ptr< const AttributeBase > _get_attribute_ptr ( std::string_view  name) const

Gets a read-only weak pointer to the base attribute object.

Parameters
[in]nameAttribute name.
Returns
A weak ptr to the base attribute object.
Note
This method is for tracking the life span of the attribute object.

◆ _get_attribute_ptr() [2/2]

internal::weak_ptr< const AttributeBase > _get_attribute_ptr ( AttributeId  id) const

Gets a read-only weak pointer to the base attribute object.

Parameters
[in]idAttribute id.
Returns
A weak ptr to the base attribute object.
Note
This method is for tracking the life span of the attribute object.

◆ get_indexed_attribute() [1/2]

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.

Parameters
[in]nameAttribute name.
Template Parameters
ValueTypeScalar type stored in the attribute.
Returns
The attribute reference.

◆ get_indexed_attribute() [2/2]

auto get_indexed_attribute ( AttributeId  id) const -> const IndexedAttribute<ValueType, Index>&

Gets a read-only reference to an indexed attribute given its id.

Parameters
[in]idAttribute id.
Template Parameters
ValueTypeScalar type stored in the attribute.
Returns
The attribute reference.

◆ ref_attribute() [1/2]

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.

Parameters
[in]nameAttribute name.
Template Parameters
ValueTypeScalar type stored in the attribute.
Returns
The attribute reference.

◆ ref_attribute() [2/2]

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.

Parameters
[in]idAttribute id.
Template Parameters
ValueTypeScalar type stored in the attribute.
Returns
The attribute reference.

◆ _ref_attribute_ptr() [1/2]

internal::weak_ptr< AttributeBase > _ref_attribute_ptr ( std::string_view  name)

Gets a weak pointer to the base attribute object.

Parameters
[in]nameAttribute name.
Returns
A weak ptr to the base attribute object.
Note
This method is for tracking the life span of the attribute object.

◆ _ref_attribute_ptr() [2/2]

internal::weak_ptr< AttributeBase > _ref_attribute_ptr ( AttributeId  id)

Gets a weak pointer to the base attribute object.

Parameters
[in]idAttribute id.
Returns
A weak ptr to the base attribute object.
Note
This method is for tracking the life span of the attribute object.

◆ ref_indexed_attribute() [1/2]

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.

Parameters
[in]nameAttribute name.
Template Parameters
ValueTypeScalar type stored in the attribute.
Returns
The attribute reference.

◆ ref_indexed_attribute() [2/2]

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.

Parameters
[in]idAttribute id.
Template Parameters
ValueTypeScalar type stored in the attribute.
Returns
The attribute reference.

◆ get_vertex_to_position()

auto get_vertex_to_position

Gets a read-only reference to the vertex -> positions attribute.

Returns
Reference to the attribute.

◆ ref_vertex_to_position()

auto ref_vertex_to_position

Gets a writable reference to the vertex -> positions attribute.

Returns
Reference to the attribute.

◆ get_corner_to_vertex()

auto get_corner_to_vertex

Gets a read-only reference to the corner -> vertex id attribute.

Returns
Vertex indices attribute.

◆ ref_corner_to_vertex()

auto ref_corner_to_vertex

Gets a writable reference to the corner -> vertex id attribute.

Warning
If the mesh contains edge/connectivity attributes, this function will throw an exception. This is because it is impossible to update edge/connectivity information if the facet buffer is directly modified by the user. Instead, the correct facet indices must be provided when the facet is constructed.
Returns
Vertex indices attribute.

◆ attr_name_is_reserved()

bool attr_name_is_reserved ( std::string_view  name)
static

Check whether the given name corresponds to a reserved attribute.

Reserved attributes are attributes whose name starts with a "$".

Parameters
[in]nameAttribute name.
Returns
True if this is the name of a reserved attribute, false otherwise.

◆ attr_name_vertex_to_position()

static constexpr std::string_view attr_name_vertex_to_position ( )
inlinestaticconstexpr

Attribute name for vertex -> position.

Returns
Attribute name.

◆ attr_name_corner_to_vertex()

static constexpr std::string_view attr_name_corner_to_vertex ( )
inlinestaticconstexpr

Attribute name for corner -> vertex indices.

Returns
Attribute name.

◆ attr_name_facet_to_first_corner()

static constexpr std::string_view attr_name_facet_to_first_corner ( )
inlinestaticconstexpr

Attribute name for facet -> first corner index.

Returns
Attribute name.

◆ attr_name_corner_to_facet()

static constexpr std::string_view attr_name_corner_to_facet ( )
inlinestaticconstexpr

Attribute name for corner -> facet index.

Returns
Attribute name.

◆ attr_name_corner_to_edge()

static constexpr std::string_view attr_name_corner_to_edge ( )
inlinestaticconstexpr

Attribute name for corner -> edge indices.

Returns
Attribute name.

◆ attr_name_edge_to_first_corner()

static constexpr std::string_view attr_name_edge_to_first_corner ( )
inlinestaticconstexpr

Attribute name for edge -> first corner index.

Returns
Attribute name.

◆ attr_name_next_corner_around_edge()

static constexpr std::string_view attr_name_next_corner_around_edge ( )
inlinestaticconstexpr

Attribute name for corner -> next corner around edge.

Returns
Attribute name.

◆ attr_name_vertex_to_first_corner()

static constexpr std::string_view attr_name_vertex_to_first_corner ( )
inlinestaticconstexpr

Attribute name for vertex -> first corner index.

Returns
Attribute name.

◆ attr_name_next_corner_around_vertex()

static constexpr std::string_view attr_name_next_corner_around_vertex ( )
inlinestaticconstexpr

Attribute name for corner -> next corner around vertex.

Returns
Attribute name.

◆ attr_id_vertex_to_position()

AttributeId attr_id_vertex_to_position ( ) const
inline

Attribute id for vertex -> positions.

Returns
Attribute id.

◆ attr_id_vertex_to_positions()

AttributeId attr_id_vertex_to_positions ( ) const
inline

Attribute id for vertex -> positions.

Returns
Attribute id.

◆ attr_id_corner_to_vertex()

AttributeId attr_id_corner_to_vertex ( ) const
inline

Attribute id for corner -> vertex indices.

Returns
Attribute id.

◆ attr_id_facet_to_first_corner()

AttributeId attr_id_facet_to_first_corner ( ) const
inline

Attribute id for facet -> first corner index.

Returns
Attribute id.

◆ attr_id_corner_to_facet()

AttributeId attr_id_corner_to_facet ( ) const
inline

Attribute id for corner -> facet index.

Returns
Attribute id.

◆ attr_id_corner_to_edge()

AttributeId attr_id_corner_to_edge ( ) const
inline

Attribute id for corner -> edge indices.

Returns
Attribute id.

◆ attr_id_edge_to_first_corner()

AttributeId attr_id_edge_to_first_corner ( ) const
inline

Attribute id for edge -> first corner index.

Returns
Attribute id.

◆ attr_id_next_corner_around_edge()

AttributeId attr_id_next_corner_around_edge ( ) const
inline

Attribute id for corner -> next corner around edge.

Returns
Attribute id.

◆ attr_id_vertex_to_first_corner()

AttributeId attr_id_vertex_to_first_corner ( ) const
inline

Attribute id for vertex -> first corner index.

Returns
Attribute id.

◆ attr_id_next_corner_around_vertex()

AttributeId attr_id_next_corner_around_vertex ( ) const
inline

Attribute id for corner -> next corner around vertex.

Returns
Attribute id.

◆ initialize_edges() [1/2]

void initialize_edges ( span< const Index edges = {})

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).

Parameters
[in]edgesM x 2 continuous array of mapping edge -> vertices, where M is the number of edges in the mesh.

◆ initialize_edges() [2/2]

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).

Parameters
[in]num_user_edgesNumber 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_edgeCallback function to retrieve the vertices endpoints of an edge given its user-provided index.

◆ clear_edges()

void clear_edges

Clears attributes related to mesh edges and connectivity:

  • "$corner_to_edge"
  • "$vertex_to_first_corner"
  • "$next_corner_around_vertex"
  • "$edge_to_first_corner"
  • "$next_corner_around_edge"

This method also sets the number of mesh edges to 0, effectively resizing all user-defined edge attributes to 0.

◆ has_edges()

bool has_edges ( ) const
inline

Determines if the attributes associated to mesh edges and connectivity have been initialized.

Returns
True if attributes have been initialized, False otherwise.

◆ get_edge()

auto get_edge ( Index  f,
Index  lv 
) const

Gets the edge index corresponding to (f, lv) – (f, lv+1).

Parameters
[in]fFacet index.
[in]lvLocal vertex index [0, get_vertex_per_facet()[.
Returns
Edge index.

◆ get_corner_edge()

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.

Parameters
[in]cCorner index.
Returns
Edge index.

◆ get_edge_from_corner()

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.

Parameters
[in]cCorner index.
Returns
Edge index.
Deprecated:
Use get_corner_edge instead.

◆ get_edge_vertices()

auto get_edge_vertices ( Index  e) const

Retrieve edge endpoints.

Parameters
[in]eQueried edge index.
Returns
Array of vertex ids at the edge endpoints.

◆ find_edge_from_vertices()

Index find_edge_from_vertices ( Index  v0,
Index  v1 
) const

Retrieve the edge index corresponding to (v0, v1).

Parameters
[in]v0,v1The vertex indices for edge end points.
Returns
The edge index if found, otherwise invalid<Index>().

◆ get_next_corner_around_facet()

Index get_next_corner_around_facet ( Index  c) const

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.

Parameters
[in]cCorner index.
Returns
The next corner around facet.

◆ get_first_corner_around_edge()

auto get_first_corner_around_edge ( Index  e) const

Get the index of the first corner around a given edge.

Parameters
[in]eQueried edge index.
Returns
Index of the first corner around the queried edge.

◆ get_next_corner_around_edge()

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>.

Parameters
[in]cCorner index.
Returns
Next corner around the edge.

◆ get_first_corner_around_vertex()

auto get_first_corner_around_vertex ( Index  v) const

Get the index of the first corner around a given vertex.

Parameters
[in]vQueried vertex index.
Returns
Index of the first corner around the queried vertex.

◆ get_next_corner_around_vertex()

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>.

Note
The sequence of corners around a vertex defined by this function has no geometric meaning. I.e. the current corner and its next corner may not be adjacent to the same edge.
Parameters
[in]cCorner index.
Returns
Next corner around the vertex.

◆ count_num_corners_around_edge()

auto count_num_corners_around_edge ( Index  e) const

Count the number of corners incident to a given edge.

Note
This may not be the same as the number of incident facets. E.g. the same facet may be incident to the same edge multiple times. To count the number of incident facet without duplications, you will need to write your own function.
Parameters
[in]eQueried edge index.
Returns
Number of corners incident to the queried edge.

◆ count_num_corners_around_vertex()

auto count_num_corners_around_vertex ( Index  v) const

Count the number of corners incident to a given vertex.

Note
This may not be the same as the number of incident facets. E.g. the same facet may be incident to the same vertex multiple times. To count the number of incident facet without duplications, you will need to write your own function.
Parameters
[in]vQueried vertex index.
Returns
Number of corners incident to the queried vertex.

◆ get_one_facet_around_edge()

auto get_one_facet_around_edge ( Index  e) const

Get the index of one facet around a given edge.

Parameters
[in]eQueried edge index.
Returns
Face index of one facet incident to the queried edge.

◆ get_one_corner_around_edge()

auto get_one_corner_around_edge ( Index  e) const

Get the index of one corner around a given edge.

Note
While this is technically redundant with get_first_corner_around_edge, the latter can be used when iterating manually over a chain of corners, while this method can be used to retrieve a single corner around a given edge.
Parameters
[in]eQueried edge index.
Returns
Index of the first corner around the queried edge.

◆ get_one_corner_around_vertex()

auto get_one_corner_around_vertex ( Index  v) const

Get the index of one corner around a given vertex.

Note
While this is technically redundant with get_first_corner_around_vertex, the latter can be used when iterating manually over a chain of corners, while this method can be used to retrieve a single corner around a given vertex.
Parameters
[in]vQueried vertex index.
Returns
Index of the first corner around the queried vertex.

◆ is_boundary_edge()

bool is_boundary_edge ( Index  e) const

Determines whether the specified edge e is a boundary edge.

Parameters
[in]eQueried edge index.
Returns
True if the specified edge e is a boundary edge, False otherwise.

◆ foreach_facet_around_edge()

void foreach_facet_around_edge ( Index  e,
function_ref< void(Index)>  func 
) const

Applies a function to each facet around a prescribed edge.

Warning
If a facet is incident to the same edge multiple times (e.g. facet {0, 1, 0, 1}), the callback function will be called multiple times for te facet.
Parameters
[in]eQueried edge index.
[in]funcCallback to apply to each incident facet.

◆ foreach_facet_around_vertex()

void foreach_facet_around_vertex ( Index  v,
function_ref< void(Index)>  func 
) const

Applies a function to each facet around a prescribed vertex.

Warning
If a facet is incident to the same vertex multiple times (e.g. facet {0, 1, 0, 1}), the callback function will be called multiple times for the facet.
Parameters
[in]vQueried vertex index.
[in]funcCallback to apply to each incident facet.

◆ foreach_corner_around_edge()

void foreach_corner_around_edge ( Index  e,
function_ref< void(Index)>  func 
) const

Applies a function to each corner around a prescribed edge.

Parameters
[in]eQueried edge index.
[in]funcCallback to apply to each incident corner.

◆ foreach_corner_around_vertex()

void foreach_corner_around_vertex ( Index  v,
function_ref< void(Index)>  func 
) const

Applies a function to each corner around a prescribed vertex.

Parameters
[in]vQueried vertex index.
[in]funcCallback to apply to each incident corner.

◆ foreach_edge_around_vertex_with_duplicates()

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).

Parameters
[in]vQueried vertex index.
[in]funcCallback to apply to each incident edge.

◆ create_attribute_internal()

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 = {} 
)
protected

Same as create_attribute, but allows creation of reserved attributes.

Parameters
[in]nameAttribute name to create.
[in]elementMesh element to which the attribute is attached to (Vertex, Facet, etc.).
[in]usageTag to indicate how the values are modified under rigid transformation.
[in]num_channelsThe number of channels for the attribute. Cannot be modified once the attribute has been created.
[in]initial_valuesA 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_indicesA 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).
Template Parameters
ValueTypeValue type for the attribute.
Returns
The attribute identifier.

◆ set_attribute_default_internal()

void set_attribute_default_internal ( std::string_view  name)
protected

Set attribute default value for known internal attributes.

Parameters
[in]nameName of the attribute being set.
Template Parameters
ValueTypeValue type for the attribute.

◆ reindex_vertices_internal()

void reindex_vertices_internal ( span< const Index old_to_new)
protected

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.

Parameters
[in]old_to_newMapping old vertex index -> new vertex index.

◆ reindex_facets_internal()

auto reindex_facets_internal ( span< const Index old_to_new)
protected

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.

Parameters
[in]old_to_newMapping old facet index -> new facet index.
Returns
A pair (nc, ne) containing the new number of corners & edges, respectively.

◆ resize_elements_internal()

void resize_elements_internal ( Index  num_elements)
protected

Resize the buffers associated to a specific element type in the mesh.

Newly inserted elements will be default-initialized.

Parameters
[in]num_elementsNew number of elements.
Template Parameters
elementElement type to resize (vertices, facets, etc.).

◆ resize_vertices_internal()

void resize_vertices_internal ( Index  num_vertices)
protected

Resize the buffers associated to mesh vertices and their attributes.

Newly inserted elements will be default-initialized.

Parameters
[in]num_verticesNew number of vertices.

◆ resize_facets_internal()

void resize_facets_internal ( Index  num_facets)
protected

Resize the buffers associated to mesh facets and their attributes.

Newly inserted elements will be default-initialized.

Parameters
[in]num_facetsNew number of facets.

◆ resize_corners_internal()

void resize_corners_internal ( Index  num_corners)
protected

Resize the buffers associated to mesh corners and their attributes.

Newly inserted elements will be default-initialized.

Parameters
[in]num_cornersNew number of corners.

◆ resize_edges_internal()

void resize_edges_internal ( Index  num_edges)
protected

Resize the buffers associated to mesh edges and their attributes.

Newly inserted elements will be default-initialized.

Parameters
[in]num_edgesNew number of edges.

◆ reserve_indices_internal() [1/3]

auto reserve_indices_internal ( Index  num_facets,
Index  facet_size 
)
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.

Parameters
[in]num_facetsNumber of facets to add.
[in]facet_sizeSize of each facet to add.
Returns
A writable span pointing to the newly inserted rows of the corner_to_vertex attribute.

◆ reserve_indices_internal() [2/3]

auto reserve_indices_internal ( span< const Index facet_sizes)
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.

Parameters
[in]facet_sizesA contiguous array representing the size of each facet to add.
Returns
A writable span pointing to the newly inserted rows of the corner_to_vertex attribute.

◆ reserve_indices_internal() [3/3]

auto reserve_indices_internal ( Index  num_facets,
GetFacetsSizeFunction  get_facets_size 
)
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.

Parameters
[in]num_facetsNumber of facets to add.
[in]get_facets_sizeCallable function to retrieve the size of each facet to be added.
Returns
A writable span pointing to the newly inserted rows of the corner_to_vertex attribute.

◆ compute_corner_to_facet_internal()

void compute_corner_to_facet_internal ( Index  facet_begin,
Index  facet_end 
)
protected

Compute inverse mapping corner -> facet index for a specific range of facets.

Parameters
[in]facet_beginFirst facet in the range.
[in]facet_endIndex beyond the last facet in the range.

◆ initialize_edges_internal()

void initialize_edges_internal ( Index  num_user_edges = 0,
GetEdgeVertices get_user_edge_ptr = nullptr 
)
protected

Initializes attributes associated to mesh edges and connectivity.

Internal method to avoid code duplication.

Parameters
[in]num_user_edgesNumber of edges in the user-provided ordering.
[in]get_user_edge_ptrCallback function to retrieve the vertices endpoints of an edge given its user-provided index.

◆ update_edges_range_internal()

void update_edges_range_internal ( Index  facet_begin,
Index  facet_end,
Index  num_user_edges = 0,
GetEdgeVertices get_user_edge_ptr = nullptr 
)
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).

See also
initialize_edges
Parameters
[in]facet_beginFirst facet in the range.
[in]facet_endIndex beyond the last facet in the range.
[in]num_user_edgesNumber of edges in the user-provided ordering.
[in]get_user_edge_ptrCallback function to retrieve the vertices endpoints of an edge given its user-provided index.

◆ update_edges_last_internal()

void update_edges_last_internal ( Index  count,
Index  num_user_edges = 0,
GetEdgeVertices get_user_edge_ptr = nullptr 
)
protected

Same as update_edges_range_internal, but operate on the last count facets in the mesh instead.

Parameters
[in]countNumber of facets to update.
[in]num_user_edgesNumber of edges in the user-provided ordering.
[in]get_user_edge_ptrCallback function to retrieve the vertices endpoints of an edge given its user-provided index.

◆ get_num_elements_internal()

size_t get_num_elements_internal ( AttributeElement  element) const
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.

Parameters
[in]elementType of element (vertex, facet, etc.).
Returns
The number of such elements in the mesh.

◆ wrap_as_attribute_internal() [1/3]

void wrap_as_attribute_internal ( Attribute< std::decay_t< ValueType > > &  attr,
size_t  num_values,
span< ValueType >  values_view 
)
protected

Wrap a span in an attribute.

Template Parameters
ValueTypeThe attribute value type.
Parameters
[in]attrThe attribute object.
[in]num_valuesThe number of elements to wrap.
[in]values_viewA view of the raw buffer. Its size must sufficiently large to hold at least num_values elements.

◆ wrap_as_attribute_internal() [2/3]

void wrap_as_attribute_internal ( Attribute< std::decay_t< ValueType > > &  attr,
size_t  num_values,
SharedSpan< ValueType >  shared_values 
)
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.

Template Parameters
ValueTypeThe attribute value type.
Parameters
[in]attrThe attribute object.
[in]num_valuesThe number of elements to wrap.
[in]shared_valuesA shared span object with memory ownership tracking support. Its size must sufficiently large to hold at least num_values elements.

◆ wrap_as_facets_internal()

AttributeId wrap_as_facets_internal ( OffsetSpan  offsets,
Index  num_facets,
FacetSpan  facets,
Index  num_corners 
)
protected

Wrap shared spans as offsets and facets.

Template Parameters
OffsetSpanThe offset span type. Should be either span<T> or SharedSpan<T>.
FacetSpanThe facet span type. Should be either span<T> or SharedSpan<T>.
Parameters
offsetsThe offset span. Its size should be >= num_facets.
num_facetsThe number of facets.
facetsThe facet span. Its size should be >= num_corners.
num_cornersThe number of corners.
Returns
The corner-to-vertex attribute id.

◆ wrap_as_attribute_internal() [3/3]

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 = {} 
)
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.

Template Parameters
ValueSpanThe value span type. Should be either span<T> or SharedSpan<T>.
IndexSpanThe index span type. Should be either span<T> or SharedSpan<T>.
Parameters
nameThe attribute name.
elementThe attribute element type.
usageThe attribute usage type.
num_valuesThe number of values.
num_channelsThe number of channels.
valuesThe value span. Its size should be >= num_values * num_channels.
indicesThe index span. Its size should be >= the number of corresponding elements. It is only used for creating indexed attribute.
Returns
The attribute id of the generated attribute.

Member Data Documentation

◆ items

std::string_view items[9]
Initial value:
= {
"$vertex_to_position",
"$corner_to_vertex",
"$facet_to_first_corner",
"$corner_to_facet",
"$corner_to_edge",
"$edge_to_first_corner",
"$next_corner_around_edge",
"$vertex_to_first_corner",
"$next_corner_around_vertex",
}

The documentation for this class was generated from the following files: