Lagrange
Loading...
Searching...
No Matches
SurfaceMesh.h
1/*
2 * Copyright 2022 Adobe. All rights reserved.
3 * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License. You may obtain a copy
5 * of the License at http://www.apache.org/licenses/LICENSE-2.0
6 *
7 * Unless required by applicable law or agreed to in writing, software distributed under
8 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9 * OF ANY KIND, either express or implied. See the License for the specific language
10 * governing permissions and limitations under the License.
11 */
12#pragma once
13
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>
19
20#include <initializer_list>
21#include <string_view>
22#include <type_traits>
23
24namespace lagrange {
25
28namespace internal {
29template <typename T>
30class weak_ptr;
31}
33
38
64template <typename Scalar_, typename Index_>
66{
67public:
69 using Scalar = Scalar_;
70
72 using Index = Index_;
73
75 using SignedIndex = std::make_signed_t<Index>;
76
77 // Static assertions to prevent users from instantiating unsupported types.
78 static_assert(
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.");
81 static_assert(
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.");
84
85public:
97
107
119
129
139
140public:
144
150 explicit SurfaceMesh(Index dimension = 3);
151
156
162 SurfaceMesh(SurfaceMesh&& other) noexcept;
163
172
179
188
207 template <typename OtherScalar, typename OtherIndex>
209
228 template <typename OtherScalar, typename OtherIndex>
230
237
243 void add_vertex(std::initializer_list<const Scalar> p);
244
252 void add_vertices(Index num_vertices, span<const Scalar> coordinates = {});
253
261 void add_vertices(Index num_vertices, std::initializer_list<const Scalar> coordinates);
262
269 void add_vertices(Index num_vertices, SetVertexCoordinatesFunction set_vertex_coordinates);
270
278 void add_triangle(Index v0, Index v1, Index v2);
279
293 void add_triangles(Index num_facets, span<const Index> facet_indices = {});
294
308 void add_triangles(Index num_facets, std::initializer_list<const Index> facet_indices);
309
316 void add_triangles(Index num_facets, SetMultiFacetsIndicesFunction set_facets_indices);
317
326 void add_quad(Index v0, Index v1, Index v2, Index v3);
327
341 void add_quads(Index num_facets, span<const Index> facet_indices = {});
342
356 void add_quads(Index num_facets, std::initializer_list<const Index> facet_indices);
357
364 void add_quads(Index num_facets, SetMultiFacetsIndicesFunction set_facets_indices);
365
371 void add_polygon(Index facet_size);
372
378 void add_polygon(span<const Index> facet_indices);
379
385 void add_polygon(std::initializer_list<const Index> facet_indices);
386
393 void add_polygon(Index facet_size, SetSingleFacetIndicesFunction set_facet_indices);
394
410 void add_polygons(Index num_facets, Index facet_size, span<const Index> facet_indices = {});
411
428 Index num_facets,
429 Index facet_size,
430 std::initializer_list<const Index> facet_indices);
431
440 Index num_facets,
441 Index facet_size,
442 SetMultiFacetsIndicesFunction set_facets_indices);
443
458 void add_hybrid(span<const Index> facet_sizes, span<const Index> facet_indices = {});
459
475 std::initializer_list<const Index> facet_sizes,
476 std::initializer_list<const Index> facet_indices);
477
487 Index num_facets,
488 GetFacetsSizeFunction facet_sizes,
489 SetMultiFacetsIndicesFunction set_facets_indices);
490
499 void remove_vertices(span<const Index> vertices_to_remove);
500
509 void remove_vertices(std::initializer_list<const Index> vertices_to_remove);
510
519 void remove_vertices(function_ref<bool(Index)> should_remove_func);
520
530 void remove_facets(span<const Index> facets_to_remove);
531
541 void remove_facets(std::initializer_list<const Index> facets_to_remove);
542
552 void remove_facets(function_ref<bool(Index)> should_remove_func);
553
561 span<const Index> facets_to_flip,
563
571 std::initializer_list<const Index> facets_to_flip,
573
582 function_ref<bool(Index)> should_flip_func,
584
590
596
601
610
611public:
615
625 [[nodiscard]] bool is_triangle_mesh() const;
626
636 [[nodiscard]] bool is_quad_mesh() const;
637
647 [[nodiscard]] bool is_regular() const;
648
658 [[nodiscard]] bool is_hybrid() const { return !is_regular(); }
659
665 [[nodiscard]] Index get_dimension() const { return m_dimension; }
666
673 [[nodiscard]] Index get_vertex_per_facet() const;
674
680 [[nodiscard]] Index get_num_vertices() const { return m_num_vertices; }
681
687 [[nodiscard]] Index get_num_facets() const { return m_num_facets; }
688
694 [[nodiscard]] Index get_num_corners() const { return m_num_corners; }
695
701 [[nodiscard]] Index get_num_edges() const { return m_num_edges; }
702
710 [[nodiscard]] span<const Scalar> get_position(Index v) const;
711
720
728 [[nodiscard]] Index get_facet_size(Index f) const
729 {
731 }
732
741 [[nodiscard]] Index get_facet_vertex(Index f, Index lv) const
742 {
744 }
745
753 [[nodiscard]] Index get_facet_corner_begin(Index f) const;
754
762 [[nodiscard]] Index get_facet_corner_end(Index f) const;
763
773 [[nodiscard]] Index get_corner_vertex(Index c) const;
774
784 [[nodiscard]] Index get_corner_facet(Index c) const;
785
794
808
809public:
813
822 [[nodiscard]] AttributeId get_attribute_id(std::string_view name) const;
823
833 [[nodiscard]] std::string_view get_attribute_name(AttributeId id) const;
834
868 template <typename ValueType>
870 std::string_view name,
871 AttributeElement element,
872 size_t num_channels = 1,
874 span<const ValueType> initial_values = {},
875 span<const Index> initial_indices = {},
877
913 template <typename ValueType>
915 std::string_view name,
916 AttributeElement element,
917 AttributeUsage usage,
918 size_t num_channels = 1,
919 span<const ValueType> initial_values = {},
920 span<const Index> initial_indices = {},
922
941 template <typename OtherScalar, typename OtherIndex>
943 std::string_view name,
944 const SurfaceMesh<OtherScalar, OtherIndex>& source_mesh,
945 std::string_view source_name = {});
946
970 template <typename ValueType>
972 std::string_view name,
973 AttributeElement element,
974 AttributeUsage usage,
975 size_t num_channels,
976 span<ValueType> values_view);
977
985 template <typename ValueType>
987 std::string_view name,
988 AttributeElement element,
989 AttributeUsage usage,
990 size_t num_channels,
991 SharedSpan<ValueType> shared_values);
992
1016 template <typename ValueType>
1018 std::string_view name,
1019 AttributeElement element,
1020 AttributeUsage usage,
1021 size_t num_channels,
1022 span<const ValueType> values_view);
1023
1031 template <typename ValueType>
1033 std::string_view name,
1034 AttributeElement element,
1035 AttributeUsage usage,
1036 size_t num_channels,
1037 SharedSpan<const ValueType> shared_values);
1038
1065 template <typename ValueType>
1067 std::string_view name,
1068 AttributeUsage usage,
1069 size_t num_values,
1070 size_t num_channels,
1071 span<ValueType> values_view,
1072 span<Index> indices_view);
1073
1082 template <typename ValueType>
1084 std::string_view name,
1085 AttributeUsage usage,
1086 size_t num_values,
1087 size_t num_channels,
1088 SharedSpan<ValueType> shared_values,
1089 SharedSpan<Index> shared_indices);
1090
1098 template <typename ValueType>
1100 std::string_view name,
1101 AttributeUsage usage,
1102 size_t num_values,
1103 size_t num_channels,
1104 span<ValueType> values_view,
1105 SharedSpan<Index> shared_indices);
1106
1114 template <typename ValueType>
1116 std::string_view name,
1117 AttributeUsage usage,
1118 size_t num_values,
1119 size_t num_channels,
1120 SharedSpan<ValueType> shared_values,
1121 span<Index> indices_view);
1122
1150 template <typename ValueType>
1152 std::string_view name,
1153 AttributeUsage usage,
1154 size_t num_values,
1155 size_t num_channels,
1156 span<const ValueType> values_view,
1157 span<const Index> indices_view);
1158
1167 template <typename ValueType>
1169 std::string_view name,
1170 AttributeUsage usage,
1171 size_t num_values,
1172 size_t num_channels,
1173 SharedSpan<const ValueType> shared_values,
1174 SharedSpan<const Index> shared_indices);
1175
1183 template <typename ValueType>
1185 std::string_view name,
1186 AttributeUsage usage,
1187 size_t num_values,
1188 size_t num_channels,
1189 span<const ValueType> values_view,
1190 SharedSpan<const Index> shared_indices);
1191
1199 template <typename ValueType>
1201 std::string_view name,
1202 AttributeUsage usage,
1203 size_t num_values,
1204 size_t num_channels,
1205 SharedSpan<const ValueType> shared_values,
1206 span<const Index> indices_view);
1207
1222 AttributeId wrap_as_vertices(span<Scalar> vertices_view, Index num_vertices);
1223
1232
1249
1258 SharedSpan<const Scalar> shared_vertices,
1259 Index num_vertices);
1260
1275 AttributeId wrap_as_facets(span<Index> facets_view, Index num_facets, Index vertex_per_facet);
1276
1285 wrap_as_facets(SharedSpan<Index> shared_facets, Index num_facets, Index vertex_per_facet);
1286
1303 wrap_as_const_facets(span<const Index> facets_view, Index num_facets, Index vertex_per_facet);
1304
1313 SharedSpan<const Index> shared_facets,
1314 Index num_facets,
1315 Index vertex_per_facet);
1316
1336 span<Index> offsets_view,
1337 Index num_facets,
1338 span<Index> facets_view,
1339 Index num_corners);
1340
1350 SharedSpan<Index> shared_offsets,
1351 Index num_facets,
1352 SharedSpan<Index> shared_facets,
1353 Index num_corners);
1354
1363 span<Index> offsets_view,
1364 Index num_facets,
1365 SharedSpan<Index> shared_facets,
1366 Index num_corners);
1367
1376 SharedSpan<Index> shared_offsets,
1377 Index num_facets,
1378 span<Index> facets_view,
1379 Index num_corners);
1380
1401 span<const Index> offsets_view,
1402 Index num_facets,
1403 span<const Index> facets_view,
1404 Index num_corners);
1405
1415 SharedSpan<const Index> shared_offsets,
1416 Index num_facets,
1417 SharedSpan<const Index> shared_facets,
1418 Index num_corners);
1419
1428 span<const Index> offsets_view,
1429 Index num_facets,
1430 SharedSpan<const Index> shared_facets,
1431 Index num_corners);
1432
1441 SharedSpan<const Index> shared_offsets,
1442 Index num_facets,
1443 span<const Index> facets_view,
1444 Index num_corners);
1445
1455 AttributeId duplicate_attribute(std::string_view old_name, std::string_view new_name);
1456
1463 void rename_attribute(std::string_view old_name, std::string_view new_name);
1464
1473 std::string_view name,
1475
1484 AttributeId id,
1486
1504 template <typename ValueType>
1505 std::shared_ptr<Attribute<ValueType>> delete_and_export_attribute(
1506 std::string_view name,
1509
1527 template <typename ValueType>
1528 std::shared_ptr<const Attribute<ValueType>> delete_and_export_const_attribute(
1529 std::string_view name,
1532
1549 template <typename ValueType>
1551 std::string_view name,
1553 -> std::shared_ptr<IndexedAttribute<ValueType, Index>>;
1554
1571 template <typename ValueType>
1573 std::string_view name,
1575 -> std::shared_ptr<const IndexedAttribute<ValueType, Index>>;
1576
1577public:
1581
1596 AttributeId create_metadata(std::string_view name, std::string_view value);
1597
1604 void set_metadata(AttributeId id, std::string_view value);
1605
1613 void set_metadata(std::string_view name, std::string_view value);
1614
1622 std::string_view get_metadata(AttributeId id) const;
1623
1631 std::string_view get_metadata(std::string_view name) const;
1632
1633public:
1637
1648 [[nodiscard]] bool has_attribute(std::string_view name) const;
1649
1659 template <typename ValueType>
1660 [[nodiscard]] bool is_attribute_type(std::string_view name) const;
1661
1671 template <typename ValueType>
1672 [[nodiscard]] bool is_attribute_type(AttributeId id) const;
1673
1680 [[nodiscard]] bool is_attribute_indexed(std::string_view name) const;
1681
1688 [[nodiscard]] bool is_attribute_indexed(AttributeId id) const;
1689
1701
1712 void seq_foreach_attribute_id(function_ref<void(std::string_view, AttributeId)> func) const;
1713
1725
1736 void par_foreach_attribute_id(function_ref<void(std::string_view, AttributeId)> func) const;
1737
1745 [[nodiscard]] const AttributeBase& get_attribute_base(std::string_view name) const;
1746
1754 [[nodiscard]] const AttributeBase& get_attribute_base(AttributeId id) const;
1755
1765 template <typename ValueType>
1766 [[nodiscard]] const Attribute<ValueType>& get_attribute(std::string_view name) const;
1767
1777 template <typename ValueType>
1778 [[nodiscard]] const Attribute<ValueType>& get_attribute(AttributeId id) const;
1779
1790 std::string_view name) const;
1791
1802 AttributeId id) const;
1803
1813 template <typename ValueType>
1814 [[nodiscard]] auto get_indexed_attribute(std::string_view name) const
1816
1826 template <typename ValueType>
1827 [[nodiscard]] auto get_indexed_attribute(AttributeId id) const
1829
1840 template <typename ValueType>
1841 [[nodiscard]] Attribute<ValueType>& ref_attribute(std::string_view name);
1842
1853 template <typename ValueType>
1855
1866 std::string_view name);
1867
1878
1889 template <typename ValueType>
1890 [[nodiscard]] auto ref_indexed_attribute(std::string_view name)
1892
1903 template <typename ValueType>
1905
1911 [[nodiscard]] const Attribute<Scalar>& get_vertex_to_position() const;
1912
1919
1925 [[nodiscard]] const Attribute<Index>& get_corner_to_vertex() const;
1926
1941
1942public:
1946
1955 static bool attr_name_is_reserved(std::string_view name);
1956
1962 static constexpr std::string_view attr_name_vertex_to_position()
1963 {
1964 return s_reserved_names.vertex_to_position();
1965 }
1966
1972 static constexpr std::string_view attr_name_corner_to_vertex()
1973 {
1974 return s_reserved_names.corner_to_vertex();
1975 }
1976
1982 static constexpr std::string_view attr_name_facet_to_first_corner()
1983 {
1984 return s_reserved_names.facet_to_first_corner();
1985 }
1986
1992 static constexpr std::string_view attr_name_corner_to_facet()
1993 {
1994 return s_reserved_names.corner_to_facet();
1995 }
1996
2002 static constexpr std::string_view attr_name_corner_to_edge()
2003 {
2004 return s_reserved_names.corner_to_edge();
2005 }
2006
2012 static constexpr std::string_view attr_name_edge_to_first_corner()
2013 {
2014 return s_reserved_names.edge_to_first_corner();
2015 }
2016
2022 static constexpr std::string_view attr_name_next_corner_around_edge()
2023 {
2024 return s_reserved_names.next_corner_around_edge();
2025 }
2026
2032 static constexpr std::string_view attr_name_vertex_to_first_corner()
2033 {
2034 return s_reserved_names.vertex_to_first_corner();
2035 }
2036
2042 static constexpr std::string_view attr_name_next_corner_around_vertex()
2043 {
2044 return s_reserved_names.next_corner_around_vertex();
2045 }
2046
2052 AttributeId attr_id_vertex_to_position() const { return m_reserved_ids.vertex_to_position(); }
2053
2059 [[deprecated("Use attr_id_vertex_to_position() instead.")]] AttributeId
2061 {
2062 return m_reserved_ids.vertex_to_position();
2063 }
2064
2070 AttributeId attr_id_corner_to_vertex() const { return m_reserved_ids.corner_to_vertex(); }
2071
2078 {
2079 return m_reserved_ids.facet_to_first_corner();
2080 }
2081
2087 AttributeId attr_id_corner_to_facet() const { return m_reserved_ids.corner_to_facet(); }
2088
2094 AttributeId attr_id_corner_to_edge() const { return m_reserved_ids.corner_to_edge(); }
2095
2102 {
2103 return m_reserved_ids.edge_to_first_corner();
2104 }
2105
2112 {
2113 return m_reserved_ids.next_corner_around_edge();
2114 }
2115
2122 {
2123 return m_reserved_ids.vertex_to_first_corner();
2124 }
2125
2132 {
2133 return m_reserved_ids.next_corner_around_vertex();
2134 }
2135
2136public:
2140
2150
2162 void initialize_edges(Index num_user_edges, GetEdgeVertices get_user_edge);
2163
2177
2183 bool has_edges() const
2184 {
2185 return m_reserved_ids.edge_to_first_corner() != invalid_attribute_id();
2186 }
2187
2197
2208
2214 [[deprecated("Use get_corner_edge() instead.")]] Index get_edge_from_corner(Index c) const;
2215
2223 std::array<Index, 2> get_edge_vertices(Index e) const;
2224
2233
2244
2253
2263
2272
2286
2299
2312
2329
2345
2354
2367
2380
2389
2400
2408
2419
2427
2435
2444
2446
2447protected:
2452 {
2453 };
2454
2460 explicit SurfaceMesh(BareMeshTag tag);
2461
2486 template <typename ValueType>
2488 std::string_view name,
2489 AttributeElement element,
2491 size_t num_channels = 1,
2492 span<const ValueType> initial_values = {},
2493 span<const Index> initial_indices = {});
2494
2502 template <typename ValueType>
2503 void set_attribute_default_internal(std::string_view name);
2504
2514
2525 std::pair<Index, Index> reindex_facets_internal(span<const Index> old_to_new);
2526
2537
2546 function_ref<Index(Index)> old_to_new_corners,
2547 CornerMappingType mapping_type);
2548
2557 template <AttributeElement element>
2559
2567
2575
2583
2591
2603
2614
2627
2634 void compute_corner_to_facet_internal(Index facet_begin, Index facet_end);
2635
2645 Index num_user_edges = 0,
2646 GetEdgeVertices* get_user_edge_ptr = nullptr);
2647
2669 Index facet_begin,
2670 Index facet_end,
2671 Index num_user_edges = 0,
2672 GetEdgeVertices* get_user_edge_ptr = nullptr);
2673
2684 Index count,
2685 Index num_user_edges = 0,
2686 GetEdgeVertices* get_user_edge_ptr = nullptr);
2687
2696 [[nodiscard]] size_t get_num_elements_internal(AttributeElement element) const;
2697
2708 template <typename ValueType>
2710 Attribute<std::decay_t<ValueType>>& attr,
2711 size_t num_values,
2712 span<ValueType> values_view);
2713
2727 template <typename ValueType>
2729 Attribute<std::decay_t<ValueType>>& attr,
2730 size_t num_values,
2731 SharedSpan<ValueType> shared_values);
2732
2746 template <typename OffsetSpan, typename FacetSpan>
2748 OffsetSpan offsets,
2749 Index num_facets,
2750 FacetSpan facets,
2751 Index num_corners);
2752
2775 template <typename ValueSpan, typename IndexSpan = span<Index>>
2777 std::string_view name,
2778 AttributeElement element,
2779 AttributeUsage usage,
2780 size_t num_values,
2781 size_t num_channels,
2782 ValueSpan values,
2783 IndexSpan indices = {});
2784
2785protected:
2787
2789 template <typename, typename>
2790 friend class SurfaceMesh;
2791
2795 struct AttributeManager;
2796
2798
2799protected:
2802
2805
2808
2811
2814
2817
2820
2822 struct ReservedAttributeIds
2823 {
2824 AttributeId items[9];
2825
2826 ReservedAttributeIds() { std::fill_n(items, 9, invalid_attribute_id()); }
2827 static constexpr int size() { return 9; }
2828
2829 AttributeId& vertex_to_position() { return items[0]; };
2830 AttributeId& corner_to_vertex() { return items[1]; };
2831 AttributeId& facet_to_first_corner() { return items[2]; };
2832 AttributeId& corner_to_facet() { return items[3]; };
2833 AttributeId& corner_to_edge() { return items[4]; };
2834 AttributeId& edge_to_first_corner() { return items[5]; };
2835 AttributeId& next_corner_around_edge() { return items[6]; };
2836 AttributeId& vertex_to_first_corner() { return items[7]; };
2837 AttributeId& next_corner_around_vertex() { return items[8]; };
2838
2839 const AttributeId& vertex_to_position() const { return items[0]; };
2840 const AttributeId& corner_to_vertex() const { return items[1]; };
2841 const AttributeId& facet_to_first_corner() const { return items[2]; };
2842 const AttributeId& corner_to_facet() const { return items[3]; };
2843 const AttributeId& corner_to_edge() const { return items[4]; };
2844 const AttributeId& edge_to_first_corner() const { return items[5]; };
2845 const AttributeId& next_corner_around_edge() const { return items[6]; };
2846 const AttributeId& vertex_to_first_corner() const { return items[7]; };
2847 const AttributeId& next_corner_around_vertex() const { return items[8]; };
2848 } m_reserved_ids;
2849
2850protected:
2852 static constexpr struct
2853 {
2854 std::string_view items[9] = {
2855 "$vertex_to_position",
2856 "$corner_to_vertex",
2857 "$facet_to_first_corner",
2858 "$corner_to_facet",
2859 "$corner_to_edge",
2860 "$edge_to_first_corner",
2861 "$next_corner_around_edge",
2862 "$vertex_to_first_corner",
2863 "$next_corner_around_vertex",
2864 };
2865 std::string_view vertex_to_position() const { return items[0]; }
2866 std::string_view corner_to_vertex() const { return items[1]; }
2867 std::string_view facet_to_first_corner() const { return items[2]; }
2868 std::string_view corner_to_facet() const { return items[3]; }
2869 std::string_view corner_to_edge() const { return items[4]; }
2870 std::string_view edge_to_first_corner() const { return items[5]; }
2871 std::string_view next_corner_around_edge() const { return items[6]; }
2872 std::string_view vertex_to_first_corner() const { return items[7]; }
2873 std::string_view next_corner_around_vertex() const { return items[8]; }
2875};
2876
2877using SurfaceMesh32f = SurfaceMesh<float, uint32_t>;
2878using SurfaceMesh32d = SurfaceMesh<double, uint32_t>;
2879using SurfaceMesh64f = SurfaceMesh<float, uint64_t>;
2880using SurfaceMesh64d = SurfaceMesh<double, uint64_t>;
2881
2883
2884} // namespace lagrange
Base handle for attributes.
Definition Attribute.h:41
Derived attribute class that stores the actual information.
Definition Attribute.h:153
Derived attribute class that stores the actual information.
Definition IndexedAttribute.h:29
Shared span with ownership tracking.
Definition SharedSpan.h:36
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:1762
Index find_edge_from_vertices(Index v0, Index v1) const
Retrieve the edge index corresponding to (v0, v1).
Definition SurfaceMesh.cpp:2708
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:2940
span< Index > reserve_indices_internal(Index num_facets, Index facet_size)
Reserve index buffer for multiple facets of a given size.
Definition SurfaceMesh.cpp:3353
AttributeId attr_id_vertex_to_position() const
Attribute id for vertex -> positions.
Definition SurfaceMesh.h:2052
void add_quads(Index num_facets, span< const Index > facet_indices={})
Adds multiple quadrilateral facets to the mesh.
Definition SurfaceMesh.cpp:1693
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 o...
Definition SurfaceMesh.cpp:746
Index get_next_corner_around_facet(Index c) const
Gets the next corner around the facet associated to a corner.
Definition SurfaceMesh.cpp:2698
static constexpr std::string_view attr_name_facet_to_first_corner()
Attribute name for facet -> first corner index.
Definition SurfaceMesh.h:1982
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 o...
Definition SurfaceMesh.cpp:788
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:2891
void par_foreach_attribute_id(function_ref< void(AttributeId)> func) const
Iterates over all attribute ids in parallel.
Definition SurfaceMesh.cpp:1263
bool is_quad_mesh() const
Whether the mesh must only contains quadrilateral facets.
Definition SurfaceMesh.cpp:2325
std::string_view get_attribute_name(AttributeId id) const
Retrieve attribute name from its id.
Definition SurfaceMesh.cpp:356
void add_quads(Index num_facets, SetMultiFacetsIndicesFunction set_facets_indices)
Adds multiple quadrilateral facets to the mesh.
Definition SurfaceMesh.cpp:1707
bool is_boundary_edge(Index e) const
Determines whether the specified edge e is a boundary edge.
Definition SurfaceMesh.cpp:2842
Index get_facet_corner_end(Index f) const
Index past the last corner around the facet.
Definition SurfaceMesh.cpp:2378
Attribute< Scalar > & ref_vertex_to_position()
Gets a writable reference to the vertex -> positions attribute.
Definition SurfaceMesh.cpp:1394
void clear_edges()
Clears attributes related to mesh edges and connectivity:
Definition SurfaceMesh.cpp:2651
function_ref< void(Index f, span< Index > t)> SetMultiFacetsIndicesFunction
Callback function to set indices of a multiple facets.
Definition SurfaceMesh.h:118
void set_metadata(std::string_view name, std::string_view value)
Write metadata attribute value.
Definition SurfaceMesh.cpp:1195
void add_vertex(std::initializer_list< const Scalar > p)
Adds a vertex to the mesh.
Definition SurfaceMesh.cpp:1570
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:2512
static constexpr std::string_view attr_name_next_corner_around_vertex()
Attribute name for corner -> next corner around vertex.
Definition SurfaceMesh.h:2042
static constexpr std::string_view attr_name_vertex_to_position()
Attribute name for vertex -> position.
Definition SurfaceMesh.h:1962
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:1972
AttributeId attr_id_corner_to_edge() const
Attribute id for corner -> edge indices.
Definition SurfaceMesh.h:2094
static SurfaceMesh stripped_copy(const SurfaceMesh< OtherScalar, OtherIndex > &other)
Copy constructor stripping away non-reserved attributes.
bool is_attribute_type(AttributeId id) const
Checks whether the specified attribute is of a given type.
Definition SurfaceMesh.cpp:1229
void set_attribute_default_internal(std::string_view name)
Set attribute default value for known internal attributes.
Definition SurfaceMesh.cpp:377
void add_polygon(Index facet_size, SetSingleFacetIndicesFunction set_facet_indices)
Adds a single polygonal facet to the mesh.
Definition SurfaceMesh.cpp:1659
const Attribute< ValueType > & get_attribute(std::string_view name) const
Gets a read-only reference to an attribute given its name.
Definition SurfaceMesh.cpp:1291
Index m_num_facets
Definition SurfaceMesh.h:2804
void delete_attribute(std::string_view name, AttributeDeletePolicy policy=AttributeDeletePolicy::ErrorIfReserved)
Delete an attribute given by name.
Definition SurfaceMesh.cpp:1042
Index count_num_corners_around_edge(Index e) const
Count the number of corners incident to a given edge.
Definition SurfaceMesh.cpp:2813
Index get_num_vertices() const
Retrieves the number of vertices.
Definition SurfaceMesh.h:680
void resize_facets_internal(Index num_facets)
Resize the buffers associated to mesh facets and their attributes.
Definition SurfaceMesh.cpp:3332
Attribute< ValueType > & ref_attribute(std::string_view name)
Gets a writable reference to an attribute given its name.
Definition SurfaceMesh.cpp:1341
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 o...
Definition SurfaceMesh.cpp:619
Index get_corner_edge(Index c) const
Gets the edge index corresponding to a corner index.
Definition SurfaceMesh.cpp:2670
void flip_facets(span< const Index > facets_to_flip, AttributeReorientPolicy reorient_policy=AttributeReorientPolicy::None)
Reverses the orientation of a list of facets.
Definition SurfaceMesh.cpp:2167
AttributeId attr_id_facet_to_first_corner() const
Attribute id for facet -> first corner index.
Definition SurfaceMesh.h:2077
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:1114
std::array< Index, 2 > get_edge_vertices(Index e) const
Retrieve edge endpoints.
Definition SurfaceMesh.cpp:2684
void add_vertices(Index num_vertices, std::initializer_list< const Scalar > coordinates)
Adds multiple vertices to the mesh.
Definition SurfaceMesh.cpp:1593
void add_hybrid(Index num_facets, GetFacetsSizeFunction facet_sizes, SetMultiFacetsIndicesFunction set_facets_indices)
Adds multiple polygonal facets of different sizes to the mesh.
Definition SurfaceMesh.cpp:1789
void remove_vertices(std::initializer_list< const Index > vertices_to_remove)
Removes a list of vertices.
Definition SurfaceMesh.cpp:1853
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 o...
Definition SurfaceMesh.cpp:970
Index get_dimension() const
Retrieves the dimension of the mesh vertices.
Definition SurfaceMesh.h:665
void add_quads(Index num_facets, std::initializer_list< const Index > facet_indices)
Adds multiple quadrilateral facets to the mesh.
Definition SurfaceMesh.cpp:1699
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 o...
Definition SurfaceMesh.cpp:767
Index get_edge(Index f, Index lv) const
Gets the edge index corresponding to (f, lv) – (f, lv+1).
Definition SurfaceMesh.cpp:2662
::lagrange::internal::weak_ptr< const AttributeBase > _get_attribute_ptr(AttributeId id) const
Gets a read-only weak pointer to the base attribute object.
Definition SurfaceMesh.cpp:1313
Index m_vertex_per_facet
Definition SurfaceMesh.h:2816
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.
Definition SurfaceMesh.cpp:3478
Index get_clockwise_corner_around_vertex(Index c) const
Get the adjacent corner around the vertex associated to a corner in the clockwise direction.
Definition SurfaceMesh.cpp:2790
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:407
static constexpr std::string_view attr_name_corner_to_facet()
Attribute name for corner -> facet index.
Definition SurfaceMesh.h:1992
AttributeId attr_id_corner_to_vertex() const
Attribute id for corner -> vertex indices.
Definition SurfaceMesh.h:2070
bool is_attribute_type(std::string_view name) const
Checks whether the specified attribute is of a given type.
Definition SurfaceMesh.cpp:1222
Index m_num_vertices
Definition SurfaceMesh.h:2801
AttributeId get_attribute_id(std::string_view name) const
Retrieve an attribute id given its name.
Definition SurfaceMesh.cpp:346
void reindex_corners_internal(function_ref< Index(Index)> old_to_new_corners, CornerMappingType mapping_type)
Reindex mesh corners according to the given mapping.
Definition SurfaceMesh.cpp:3153
void add_vertices(Index num_vertices, span< const Scalar > coordinates={})
Adds multiple vertices to the mesh.
Definition SurfaceMesh.cpp:1580
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:2741
Index get_edge_from_corner(Index c) const
Gets the edge index corresponding to a corner index.
Definition SurfaceMesh.cpp:2678
void add_triangles(Index num_facets, SetMultiFacetsIndicesFunction set_facets_indices)
Adds multiple triangular facets to the mesh.
Definition SurfaceMesh.cpp:1685
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 o...
Definition SurfaceMesh.cpp:820
span< Index > ref_facet_vertices(Index f)
Retrieves a writable pointer to a facet indices.
Definition SurfaceMesh.cpp:2415
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:2868
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 o...
Definition SurfaceMesh.cpp:432
void remove_vertices(span< const Index > vertices_to_remove)
Removes a list of vertices.
Definition SurfaceMesh.cpp:1809
void remove_facets(span< const Index > facets_to_remove)
Removes a list of facets.
Definition SurfaceMesh.cpp:1900
void resize_vertices_internal(Index num_vertices)
Resize the buffers associated to mesh vertices and their attributes.
Definition SurfaceMesh.cpp:3325
bool has_attribute(std::string_view name) const
Checks if an attribute of a given name is attached to the mesh.
Definition SurfaceMesh.cpp:1215
const Attribute< ValueType > & get_attribute(AttributeId id) const
Gets a read-only reference to an attribute given its id.
Definition SurfaceMesh.cpp:1298
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 o...
Definition SurfaceMesh.cpp:1010
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.
Definition SurfaceMesh.cpp:940
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:725
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:1130
std::string_view get_metadata(AttributeId id) const
Read metadata attribute value.
Definition SurfaceMesh.cpp:1201
AttributeId create_metadata(std::string_view name, std::string_view value)
Create a metadata attribute.
Definition SurfaceMesh.cpp:1174
Index count_num_corners_around_vertex(Index v) const
Count the number of corners incident to a given vertex.
Definition SurfaceMesh.cpp:2759
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.
Definition SurfaceMesh.cpp:980
bool is_attribute_indexed(AttributeId id) const
Determines whether the specified attribute is indexed.
Definition SurfaceMesh.cpp:1242
value_ptr< AttributeManager > m_attributes
Definition SurfaceMesh.h:2819
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 o...
Definition SurfaceMesh.cpp:877
void add_quad(Index v0, Index v1, Index v2, Index v3)
Adds a quadrilateral facet to the mesh.
Definition SurfaceMesh.cpp:1624
void add_polygon(Index facet_size)
Adds a single (uninitialized) polygonal facet to the mesh.
Definition SurfaceMesh.cpp:1633
auto ref_indexed_attribute(AttributeId id) -> IndexedAttribute< ValueType, Index > &
Gets a writable reference to an indexed attribute given its id.
Definition SurfaceMesh.cpp:1379
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:3506
void shrink_to_fit()
Shrink buffer capacities to fit current mesh attributes, deallocating any extra capacity.
Definition SurfaceMesh.cpp:2272
AttributeId attr_id_vertex_to_positions() const
Attribute id for vertex -> positions.
Definition SurfaceMesh.h:2060
void clear_facets()
Clear buffer for mesh facets and other facet/corner attributes.
Definition SurfaceMesh.cpp:2259
Index get_one_corner_around_vertex(Index v) const
Get the index of one corner around a given vertex.
Definition SurfaceMesh.cpp:2836
SurfaceMesh & operator=(const SurfaceMesh &other)
Assignment copy operator.
Index get_facet_corner_begin(Index f) const
First corner around the facet.
Definition SurfaceMesh.cpp:2366
::lagrange::internal::weak_ptr< AttributeBase > _ref_attribute_ptr(AttributeId id)
Gets a weak pointer to the base attribute object.
Definition SurfaceMesh.cpp:1363
void add_vertex(span< const Scalar > p)
Adds a vertex to the mesh.
Definition SurfaceMesh.cpp:1560
SurfaceMesh(Index dimension=3)
Default constructor.
Definition SurfaceMesh.cpp:1432
size_t get_num_elements_internal(AttributeElement element) const
Gets the number of mesh elements, based on an element type.
Definition SurfaceMesh.cpp:362
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:533
AttributeId attr_id_vertex_to_first_corner() const
Attribute id for vertex -> first corner index.
Definition SurfaceMesh.h:2121
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.
Definition SurfaceMesh.cpp:1735
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 o...
Definition SurfaceMesh.cpp:662
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:1356
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:1277
void resize_corners_internal(Index num_corners)
Resize the buffers associated to mesh corners and their attributes.
Definition SurfaceMesh.cpp:3339
void foreach_facet_around_facet(Index f, function_ref< void(Index)> func) const
Applies a function to each of the facets around a prescribed facet.
Definition SurfaceMesh.cpp:2850
void add_triangle(Index v0, Index v1, Index v2)
Adds a triangular facet to the mesh.
Definition SurfaceMesh.cpp:1615
Index_ Index
Mesh index type, used for facet indices.
Definition SurfaceMesh.h:72
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.
Definition SurfaceMesh.cpp:1779
span< Index > reserve_indices_internal(Index num_facets, GetFacetsSizeFunction get_facets_size)
Reserve index buffer for multiple facets of a given size.
Definition SurfaceMesh.cpp:3382
Index get_one_facet_around_edge(Index e) const
Get the index of one facet around a given edge.
Definition SurfaceMesh.cpp:2822
Index get_first_corner_around_edge(Index e) const
Get the index of the first corner around a given edge.
Definition SurfaceMesh.cpp:2735
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 o...
Definition SurfaceMesh.cpp:704
void seq_foreach_attribute_id(function_ref< void(std::string_view, AttributeId)> func) const
Iterates over all pairs of attribute names x ids sequentially.
Definition SurfaceMesh.cpp:1256
void add_triangles(Index num_facets, std::initializer_list< const Index > facet_indices)
Adds multiple triangular facets to the mesh.
Definition SurfaceMesh.cpp:1677
void flip_facets(std::initializer_list< const Index > facets_to_flip, AttributeReorientPolicy reorient_policy=AttributeReorientPolicy::None)
Reverses the orientation of a list of facets.
Definition SurfaceMesh.cpp:2192
void remove_facets(std::initializer_list< const Index > facets_to_remove)
Removes a list of facets.
Definition SurfaceMesh.cpp:1935
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:3463
void add_triangles(Index num_facets, span< const Index > facet_indices={})
Adds multiple triangular facets to the mesh.
Definition SurfaceMesh.cpp:1671
void add_polygon(std::initializer_list< const Index > facet_indices)
Adds a single polygonal facet to the mesh.
Definition SurfaceMesh.cpp:1650
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:2456
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:1323
~SurfaceMesh()
Default destructor.
Attribute< ValueType > & ref_attribute(AttributeId id)
Gets a writable reference to an attribute given its id.
Definition SurfaceMesh.cpp:1348
void resize_elements_internal(Index num_elements)
Resize the buffers associated to a specific element type in the mesh.
Definition SurfaceMesh.cpp:3310
void initialize_edges(Index num_user_edges, GetEdgeVertices get_user_edge)
Initializes attributes associated to mesh edges and connectivity.
Definition SurfaceMesh.cpp:2448
void set_metadata(AttributeId id, std::string_view value)
Write metadata attribute value.
Definition SurfaceMesh.cpp:1185
bool is_regular() const
Whether the mesh must only contains facets of equal sizes.
Definition SurfaceMesh.cpp:2331
AttributeId attr_id_next_corner_around_edge() const
Attribute id for corner -> next corner around edge.
Definition SurfaceMesh.h:2111
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 o...
Definition SurfaceMesh.cpp:683
Index get_first_corner_around_vertex(Index v) const
Get the index of the first corner around a given vertex.
Definition SurfaceMesh.cpp:2747
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 o...
Definition SurfaceMesh.cpp:960
Index m_num_corners
Definition SurfaceMesh.h:2807
bool is_attribute_indexed(std::string_view name) const
Determines whether the specified attribute is indexed.
Definition SurfaceMesh.cpp:1236
const Attribute< Index > & get_corner_to_vertex() const
Gets a read-only reference to the corner -> vertex id attribute.
Definition SurfaceMesh.cpp:1400
std::string_view get_metadata(std::string_view name) const
Read metadata attribute value.
Definition SurfaceMesh.cpp:1209
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:2501
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.
Definition SurfaceMesh.cpp:1270
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:832
Index get_next_corner_around_vertex(Index c) const
Gets the next corner around the vertex associated to a corner.
Definition SurfaceMesh.cpp:2753
Index get_facet_vertex(Index f, Index lv) const
Index of a vertex given from a facet + local index.
Definition SurfaceMesh.h:741
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:898
void compress_if_regular()
Compress mesh storage if the mesh is regular.
Definition SurfaceMesh.cpp:2286
bool is_triangle_mesh() const
Whether the mesh must only contain triangular facets.
Definition SurfaceMesh.cpp:2319
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:3492
Index get_corner_vertex(Index c) const
Retrieves the index of a vertex given its corner index.
Definition SurfaceMesh.cpp:2392
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:2913
void resize_edges_internal(Index num_edges)
Resize the buffers associated to mesh edges and their attributes.
Definition SurfaceMesh.cpp:3346
Index get_corner_facet(Index c) const
Retrieves the index of a facet given its corner index.
Definition SurfaceMesh.cpp:2398
bool has_edges() const
Determines if the attributes associated to mesh edges and connectivity have been initialized.
Definition SurfaceMesh.h:2183
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 o...
Definition SurfaceMesh.cpp:1000
SurfaceMesh(SurfaceMesh &&other) noexcept
Move constructor.
void add_vertices(Index num_vertices, SetVertexCoordinatesFunction set_vertex_coordinates)
Adds multiple vertices to the mesh.
Definition SurfaceMesh.cpp:1601
std::pair< Index, Index > reindex_facets_internal(span< const Index > old_to_new)
Reindex mesh facets according to the given mapping.
Definition SurfaceMesh.cpp:3044
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:1145
span< const Index > get_facet_vertices(Index f) const
Retrieves a read-only pointer to a facet indices.
Definition SurfaceMesh.cpp:2409
static constexpr std::string_view attr_name_edge_to_first_corner()
Attribute name for edge -> first corner index.
Definition SurfaceMesh.h:2012
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:1371
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:597
bool is_hybrid() const
Whether the mesh may contain facets of different sizes.
Definition SurfaceMesh.h:658
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 o...
Definition SurfaceMesh.cpp:575
Index get_num_edges() const
Retrieves the number of edges.
Definition SurfaceMesh.h:701
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:453
AttributeId wrap_as_vertices(span< Scalar > vertices_view, Index num_vertices)
Wraps a writable external buffer as mesh vertices coordinates.
Definition SurfaceMesh.cpp:808
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 o...
Definition SurfaceMesh.cpp:950
Index get_one_corner_around_edge(Index e) const
Get the index of one corner around a given edge.
Definition SurfaceMesh.cpp:2830
static constexpr struct lagrange::SurfaceMesh::@325255152247021150212276167153340070021334233120 s_reserved_names
Index get_num_facets() const
Retrieves the number of facets.
Definition SurfaceMesh.h:687
Index get_vertex_per_facet() const
Retrieves the number of vertex per facet in a regular mesh.
Definition SurfaceMesh.cpp:2345
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 o...
Definition SurfaceMesh.cpp:990
SurfaceMesh(const SurfaceMesh &other)
Copy constructor.
span< Scalar > ref_position(Index v)
Retrieves a writeable pointer to a vertex coordinates.
Definition SurfaceMesh.cpp:2360
AttributeId attr_id_edge_to_first_corner() const
Attribute id for edge -> first corner index.
Definition SurfaceMesh.h:2101
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:641
AttributeId duplicate_attribute(std::string_view old_name, std::string_view new_name)
Duplicates an attribute.
Definition SurfaceMesh.cpp:1020
void flip_facets(function_ref< bool(Index)> should_flip_func, AttributeReorientPolicy reorient_policy=AttributeReorientPolicy::None)
Reverses the orientation of a list of facets.
Definition SurfaceMesh.cpp:2200
static constexpr std::string_view attr_name_vertex_to_first_corner()
Attribute name for vertex -> first corner index.
Definition SurfaceMesh.h:2032
void delete_attribute(AttributeId id, AttributeDeletePolicy policy=AttributeDeletePolicy::ErrorIfReserved)
Delete an attribute given by its id.
Definition SurfaceMesh.cpp:1079
void remove_vertices(function_ref< bool(Index)> should_remove_func)
Removes a list of vertices, defined by a predicate function.
Definition SurfaceMesh.cpp:1860
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.
Definition SurfaceMesh.cpp:3555
AttributeId attr_id_next_corner_around_vertex() const
Attribute id for corner -> next corner around vertex.
Definition SurfaceMesh.h:2131
Index m_dimension
Definition SurfaceMesh.h:2813
void initialize_edges(span< const Index > edges={})
Initializes attributes associated to mesh edges and connectivity.
Definition SurfaceMesh.cpp:2425
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:2002
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:553
Index get_counterclockwise_corner_around_vertex(Index c) const
Get the adjacent corner around the vertex associated to a corner in the counterclockwise direction.
Definition SurfaceMesh.cpp:2768
const AttributeBase & get_attribute_base(AttributeId id) const
Gets a read-only reference to an attribute given its id.
Definition SurfaceMesh.cpp:1283
void add_polygons(Index num_facets, Index facet_size, SetMultiFacetsIndicesFunction set_facets_indices)
Adds multiple polygonal facets of the same size to the mesh.
Definition SurfaceMesh.cpp:1747
AttributeId attr_id_corner_to_facet() const
Attribute id for corner -> facet index.
Definition SurfaceMesh.h:2087
void add_polygon(span< const Index > facet_indices)
Adds a single polygonal facet to the mesh.
Definition SurfaceMesh.cpp:1641
static SurfaceMesh stripped_move(SurfaceMesh< OtherScalar, OtherIndex > &&other)
Move constructor stripping away non-reserved attributes.
Attribute< Index > & ref_corner_to_vertex(AttributeRefPolicy policy=AttributeRefPolicy::Default)
Gets a writable reference to the corner -> vertex id attribute.
Definition SurfaceMesh.cpp:1406
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:856
void reindex_vertices_internal(span< const Index > old_to_new)
Reindex mesh vertices according to the given mapping.
Definition SurfaceMesh.cpp:3019
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:2927
void rename_attribute(std::string_view old_name, std::string_view new_name)
Rename an existing attribute.
Definition SurfaceMesh.cpp:1031
span< Index > reserve_indices_internal(span< const Index > facet_sizes)
Reserve index buffer for multiple facets of a given size.
Definition SurfaceMesh.cpp:3373
const Attribute< Scalar > & get_vertex_to_position() const
Gets a read-only reference to the vertex -> positions attribute.
Definition SurfaceMesh.cpp:1388
CornerMappingType
Assumptions on the corner mapping received by the internal reindexing method.
Definition SurfaceMesh.h:2530
@ RemovingFacets
Buffer is being compressed, so it is safe to move data without an intermediate buffer.
Definition SurfaceMesh.h:2532
@ ReversingFacets
Facets are being flipped, so it is safe to simply swap rows i and j when i < j.
Definition SurfaceMesh.h:2535
Index get_facet_size(Index f) const
Number of vertices in the facet.
Definition SurfaceMesh.h:728
void remove_facets(function_ref< bool(Index)> should_remove_func)
Removes a list of facets, defined by a predicate function.
Definition SurfaceMesh.cpp:1941
Index m_num_edges
Definition SurfaceMesh.h:2810
void clear_vertices()
Clear buffer for mesh vertices and other vertex attributes.
Definition SurfaceMesh.cpp:2249
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 o...
Definition SurfaceMesh.cpp:919
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:1160
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 o...
Definition SurfaceMesh.cpp:844
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:1715
::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:1306
static constexpr std::string_view attr_name_next_corner_around_edge()
Attribute name for corner -> next corner around edge.
Definition SurfaceMesh.h:2022
static bool attr_name_is_reserved(std::string_view name)
Check whether the given name corresponds to a reserved attribute.
Definition SurfaceMesh.cpp:1417
SurfaceMesh(BareMeshTag tag)
Internal constructor.
Definition SurfaceMesh.cpp:1427
auto get_indexed_attribute(AttributeId id) const -> const IndexedAttribute< ValueType, Index > &
Gets a read-only reference to an indexed attribute given its id.
Definition SurfaceMesh.cpp:1331
Index get_num_corners() const
Retrieves the number of corners.
Definition SurfaceMesh.h:694
span< const Scalar > get_position(Index v) const
Retrieves a read-only pointer to a vertex coordinates.
Definition SurfaceMesh.cpp:2354
void seq_foreach_attribute_id(function_ref< void(AttributeId)> func) const
Iterates over all attribute ids sequentially.
Definition SurfaceMesh.cpp:1249
A lightweight non-owning reference to a callable.
Definition function_ref.h:47
Definition weak_ptr.h:26
Smart pointer with value semantics.
Definition value_ptr.h:134
AttributeReorientPolicy
Policy for updating attribute values when reorienting mesh facets.
Definition AttributeFwd.h:192
AttributeRefPolicy
Policy for retrieving writable references to attribute buffers.
Definition AttributeFwd.h:202
AttributeCreatePolicy
Policy for attribute creation with reserved attribute names.
Definition AttributeFwd.h:86
uint32_t AttributeId
Identified to be used to access an attribute.
Definition AttributeFwd.h:73
AttributeExportPolicy
Policy for exporting attributes that are views onto external buffers.
Definition AttributeFwd.h:149
AttributeUsage
Usage tag indicating how the attribute should behave under mesh transformations.
Definition AttributeFwd.h:54
AttributeElement
Type of element to which the attribute is attached.
Definition AttributeFwd.h:26
AttributeDeletePolicy
Policy for attribute deletion of reserved attribute names.
Definition AttributeFwd.h:172
constexpr AttributeId invalid_attribute_id()
Invalid attribute id.
Definition AttributeFwd.h:76
@ None
Do not reorient attribute values when flipping mesh facets.
Definition AttributeFwd.h:193
@ Default
Throws an exception if the attribute is the corner -> vertex id attribute and the mesh has edge/conne...
Definition AttributeFwd.h:205
@ ErrorIfReserved
Default deletion policy, throw an exception if attribute name is reserved.
Definition AttributeFwd.h:87
@ CopyIfExternal
Copy the buffer during export if the attribute points to an external buffer.
Definition AttributeFwd.h:150
@ Vector
Mesh attribute can have any number of channels (including 1 channel).
Definition AttributeFwd.h:55
@ ErrorIfReserved
Default deletion policy, throw an exception if attribute name is reserved.
Definition AttributeFwd.h:173
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
nullptr_t, size_t, ptrdiff_t basic_ostream bad_weak_ptr extent, remove_extent, is_array,...
Definition attribute_string_utils.h:21
Main namespace for Lagrange.
Overload tag.
Definition SurfaceMesh.h:2452