17#include <lagrange/GenuineMeshGeometry.h>
18#include <lagrange/utils/assert.h>
23template <
typename _AttributeArray,
typename _IndexArray>
27 using AttributeArray = _AttributeArray;
28 using IndexArray = _IndexArray;
30 using Scalar =
typename AttributeArray::Scalar;
31 using Index =
typename IndexArray::Scalar;
34 std::vector<std::string> get_attribute_names()
const
36 std::vector<std::string> names;
37 for (
const auto& itr : m_data) {
38 names.push_back(itr.first);
43 bool has_attribute(
const std::string& name)
const {
return m_data.find(name) != m_data.end(); }
45 void add_attribute(
const std::string& name)
47 m_data.emplace(name, std::make_shared<AttributeData>());
50 template <
typename ValueDerived,
typename IndexDerived>
52 const std::string& name,
53 const Eigen::PlainObjectBase<ValueDerived>& values,
54 const Eigen::PlainObjectBase<IndexDerived>& indices)
57 std::make_shared<GenuineMeshGeometry<AttributeArray, IndexArray>>(values, indices);
58 m_data.emplace(name, std::move(data));
61 template <
typename ValueDerived,
typename IndexDerived>
63 const std::string& name,
64 const Eigen::PlainObjectBase<ValueDerived>& values,
65 const Eigen::PlainObjectBase<IndexDerived>& indices)
67 auto itr = m_data.find(name);
70 std::make_shared<GenuineMeshGeometry<AttributeArray, IndexArray>>(values, indices);
73 const AttributeData& get_attribute(
const std::string& name)
const
75 auto itr = m_data.find(name);
82 auto itr = m_data.find(name);
87 const AttributeArray& get_attribute_values(
const std::string& name)
const
89 return get_attribute(name).get_vertices();
92 AttributeArray& get_attribute_values(
const std::string& name)
94 return get_attribute(name).get_vertices();
97 const IndexArray& get_attribute_indices(
const std::string& name)
const
99 return get_attribute(name).get_facets();
102 IndexArray& get_attribute_indices(
const std::string& name)
104 return get_attribute(name).get_facets();
107 void remove_attribute(
const std::string& name)
109 auto itr = m_data.find(name);
114 template <
typename ValueDerived,
typename IndexDerived>
115 void import_attribute(
116 const std::string& name,
117 Eigen::PlainObjectBase<ValueDerived>& values,
118 Eigen::PlainObjectBase<IndexDerived>& indices)
120 auto itr = m_data.find(name);
122 itr->second->import_vertices(values);
123 itr->second->import_facets(indices);
126 template <
typename ValueDerived,
typename IndexDerived>
127 void export_attribute(
128 const std::string& name,
129 Eigen::PlainObjectBase<ValueDerived>& values,
130 Eigen::PlainObjectBase<IndexDerived>& indices)
132 auto itr = m_data.find(name);
134 itr->second->export_vertices(values);
135 itr->second->export_facets(indices);
138 decltype(
auto) get_attribute_as_mesh(
const std::string& name)
140 auto itr = m_data.find(name);
143 return std::make_unique<MeshType>(itr->second);
147 std::map<std::string, std::shared_ptr<AttributeData>> m_data;
Definition: GenuineMeshGeometry.h:25
Legacy indexed attribute class.
Definition: IndexedAttributes.h:25
#define la_runtime_assert(...)
Runtime assertion check.
Definition: assert.h:169
Main namespace for Lagrange.
Definition: AABBIGL.h:30