Wildmeshing Toolkit
Loading...
Searching...
No Matches
AccessorBase.hxx
Go to the documentation of this file.
1#pragma once
3#include "AccessorBase.hpp"
5// #include "MeshAttributeHandle.hpp"
6// #include "MeshAttributes.hpp"
7//#include "wmtk/Mesh.hpp"
8
9namespace wmtk::attribute {
10template <typename T, int Dim>
12 : m_handle(handle)
13 , m_mesh(m)
14 , m_attribute(mesh().m_attribute_manager.get(m_handle).attribute(m_handle.m_base_handle))
15{}
16template <typename T, int Dim>
18 : AccessorBase(const_cast<Mesh&>(m), handle)
19{}
20
21
22template <typename T, int Dim>
24{
25 return m_mesh;
26}
27template <typename T, int Dim>
28inline const Mesh& AccessorBase<T, Dim>::mesh() const
29{
30 return m_mesh;
31}
32
33template <typename T, int Dim>
35{
36 return mesh().m_attribute_manager;
37}
38
39template <typename T, int Dim>
41{
42 return mesh().m_attribute_manager;
43}
44
46template <typename T, int Dim>
48
49
50template <typename T, int Dim>
52{
53 return attribute().reserved_size();
54}
55
56template <typename T, int Dim>
57inline int64_t AccessorBase<T, Dim>::dimension() const
59 return attribute().dimension();
62template <typename T, int Dim>
65 return attribute().default_value();
68template <typename T, int Dim>
70{
71 return attribute_manager().get(m_handle);
73template <typename T, int Dim>
76 return attribute_manager().get(m_handle);
77}
78template <typename T, int Dim>
80{
81 return m_attribute;
82}
83template <typename T, int Dim>
84inline auto AccessorBase<T, Dim>::attribute() const -> const Attribute<T>&
85{
86 return m_attribute;
88template <typename T, int Dim>
90{
91 return m_handle;
92}
93template <typename T, int Dim>
95{
96 return MeshAttributeHandle(m_mesh, m_handle);
97}
98
99template <typename T, int Dim>
101{
102 return handle().primitive_type();
103}
104
105template <typename T, int Dim>
106template <int D>
107inline auto AccessorBase<T, Dim>::const_vector_attribute(const int64_t index) const
109{
110 auto buffer = attribute().template const_vector_attribute<D>(index);
111 return buffer;
112}
113
114template <typename T, int Dim>
115template <int D>
116inline auto AccessorBase<T, Dim>::vector_attribute(const int64_t index) -> MapResult<D>
117{
118 auto& attr = attribute();
119 auto buffer = attr.template vector_attribute<D>(index);
120
121 return buffer;
122}
123
124template <typename T, int Dim>
125inline T AccessorBase<T, Dim>::const_scalar_attribute(const int64_t index) const
126{
127 auto value = attribute().const_scalar_attribute(index);
128 return value;
129}
130template <typename T, int Dim>
131inline auto AccessorBase<T, Dim>::scalar_attribute(const int64_t index) -> T&
132{
133 auto& value = attribute().scalar_attribute(index);
134 return value;
135}
136
137template <typename T, int Dim>
138inline T AccessorBase<T, Dim>::const_scalar_attribute(const int64_t index, const int8_t offset)
139 const
140{
141 auto value = attribute().const_scalar_attribute(index, offset);
142 return value;
143}
144template <typename T, int Dim>
145inline auto AccessorBase<T, Dim>::scalar_attribute(const int64_t index, const int8_t offset) -> T&
146{
147 auto& value = attribute().scalar_attribute(index, offset);
148 return value;
149}
150
151template <typename T, int Dim>
152inline void AccessorBase<T, Dim>::set_attribute(std::vector<T> value)
153{
154 attribute().set(std::move(value));
155}
156// template class AccessorBase<char>;
157// template class AccessorBase<int64_t>;
158// template class AccessorBase<double>;
159// template class AccessorBase<Rational>;
160} // namespace wmtk::attribute
T const_scalar_attribute(const int64_t index) const
const T & default_value() const
MeshAttributes< T > & attributes()
AccessorBase(Mesh &m, const TypedAttributeHandle< T > &handle)
const TypedAttributeHandle< T > & typed_handle() const
MeshAttributeHandle handle() const
internal::ConstMapResult< T, D > ConstMapResult
const AttributeManager & attribute_manager() const
PrimitiveType primitive_type() const
void set_attribute(std::vector< T > value)
MapResult< D > vector_attribute(const int64_t index)
T & scalar_attribute(const int64_t index)
ConstMapResult< D > const_vector_attribute(const int64_t index) const
internal::MapResult< T, D > MapResult
This class stores data of type T in a vector.
Definition Attribute.hpp:32
Contains all attributes of type T for a single mesh.
Handle that represents attributes for some mesh.