14#include <lagrange/AttributeFwd.h>
15#include <lagrange/utils/SharedSpan.h>
16#include <lagrange/utils/function_ref.h>
17#include <lagrange/utils/span.h>
18#include <lagrange/utils/value_ptr.h>
20#include <initializer_list>
64template <
typename Scalar_,
typename Index_>
79 std::is_same_v<Scalar, float> || std::is_same_v<Scalar, double>,
80 "SurfaceMesh's Scalar template parameter can only be float or double.");
82 std::is_same_v<Index, uint32_t> || std::is_same_v<Index, uint64_t>,
83 "SurfaceMesh's Index template parameter can only be uint32_t or uint64_t.");
207 template <
typename OtherScalar,
typename OtherIndex>
228 template <
typename OtherScalar,
typename OtherIndex>
243 void add_vertex(std::initializer_list<const Scalar> p);
261 void add_vertices(Index num_vertices, std::initializer_list<const Scalar> coordinates);
308 void add_triangles(Index num_facets, std::initializer_list<const Index> facet_indices);
326 void add_quad(Index v0, Index v1, Index v2, Index v3);
341 void add_quads(Index num_facets, span<const Index> facet_indices = {});
356 void add_quads(Index num_facets, std::initializer_list<const Index> facet_indices);
385 void add_polygon(std::initializer_list<const Index> facet_indices);
410 void add_polygons(Index num_facets, Index facet_size, span<const Index> facet_indices = {});
430 std::initializer_list<const Index> facet_indices);
458 void add_hybrid(span<const Index> facet_sizes, span<const Index> facet_indices = {});
475 std::initializer_list<const Index> facet_sizes,
476 std::initializer_list<const Index> facet_indices);
509 void remove_vertices(std::initializer_list<const Index> vertices_to_remove);
541 void remove_facets(std::initializer_list<const Index> facets_to_remove);
837 template <
typename ValueType>
839 std::string_view name,
841 size_t num_channels = 1,
844 span<const Index> initial_indices = {},
882 template <
typename ValueType>
884 std::string_view name,
887 size_t num_channels = 1,
888 span<const ValueType> initial_values = {},
889 span<const Index> initial_indices = {},
910 template <
typename OtherScalar,
typename OtherIndex>
912 std::string_view name,
913 const SurfaceMesh<OtherScalar, OtherIndex>& source_mesh,
914 std::string_view source_name = {});
939 template <
typename ValueType>
941 std::string_view name,
945 span<ValueType> values_view);
954 template <
typename ValueType>
956 std::string_view name,
960 SharedSpan<ValueType> shared_values);
985 template <
typename ValueType>
987 std::string_view name,
991 span<const ValueType> values_view);
1000 template <
typename ValueType>
1002 std::string_view name,
1005 size_t num_channels,
1006 SharedSpan<const ValueType> shared_values);
1034 template <
typename ValueType>
1036 std::string_view name,
1039 size_t num_channels,
1040 span<ValueType> values_view,
1041 span<Index> indices_view);
1051 template <
typename ValueType>
1053 std::string_view name,
1056 size_t num_channels,
1057 SharedSpan<ValueType> shared_values,
1058 SharedSpan<Index> shared_indices);
1067 template <
typename ValueType>
1069 std::string_view name,
1072 size_t num_channels,
1073 span<ValueType> values_view,
1074 SharedSpan<Index> shared_indices);
1083 template <
typename ValueType>
1085 std::string_view name,
1088 size_t num_channels,
1089 SharedSpan<ValueType> shared_values,
1090 span<Index> indices_view);
1119 template <
typename ValueType>
1121 std::string_view name,
1124 size_t num_channels,
1125 span<const ValueType> values_view,
1126 span<const Index> indices_view);
1136 template <
typename ValueType>
1138 std::string_view name,
1141 size_t num_channels,
1142 SharedSpan<const ValueType> shared_values,
1143 SharedSpan<const Index> shared_indices);
1152 template <
typename ValueType>
1154 std::string_view name,
1157 size_t num_channels,
1158 span<const ValueType> values_view,
1159 SharedSpan<const Index> shared_indices);
1168 template <
typename ValueType>
1170 std::string_view name,
1173 size_t num_channels,
1174 SharedSpan<const ValueType> shared_values,
1175 span<const Index> indices_view);
1227 SharedSpan<const Scalar> shared_vertices,
1228 Index num_vertices);
1254 wrap_as_facets(SharedSpan<Index> shared_facets, Index num_facets, Index vertex_per_facet);
1282 SharedSpan<const Index> shared_facets,
1284 Index vertex_per_facet);
1305 span<Index> offsets_view,
1307 span<Index> facets_view,
1319 SharedSpan<Index> shared_offsets,
1321 SharedSpan<Index> shared_facets,
1332 span<Index> offsets_view,
1334 SharedSpan<Index> shared_facets,
1345 SharedSpan<Index> shared_offsets,
1347 span<Index> facets_view,
1370 span<const Index> offsets_view,
1372 span<const Index> facets_view,
1384 SharedSpan<const Index> shared_offsets,
1386 SharedSpan<const Index> shared_facets,
1397 span<const Index> offsets_view,
1399 SharedSpan<const Index> shared_facets,
1410 SharedSpan<const Index> shared_offsets,
1412 span<const Index> facets_view,
1432 void rename_attribute(std::string_view old_name, std::string_view new_name);
1445 std::string_view name,
1465 template <
typename ValueType>
1467 std::string_view name,
1488 template <
typename ValueType>
1490 std::string_view name,
1510 template <
typename ValueType>
1512 std::string_view name,
1514 -> std::shared_ptr<IndexedAttribute<ValueType, Index>>;
1532 template <
typename ValueType>
1534 std::string_view name,
1536 -> std::shared_ptr<const IndexedAttribute<ValueType, Index>>;
1574 void set_metadata(std::string_view name, std::string_view value);
1592 std::string_view
get_metadata(std::string_view name)
const;
1609 [[nodiscard]]
bool has_attribute(std::string_view name)
const;
1620 template <
typename ValueType>
1632 template <
typename ValueType>
1722 template <
typename ValueType>
1723 [[nodiscard]]
const Attribute<ValueType>&
get_attribute(std::string_view name)
const;
1734 template <
typename ValueType>
1747 std::string_view name)
const;
1770 template <
typename ValueType>
1772 ->
const IndexedAttribute<ValueType, Index>&;
1783 template <
typename ValueType>
1785 ->
const IndexedAttribute<ValueType, Index>&;
1797 template <
typename ValueType>
1798 [[nodiscard]] Attribute<ValueType>&
ref_attribute(std::string_view name);
1810 template <
typename ValueType>
1823 std::string_view name);
1846 template <
typename ValueType>
1848 -> IndexedAttribute<ValueType, Index>&;
1860 template <
typename ValueType>
2013 [[deprecated(
"Use attr_id_vertex_to_position() instead.")]]
AttributeId
2016 return m_reserved_ids.vertex_to_position();
2033 return m_reserved_ids.facet_to_first_corner();
2057 return m_reserved_ids.edge_to_first_corner();
2067 return m_reserved_ids.next_corner_around_edge();
2077 return m_reserved_ids.vertex_to_first_corner();
2087 return m_reserved_ids.next_corner_around_vertex();
2150 Index
get_edge(Index f, Index lv)
const;
2399 template <
typename ValueType>
2401 std::string_view name,
2404 size_t num_channels = 1,
2415 template <
typename ValueType>
2448 template <AttributeElement element>
2536 Index num_user_edges = 0,
2562 Index num_user_edges = 0,
2576 Index num_user_edges = 0,
2599 template <
typename ValueType>
2601 Attribute<std::decay_t<ValueType>>& attr,
2603 span<ValueType> values_view);
2618 template <
typename ValueType>
2620 Attribute<std::decay_t<ValueType>>& attr,
2622 SharedSpan<ValueType> shared_values);
2637 template <
typename OffsetSpan,
typename FacetSpan>
2666 template <
typename ValueSpan,
typename IndexSpan = span<Index>>
2668 std::string_view name,
2672 size_t num_channels,
2674 IndexSpan indices = {});
2680 template <
typename,
typename>
2686 struct AttributeManager;
2718 static constexpr int size() {
return 9; }
2720 AttributeId& vertex_to_position() {
return items[0]; };
2721 AttributeId& corner_to_vertex() {
return items[1]; };
2722 AttributeId& facet_to_first_corner() {
return items[2]; };
2723 AttributeId& corner_to_facet() {
return items[3]; };
2724 AttributeId& corner_to_edge() {
return items[4]; };
2725 AttributeId& edge_to_first_corner() {
return items[5]; };
2726 AttributeId& next_corner_around_edge() {
return items[6]; };
2727 AttributeId& vertex_to_first_corner() {
return items[7]; };
2728 AttributeId& next_corner_around_vertex() {
return items[8]; };
2730 const AttributeId& vertex_to_position()
const {
return items[0]; };
2731 const AttributeId& corner_to_vertex()
const {
return items[1]; };
2732 const AttributeId& facet_to_first_corner()
const {
return items[2]; };
2733 const AttributeId& corner_to_facet()
const {
return items[3]; };
2734 const AttributeId& corner_to_edge()
const {
return items[4]; };
2735 const AttributeId& edge_to_first_corner()
const {
return items[5]; };
2736 const AttributeId& next_corner_around_edge()
const {
return items[6]; };
2737 const AttributeId& vertex_to_first_corner()
const {
return items[7]; };
2738 const AttributeId& next_corner_around_vertex()
const {
return items[8]; };
2743 static constexpr struct
2745 std::string_view items[9] = {
2746 "$vertex_to_position",
2747 "$corner_to_vertex",
2748 "$facet_to_first_corner",
2751 "$edge_to_first_corner",
2752 "$next_corner_around_edge",
2753 "$vertex_to_first_corner",
2754 "$next_corner_around_vertex",
2756 std::string_view vertex_to_position()
const {
return items[0]; }
2757 std::string_view corner_to_vertex()
const {
return items[1]; }
2758 std::string_view facet_to_first_corner()
const {
return items[2]; }
2759 std::string_view corner_to_facet()
const {
return items[3]; }
2760 std::string_view corner_to_edge()
const {
return items[4]; }
2761 std::string_view edge_to_first_corner()
const {
return items[5]; }
2762 std::string_view next_corner_around_edge()
const {
return items[6]; }
2763 std::string_view vertex_to_first_corner()
const {
return items[7]; }
2764 std::string_view next_corner_around_vertex()
const {
return items[8]; }
2768using SurfaceMesh32f = SurfaceMesh<float, uint32_t>;
2769using SurfaceMesh32d = SurfaceMesh<double, uint32_t>;
2770using SurfaceMesh64f = SurfaceMesh<float, uint64_t>;
2771using SurfaceMesh64d = SurfaceMesh<double, uint64_t>;
A general purpose polygonal mesh class.
Definition: SurfaceMesh.h:66
function_ref< std::array< Index, 2 >(Index e)> GetEdgeVertices
Callback function to get the vertex indices of an edge endpoints in a user-provided ordering of a mes...
Definition: SurfaceMesh.h:138
void add_hybrid(span< const Index > facet_sizes, span< const Index > facet_indices={})
Adds multiple polygonal facets of different sizes to the mesh.
Definition: SurfaceMesh.cpp:1748
Index find_edge_from_vertices(Index v0, Index v1) const
Retrieve the edge index corresponding to (v0, v1).
Definition: SurfaceMesh.cpp:2443
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.
Definition: SurfaceMesh.cpp:2612
span< Index > reserve_indices_internal(Index num_facets, Index facet_size)
Reserve index buffer for multiple facets of a given size.
Definition: SurfaceMesh.cpp:2935
AttributeId attr_id_vertex_to_position() const
Attribute id for vertex -> positions.
Definition: SurfaceMesh.h:2006
void add_quads(Index num_facets, span< const Index > facet_indices={})
Adds multiple quadrilateral facets to the mesh.
Definition: SurfaceMesh.cpp:1679
Index get_next_corner_around_facet(Index c) const
Gets the next corner around the facet associated to a corner.
Definition: SurfaceMesh.cpp:2433
static constexpr std::string_view attr_name_facet_to_first_corner()
Attribute name for facet -> first corner index.
Definition: SurfaceMesh.h:1936
void foreach_facet_around_edge(Index e, function_ref< void(Index)> func) const
Applies a function to each facet around a prescribed edge.
Definition: SurfaceMesh.cpp:2563
void par_foreach_attribute_id(function_ref< void(AttributeId)> func) const
Iterates over all attribute ids in parallel.
Definition: SurfaceMesh.cpp:1250
bool is_quad_mesh() const
Whether the mesh must only contains quadrilateral facets.
Definition: SurfaceMesh.cpp:2060
std::string_view get_attribute_name(AttributeId id) const
Retrieve attribute name from its id.
Definition: SurfaceMesh.cpp:351
bool is_boundary_edge(Index e) const
Determines whether the specified edge e is a boundary edge.
Definition: SurfaceMesh.cpp:2532
Index get_facet_corner_end(Index f) const
Index past the last corner around the facet.
Definition: SurfaceMesh.cpp:2113
Attribute< Scalar > & ref_vertex_to_position()
Gets a writable reference to the vertex -> positions attribute.
Definition: SurfaceMesh.cpp:1381
void clear_edges()
Clears attributes related to mesh edges and connectivity:
Definition: SurfaceMesh.cpp:2386
function_ref< void(Index f, span< Index > t)> SetMultiFacetsIndicesFunction
Callback function to set indices of a multiple facets.
Definition: SurfaceMesh.h:118
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.
Definition: SurfaceMesh.cpp:2247
static constexpr std::string_view attr_name_next_corner_around_vertex()
Attribute name for corner -> next corner around vertex.
Definition: SurfaceMesh.h:1996
static constexpr std::string_view attr_name_vertex_to_position()
Attribute name for vertex -> position.
Definition: SurfaceMesh.h:1916
function_ref< Index(Index f)> GetFacetsSizeFunction
Callback function to get a facet size (number of vertices in the facet).
Definition: SurfaceMesh.h:128
static constexpr std::string_view attr_name_corner_to_vertex()
Attribute name for corner -> vertex indices.
Definition: SurfaceMesh.h:1926
AttributeId attr_id_corner_to_edge() const
Attribute id for corner -> edge indices.
Definition: SurfaceMesh.h:2048
static SurfaceMesh stripped_copy(const SurfaceMesh< OtherScalar, OtherIndex > &other)
Copy constructor stripping away non-reserved attributes.
void set_attribute_default_internal(std::string_view name)
Set attribute default value for known internal attributes.
Definition: SurfaceMesh.cpp:372
const Attribute< ValueType > & get_attribute(std::string_view name) const
Gets a read-only reference to an attribute given its name.
Definition: SurfaceMesh.cpp:1278
Index m_num_facets
Number of facets.
Definition: SurfaceMesh.h:2695
void delete_attribute(std::string_view name, AttributeDeletePolicy policy=AttributeDeletePolicy::ErrorIfReserved)
Delete an attribute given by name.
Definition: SurfaceMesh.cpp:1036
Index count_num_corners_around_edge(Index e) const
Count the number of corners incident to a given edge.
Definition: SurfaceMesh.cpp:2503
Index get_num_vertices() const
Retrieves the number of vertices.
Definition: SurfaceMesh.h:649
void resize_facets_internal(Index num_facets)
Resize the buffers associated to mesh facets and their attributes.
Definition: SurfaceMesh.cpp:2914
Attribute< ValueType > & ref_attribute(std::string_view name)
Gets a writable reference to an attribute given its name.
Definition: SurfaceMesh.cpp:1328
Index get_corner_edge(Index c) const
Gets the edge index corresponding to a corner index.
Definition: SurfaceMesh.cpp:2405
AttributeId attr_id_facet_to_first_corner() const
Attribute id for facet -> first corner index.
Definition: SurfaceMesh.h:2031
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.
Definition: SurfaceMesh.cpp:1101
std::array< Index, 2 > get_edge_vertices(Index e) const
Retrieve edge endpoints.
Definition: SurfaceMesh.cpp:2419
Index get_dimension() const
Retrieves the dimension of the mesh vertices.
Definition: SurfaceMesh.h:634
Index get_edge(Index f, Index lv) const
Gets the edge index corresponding to (f, lv) – (f, lv+1).
Definition: SurfaceMesh.cpp:2397
Index m_vertex_per_facet
Number of vertices per facet. Either constant (> 0) or variable (= 0).
Definition: SurfaceMesh.h:2707
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.
Definition: SurfaceMesh.cpp:401
static constexpr std::string_view attr_name_corner_to_facet()
Attribute name for corner -> facet index.
Definition: SurfaceMesh.h:1946
AttributeId attr_id_corner_to_vertex() const
Attribute id for corner -> vertex indices.
Definition: SurfaceMesh.h:2024
bool is_attribute_type(std::string_view name) const
Checks whether the specified attribute is of a given type.
Definition: SurfaceMesh.cpp:1209
Index m_num_vertices
Number of vertices.
Definition: SurfaceMesh.h:2692
AttributeId get_attribute_id(std::string_view name) const
Retrieve an attribute id given its name.
Definition: SurfaceMesh.cpp:341
void add_vertices(Index num_vertices, span< const Scalar > coordinates={})
Adds multiple vertices to the mesh.
Definition: SurfaceMesh.cpp:1566
std::make_signed_t< Index > SignedIndex
Signed index type corresponding to the mesh index type.
Definition: SurfaceMesh.h:75
Index get_next_corner_around_edge(Index c) const
Gets the next corner around the edge associated to a corner.
Definition: SurfaceMesh.cpp:2476
Index get_edge_from_corner(Index c) const
Gets the edge index corresponding to a corner index.
Definition: SurfaceMesh.cpp:2413
span< Index > ref_facet_vertices(Index f)
Retrieves a writable pointer to a facet indices.
Definition: SurfaceMesh.cpp:2150
void foreach_facet_around_vertex(Index v, function_ref< void(Index)> func) const
Applies a function to each facet around a prescribed vertex.
Definition: SurfaceMesh.cpp:2540
void remove_vertices(span< const Index > vertices_to_remove)
Removes a list of vertices.
Definition: SurfaceMesh.cpp:1795
void remove_facets(span< const Index > facets_to_remove)
Removes a list of facets.
Definition: SurfaceMesh.cpp:1886
void resize_vertices_internal(Index num_vertices)
Resize the buffers associated to mesh vertices and their attributes.
Definition: SurfaceMesh.cpp:2907
bool has_attribute(std::string_view name) const
Checks if an attribute of a given name is attached to the mesh.
Definition: SurfaceMesh.cpp:1202
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.
Definition: SurfaceMesh.cpp:719
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.
Definition: SurfaceMesh.cpp:1117
std::string_view get_metadata(AttributeId id) const
Read metadata attribute value.
Definition: SurfaceMesh.cpp:1188
AttributeId create_metadata(std::string_view name, std::string_view value)
Create a metadata attribute.
Definition: SurfaceMesh.cpp:1161
Index count_num_corners_around_vertex(Index v) const
Count the number of corners incident to a given vertex.
Definition: SurfaceMesh.cpp:2494
value_ptr< AttributeManager > m_attributes
Attribute manager. Hidden implementation.
Definition: SurfaceMesh.h:2710
void add_quad(Index v0, Index v1, Index v2, Index v3)
Adds a quadrilateral facet to the mesh.
Definition: SurfaceMesh.cpp:1610
void add_polygon(Index facet_size)
Adds a single (uninitialized) polygonal facet to the mesh.
Definition: SurfaceMesh.cpp:1619
AttributeId wrap_as_facets_internal(OffsetSpan offsets, Index num_facets, FacetSpan facets, Index num_corners)
Wrap shared spans as offsets and facets.
Definition: SurfaceMesh.cpp:3088
void shrink_to_fit()
Shrink buffer capacities to fit current mesh attributes, deallocating any extra capacity.
Definition: SurfaceMesh.cpp:2007
AttributeId attr_id_vertex_to_positions() const
Attribute id for vertex -> positions.
Definition: SurfaceMesh.h:2014
void clear_facets()
Clear buffer for mesh facets and other facet/corner attributes.
Definition: SurfaceMesh.cpp:1994
Index get_one_corner_around_vertex(Index v) const
Get the index of one corner around a given vertex.
Definition: SurfaceMesh.cpp:2526
SurfaceMesh & operator=(const SurfaceMesh &other)
Assignment copy operator.
Index get_facet_corner_begin(Index f) const
First corner around the facet.
Definition: SurfaceMesh.cpp:2101
void add_vertex(span< const Scalar > p)
Adds a vertex to the mesh.
Definition: SurfaceMesh.cpp:1546
SurfaceMesh(Index dimension=3)
Default constructor.
Definition: SurfaceMesh.cpp:1418
size_t get_num_elements_internal(AttributeElement element) const
Gets the number of mesh elements, based on an element type.
Definition: SurfaceMesh.cpp:357
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.
Definition: SurfaceMesh.cpp:527
AttributeId attr_id_vertex_to_first_corner() const
Attribute id for vertex -> first corner index.
Definition: SurfaceMesh.h:2075
Scalar_ Scalar
Mesh scalar type, used for vertex coordinates.
Definition: SurfaceMesh.h:69
::lagrange::internal::weak_ptr< AttributeBase > _ref_attribute_ptr(std::string_view name)
Gets a weak pointer to the base attribute object.
Definition: SurfaceMesh.cpp:1343
const AttributeBase & get_attribute_base(std::string_view name) const
Gets a read-only reference to the base class of attribute given its name.
Definition: SurfaceMesh.cpp:1264
void resize_corners_internal(Index num_corners)
Resize the buffers associated to mesh corners and their attributes.
Definition: SurfaceMesh.cpp:2921
void add_triangle(Index v0, Index v1, Index v2)
Adds a triangular facet to the mesh.
Definition: SurfaceMesh.cpp:1601
Index_ Index
Mesh index type, used for facet indices.
Definition: SurfaceMesh.h:72
Index get_one_facet_around_edge(Index e) const
Get the index of one facet around a given edge.
Definition: SurfaceMesh.cpp:2512
Index get_first_corner_around_edge(Index e) const
Get the index of the first corner around a given edge.
Definition: SurfaceMesh.cpp:2470
void compute_corner_to_facet_internal(Index facet_begin, Index facet_end)
Compute inverse mapping corner -> facet index for a specific range of facets.
Definition: SurfaceMesh.cpp:3045
void add_triangles(Index num_facets, span< const Index > facet_indices={})
Adds multiple triangular facets to the mesh.
Definition: SurfaceMesh.cpp:1657
void initialize_edges_internal(Index num_user_edges=0, GetEdgeVertices *get_user_edge_ptr=nullptr)
Initializes attributes associated to mesh edges and connectivity.
Definition: SurfaceMesh.cpp:2191
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.
Definition: SurfaceMesh.cpp:1310
~SurfaceMesh()
Default destructor.
void resize_elements_internal(Index num_elements)
Resize the buffers associated to a specific element type in the mesh.
Definition: SurfaceMesh.cpp:2892
void set_metadata(AttributeId id, std::string_view value)
Write metadata attribute value.
Definition: SurfaceMesh.cpp:1172
bool is_regular() const
Whether the mesh must only contains facets of equal sizes.
Definition: SurfaceMesh.cpp:2066
AttributeId attr_id_next_corner_around_edge() const
Attribute id for corner -> next corner around edge.
Definition: SurfaceMesh.h:2065
Index get_first_corner_around_vertex(Index v) const
Get the index of the first corner around a given vertex.
Definition: SurfaceMesh.cpp:2482
Index m_num_corners
Number of corners.
Definition: SurfaceMesh.h:2698
bool is_attribute_indexed(std::string_view name) const
Determines whether the specified attribute is indexed.
Definition: SurfaceMesh.cpp:1223
const Attribute< Index > & get_corner_to_vertex() const
Gets a read-only reference to the corner -> vertex id attribute.
Definition: SurfaceMesh.cpp:1387
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.
Definition: SurfaceMesh.cpp:2236
SurfaceMesh & operator=(SurfaceMesh &&other) noexcept
Assignment move operator.
AttributeId wrap_as_const_vertices(span< const Scalar > vertices_view, Index num_vertices)
Wraps a read-only external buffer as mesh vertices coordinates.
Definition: SurfaceMesh.cpp:826
Index get_next_corner_around_vertex(Index c) const
Gets the next corner around the vertex associated to a corner.
Definition: SurfaceMesh.cpp:2488
Index get_facet_vertex(Index f, Index lv) const
Index of a vertex given from a facet + local index.
Definition: SurfaceMesh.h:710
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.
Definition: SurfaceMesh.cpp:892
void compress_if_regular()
Compress mesh storage if the mesh is regular.
Definition: SurfaceMesh.cpp:2021
bool is_triangle_mesh() const
Whether the mesh must only contain triangular facets.
Definition: SurfaceMesh.cpp:2054
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.
Definition: SurfaceMesh.cpp:3074
Index get_corner_vertex(Index c) const
Retrieves the index of a vertex given its corner index.
Definition: SurfaceMesh.cpp:2127
void foreach_corner_around_vertex(Index v, function_ref< void(Index)> func) const
Applies a function to each corner around a prescribed vertex.
Definition: SurfaceMesh.cpp:2585
void resize_edges_internal(Index num_edges)
Resize the buffers associated to mesh edges and their attributes.
Definition: SurfaceMesh.cpp:2928
Index get_corner_facet(Index c) const
Retrieves the index of a facet given its corner index.
Definition: SurfaceMesh.cpp:2133
bool has_edges() const
Determines if the attributes associated to mesh edges and connectivity have been initialized.
Definition: SurfaceMesh.h:2137
SurfaceMesh(SurfaceMesh &&other) noexcept
Move constructor.
std::pair< Index, Index > reindex_facets_internal(span< const Index > old_to_new)
Reindex mesh facets according to the given mapping.
Definition: SurfaceMesh.cpp:2716
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.
Definition: SurfaceMesh.cpp:1132
span< const Index > get_facet_vertices(Index f) const
Retrieves a read-only pointer to a facet indices.
Definition: SurfaceMesh.cpp:2144
static constexpr std::string_view attr_name_edge_to_first_corner()
Attribute name for edge -> first corner index.
Definition: SurfaceMesh.h:1966
auto ref_indexed_attribute(std::string_view name) -> IndexedAttribute< ValueType, Index > &
Gets a writable reference to an indexed attribute given its name.
Definition: SurfaceMesh.cpp:1358
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.
Definition: SurfaceMesh.cpp:591
bool is_hybrid() const
Whether the mesh may contain facets of different sizes.
Definition: SurfaceMesh.h:627
Index get_num_edges() const
Retrieves the number of edges.
Definition: SurfaceMesh.h:670
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.
Definition: SurfaceMesh.cpp:447
AttributeId wrap_as_vertices(span< Scalar > vertices_view, Index num_vertices)
Wraps a writable external buffer as mesh vertices coordinates.
Definition: SurfaceMesh.cpp:802
Index get_one_corner_around_edge(Index e) const
Get the index of one corner around a given edge.
Definition: SurfaceMesh.cpp:2520
Index get_num_facets() const
Retrieves the number of facets.
Definition: SurfaceMesh.h:656
Index get_vertex_per_facet() const
Retrieves the number of vertex per facet in a regular mesh.
Definition: SurfaceMesh.cpp:2080
SurfaceMesh(const SurfaceMesh &other)
Copy constructor.
span< Scalar > ref_position(Index v)
Retrieves a writeable pointer to a vertex coordinates.
Definition: SurfaceMesh.cpp:2095
AttributeId attr_id_edge_to_first_corner() const
Attribute id for edge -> first corner index.
Definition: SurfaceMesh.h:2055
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.
Definition: SurfaceMesh.cpp:635
AttributeId duplicate_attribute(std::string_view old_name, std::string_view new_name)
Duplicates an attribute.
Definition: SurfaceMesh.cpp:1014
static constexpr std::string_view attr_name_vertex_to_first_corner()
Attribute name for vertex -> first corner index.
Definition: SurfaceMesh.h:1986
static constexpr struct lagrange::SurfaceMesh::@0 s_reserved_names
Reserved attribute names.
AttributeId attr_id_next_corner_around_vertex() const
Attribute id for corner -> next corner around vertex.
Definition: SurfaceMesh.h:2085
Index m_dimension
Vertex dimension.
Definition: SurfaceMesh.h:2704
void initialize_edges(span< const Index > edges={})
Initializes attributes associated to mesh edges and connectivity.
Definition: SurfaceMesh.cpp:2160
function_ref< void(Index v, span< Scalar > p)> SetVertexCoordinatesFunction
Callback function to set vertex coordinates.
Definition: SurfaceMesh.h:96
static constexpr std::string_view attr_name_corner_to_edge()
Attribute name for corner -> edge indices.
Definition: SurfaceMesh.h:1956
Attribute< Index > & ref_corner_to_vertex()
Gets a writable reference to the corner -> vertex id attribute.
Definition: SurfaceMesh.cpp:1393
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.
Definition: SurfaceMesh.cpp:547
AttributeId attr_id_corner_to_facet() const
Attribute id for corner -> facet index.
Definition: SurfaceMesh.h:2041
static SurfaceMesh stripped_move(SurfaceMesh< OtherScalar, OtherIndex > &&other)
Move constructor stripping away non-reserved attributes.
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.
Definition: SurfaceMesh.cpp:850
void reindex_vertices_internal(span< const Index > old_to_new)
Reindex mesh vertices according to the given mapping.
Definition: SurfaceMesh.cpp:2691
void foreach_corner_around_edge(Index e, function_ref< void(Index)> func) const
Applies a function to each corner around a prescribed edge.
Definition: SurfaceMesh.cpp:2599
void rename_attribute(std::string_view old_name, std::string_view new_name)
Rename an existing attribute.
Definition: SurfaceMesh.cpp:1025
const Attribute< Scalar > & get_vertex_to_position() const
Gets a read-only reference to the vertex -> positions attribute.
Definition: SurfaceMesh.cpp:1375
Index get_facet_size(Index f) const
Number of vertices in the facet.
Definition: SurfaceMesh.h:697
Index m_num_edges
Number of edges.
Definition: SurfaceMesh.h:2701
void clear_vertices()
Clear buffer for mesh vertices and other vertex attributes.
Definition: SurfaceMesh.cpp:1984
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.
Definition: SurfaceMesh.cpp:1147
function_ref< void(span< Index > t)> SetSingleFacetIndicesFunction
Callback function to set indices of a single facet.
Definition: SurfaceMesh.h:106
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.
Definition: SurfaceMesh.cpp:1701
::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.
Definition: SurfaceMesh.cpp:1293
static constexpr std::string_view attr_name_next_corner_around_edge()
Attribute name for corner -> next corner around edge.
Definition: SurfaceMesh.h:1976
static bool attr_name_is_reserved(std::string_view name)
Check whether the given name corresponds to a reserved attribute.
Definition: SurfaceMesh.cpp:1403
Index get_num_corners() const
Retrieves the number of corners.
Definition: SurfaceMesh.h:663
span< const Scalar > get_position(Index v) const
Retrieves a read-only pointer to a vertex coordinates.
Definition: SurfaceMesh.cpp:2089
void seq_foreach_attribute_id(function_ref< void(AttributeId)> func) const
Iterates over all attribute ids sequentially.
Definition: SurfaceMesh.cpp:1236
A lightweight non-owning reference to a callable.
Definition: function_ref.h:47
Definition: weak_ptr.h:26
uint32_t AttributeId
Identified to be used to access an attribute.
Definition: AttributeFwd.h:73
AttributeUsage
Usage tag indicating how the attribute should behave under mesh transformations.
Definition: AttributeFwd.h:54
AttributeCreatePolicy
Policy for attribute creation with reserved attribute names.
Definition: AttributeFwd.h:86
AttributeElement
Type of element to which the attribute is attached.
Definition: AttributeFwd.h:26
constexpr AttributeId invalid_attribute_id()
Invalid attribute id.
Definition: AttributeFwd.h:76
AttributeDeletePolicy
Policy for attribute deletion of reserved attribute names.
Definition: AttributeFwd.h:157
AttributeExportPolicy
Policy for exporting attributes that are views onto external buffers.
Definition: AttributeFwd.h:134
@ Vector
Mesh attribute can have any number of channels (including 1 channel).
@ ErrorIfReserved
Default deletion policy, throw an exception if attribute name is reserved.
@ ErrorIfReserved
Default deletion policy, throw an exception if attribute name is reserved.
@ CopyIfExternal
Copy the buffer during export if the attribute points to an external buffer.
function_ref(R(*)(Args...)) -> function_ref< R(Args...)>
Deduce function_ref type from a function pointer.
::nonstd::span< T, Extent > span
A bounds-safe view for sequences of objects.
Definition: span.h:27
Main namespace for Lagrange.
Definition: AABBIGL.h:30
Overload tag.
Definition: SurfaceMesh.h:2365
Reserved attribute ids.
Definition: SurfaceMesh.h:2714