14 template <
typename T,
int Dim>
18 class PerThreadAttributeScopeStacks;
34 template <
int D = Eigen::Dynamic>
36 template <
int D = Eigen::Dynamic>
41 std::map<std::string, size_t>
child_hashes()
const override;
44 template <
typename U,
int D>
64 template <
int D = Eigen::Dynamic>
66 template <
int D = Eigen::Dynamic>
68 template <
int D = Eigen::Dynamic>
79 void set(std::vector<T> val);
92 void reserve(
const int64_t size);
112 void consolidate(
const std::vector<int64_t>& new2old);
119 void index_remap(
const std::vector<T>& old2new,
const std::vector<Eigen::Index>& cols);
126 template <
int D = Eigen::Dynamic>
134 template <
int D = Eigen::Dynamic>
137 const std::vector<T>& data)
const;
142 template <
int D = Eigen::Dynamic>
150 template <
int D = Eigen::Dynamic>
175 T&
scalar_attribute(
const int64_t index,
const int8_t offset, std::vector<T>& data)
const;
190 template <
typename T>
194 return const_vector_attribute<D>(index, m_data);
197 template <
typename T>
202 assert(index < reserved_size(data));
203 assert(data.size() % m_dimension == 0);
204 const int64_t start = index * m_dimension;
205 return const_vector_attribute_from_start<D>(start, data);
207 template <
typename T>
213 assert(m_dimension > 0);
214 if constexpr (D != Eigen::Dynamic) {
215 assert(D == m_dimension);
219 assert(R.size() == m_dimension);
225 template <
typename T>
230 return vector_attribute<D>(index, m_data);
233 template <
typename T>
241 template <
typename T>
246 assert(index < reserved_size(data));
247 assert(data.size() % m_dimension == 0);
248 const int64_t start = index * m_dimension;
249 return vector_attribute_from_start<D>(start, data);
252 template <
typename T>
257 assert(m_dimension > 0);
258 if constexpr (D != Eigen::Dynamic) {
259 assert(D == m_dimension);
264 assert(R.size() == m_dimension);
268 template <
typename T>
271 return const_scalar_attribute(index, m_data);
273 template <
typename T>
276 assert(index < reserved_size(data));
277 assert(m_dimension == 1);
281 template <
typename T>
284 return scalar_attribute(index, m_data);
286 template <
typename T>
289 assert(index < reserved_size(data));
290 assert(m_dimension == 1);
294 template <
typename T>
297 return const_scalar_attribute(index, offset, m_data);
299 template <
typename T>
303 const std::vector<T>& data)
const
305 const int64_t idx = index * m_dimension + offset;
306 assert(index < reserved_size(data));
310 template <
typename T>
313 return scalar_attribute(index, offset, m_data);
315 template <
typename T>
319 const int64_t idx = index * m_dimension + offset;
320 assert(index < reserved_size(data));
325 template <
typename T>
331 template <
typename T>
334 return m_default_value;
337 template <
typename T>
340 return m_scope_stacks.local();
342 template <
typename T>
345 return m_scope_stacks.local();
348 template <
typename T>
351 m_scope_stacks.local().emplace();
353 template <
typename T>
356 m_scope_stacks.local().pop(*
this, apply_updates);
359 template <
typename T>
362 m_scope_stacks.local().rollback_current_scope(*
this);
This class stores data of type T in a vector.
Attribute & operator=(Attribute &&o)
Attribute(const std::string &name, int64_t dimension, T default_value=T(0), int64_t size=0)
Initialize the attribute.
void index_remap(const std::vector< T > &old2new)
Applies the scalar old2new map to the indices in the attribute This is commonly used after a consolid...
MapResult< D > vector_attribute_from_start(const int64_t index, std::vector< T > &data) const
Accesses the attribute using the specified vector as the underlying data This is internally used by t...
internal::ConstMapResult< T, D > ConstMapResult
const internal::AttributeTransactionStack< T > & get_local_scope_stack() const
const T & default_value() const
returns the default value of this attribute
MapResult< D > vector_attribute(const int64_t index)
MapResult< D > vector_attribute(const int64_t index, std::vector< T > &data) const
Accesses the attribute using the specified vector as the underlying data This is internally used by t...
PerThreadAttributeScopeStacks< T > m_scope_stacks
int64_t dimension() const
The number of values for each index.
T & scalar_attribute(const int64_t index)
ConstMapResult< D > const_vector_attribute(const int64_t index, const std::vector< T > &data) const
Accesses the attribute using the specified vector as the underlying data This is internally used by t...
void rollback_current_scope()
internal::MapResult< T, D > MapResult
void pop_scope(bool apply_updates)
bool operator==(const Attribute< T > &o) const
ConstMapResult< D > const_vector_attribute(const int64_t index) const
void serialize(const std::string &name, const int dim, MeshWriter &writer) const
void reserve(const int64_t size)
void consolidate(const std::vector< int64_t > &new2old)
Consolidate the vector, using the new2old map m provided and resizing the vector to m....
int64_t reserved_size() const
The total number of elements in a vector.
ConstMapResult< D > const_vector_attribute_from_start(const int64_t index, const std::vector< T > &data) const
Accesses the attribute using the specified vector as the underlying data This is internally used by t...
void set(std::vector< T > val)
Replace the internal data with val.
MapResult< D > vector_attribute2(const int64_t index)
std::map< std::string, size_t > child_hashes() const override
T const_scalar_attribute(const int64_t index) const
typename VectorResult< T, R >::MapType MapResult
the default map type used by attributes is a map of our vector type.
typename VectorResult< T, R >::ConstMapType ConstMapResult