Wildmeshing Toolkit
AccessorBase.hxx
Go to the documentation of this file.
1 #pragma once
3 #include "AccessorBase.hpp"
4 #include "AttributeManager.hpp"
5 // #include "MeshAttributeHandle.hpp"
6 // #include "MeshAttributes.hpp"
7 //#include "wmtk/Mesh.hpp"
8 
9 namespace wmtk::attribute {
10 template <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 {}
16 template <typename T, int Dim>
18  : AccessorBase(const_cast<Mesh&>(m), handle)
19 {}
20 
21 
22 template <typename T, int Dim>
24 {
25  return m_mesh;
26 }
27 template <typename T, int Dim>
28 inline const Mesh& AccessorBase<T, Dim>::mesh() const
29 {
30  return m_mesh;
31 }
32 
33 template <typename T, int Dim>
35 {
36  return mesh().m_attribute_manager;
37 }
38 
39 template <typename T, int Dim>
41 {
42  return mesh().m_attribute_manager;
43 }
44 
45 
46 template <typename T, int Dim>
48 
49 
50 template <typename T, int Dim>
52 {
53  return attribute().reserved_size();
54 }
55 
56 template <typename T, int Dim>
57 inline int64_t AccessorBase<T, Dim>::dimension() const
58 {
59  return attribute().dimension();
60 }
61 
62 template <typename T, int Dim>
64 {
65  return attribute().default_value();
66 }
67 
68 template <typename T, int Dim>
70 {
71  return attribute_manager().get(m_handle);
72 }
73 template <typename T, int Dim>
74 inline auto AccessorBase<T, Dim>::attributes() const -> const MeshAttributes<T>&
75 {
76  return attribute_manager().get(m_handle);
77 }
78 template <typename T, int Dim>
80 {
81  return m_attribute;
82 }
83 template <typename T, int Dim>
84 inline auto AccessorBase<T, Dim>::attribute() const -> const Attribute<T>&
85 {
86  return m_attribute;
87 }
88 template <typename T, int Dim>
90 {
91  return m_handle;
92 }
93 template <typename T, int Dim>
95 {
96  return MeshAttributeHandle(m_mesh, m_handle);
97 }
98 
99 template <typename T, int Dim>
101 {
102  return handle().primitive_type();
103 }
104 
105 template <typename T, int Dim>
106 template <int D>
107 inline 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 
114 template <typename T, int Dim>
115 template <int D>
116 inline 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 
124 template <typename T, int Dim>
125 inline 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 }
130 template <typename T, int Dim>
131 inline auto AccessorBase<T, Dim>::scalar_attribute(const int64_t index) -> T&
132 {
133  auto& value = attribute().scalar_attribute(index);
134  return value;
135 }
136 
137 template <typename T, int Dim>
138 inline 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 }
144 template <typename T, int Dim>
145 inline 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 
151 template <typename T, int Dim>
152 inline 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
ConstMapResult< D > const_vector_attribute(const int64_t index) const
const AttributeManager & attribute_manager() const
PrimitiveType primitive_type() const
void set_attribute(std::vector< T > value)
Attribute< T > & attribute()
T & scalar_attribute(const int64_t index)
MapResult< D > vector_attribute(const int64_t index)
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.