16#include <lagrange/Mesh.h>
17#include <lagrange/MeshTrait.h>
18#include <lagrange/common.h>
19#include <lagrange/legacy/inline.h>
20#include <lagrange/utils/assert.h>
26template <
typename MeshType>
27void rename_vertex_attribute(
29 const std::string& old_name,
30 const std::string& new_name)
32 static_assert(MeshTrait<MeshType>::is_mesh(),
"MeshType is not a mesh");
34 using AttributeArray =
typename MeshType::AttributeArray;
37 AttributeArray attr_values;
38 mesh.export_vertex_attribute(old_name, attr_values);
39 mesh.remove_vertex_attribute(old_name);
40 mesh.add_vertex_attribute(new_name);
41 mesh.import_vertex_attribute(new_name, attr_values);
44template <
typename MeshType>
45void rename_facet_attribute(
47 const std::string& old_name,
48 const std::string& new_name)
50 static_assert(MeshTrait<MeshType>::is_mesh(),
"MeshType is not a mesh");
52 using AttributeArray =
typename MeshType::AttributeArray;
55 AttributeArray attr_values;
56 mesh.export_facet_attribute(old_name, attr_values);
57 mesh.remove_facet_attribute(old_name);
58 mesh.add_facet_attribute(new_name);
59 mesh.import_facet_attribute(new_name, attr_values);
62template <
typename MeshType>
63void rename_corner_attribute(
65 const std::string& old_name,
66 const std::string& new_name)
68 static_assert(MeshTrait<MeshType>::is_mesh(),
"MeshType is not a mesh");
70 using AttributeArray =
typename MeshType::AttributeArray;
73 AttributeArray attr_values;
74 mesh.export_corner_attribute(old_name, attr_values);
75 mesh.remove_corner_attribute(old_name);
76 mesh.add_corner_attribute(new_name);
77 mesh.import_corner_attribute(new_name, attr_values);
80template <
typename MeshType>
81void rename_edge_attribute(
MeshType& mesh,
const std::string& old_name,
const std::string& new_name)
83 static_assert(MeshTrait<MeshType>::is_mesh(),
"MeshType is not a mesh");
85 using AttributeArray =
typename MeshType::AttributeArray;
88 AttributeArray attr_values;
89 mesh.export_edge_attribute(old_name, attr_values);
90 mesh.remove_edge_attribute(old_name);
91 mesh.add_edge_attribute(new_name);
92 mesh.import_edge_attribute(new_name, attr_values);
95template <
typename MeshType>
96void rename_indexed_attribute(
98 const std::string& old_name,
99 const std::string& new_name)
101 static_assert(MeshTrait<MeshType>::is_mesh(),
"MeshType is not a mesh");
103 using AttributeArray =
typename MeshType::AttributeArray;
104 using IndexArray =
typename MeshType::IndexArray;
107 AttributeArray attr_values;
108 IndexArray attr_indices;
109 mesh.export_indexed_attribute(old_name, attr_values, attr_indices);
110 mesh.remove_indexed_attribute(old_name);
111 mesh.add_indexed_attribute(new_name);
112 mesh.import_indexed_attribute(new_name, attr_values, attr_indices);
#define la_runtime_assert(...)
Runtime assertion check.
Definition: assert.h:169
Main namespace for Lagrange.
Definition: AABBIGL.h:30