Wildmeshing Toolkit
wmtk::attribute::Attribute< T > Class Template Reference

This class stores data of type T in a vector. More...

#include <Attribute.hpp>

Inheritance diagram for wmtk::attribute::Attribute< T >:
[legend]
Collaboration diagram for wmtk::attribute::Attribute< T >:
[legend]

Public Types

template<int D = Eigen::Dynamic>
using MapResult = internal::MapResult< T, D >
 
template<int D = Eigen::Dynamic>
using ConstMapResult = internal::ConstMapResult< T, D >
 

Public Member Functions

std::map< std::string, size_t > child_hashes () const override
 
void serialize (const std::string &name, const int dim, MeshWriter &writer) const
 
 Attribute (const std::string &name, int64_t dimension, T default_value=T(0), int64_t size=0)
 Initialize the attribute. More...
 
 Attribute (Attribute &&o)
 
 ~Attribute ()
 
Attributeoperator= (Attribute &&o)
 
template<int D = Eigen::Dynamic>
ConstMapResult< D > const_vector_attribute (const int64_t index) const
 
template<int D = Eigen::Dynamic>
MapResult< D > vector_attribute (const int64_t index)
 
template<int D = Eigen::Dynamic>
MapResult< D > vector_attribute2 (const int64_t index)
 
const_scalar_attribute (const int64_t index) const
 
T & scalar_attribute (const int64_t index)
 
const_scalar_attribute (const int64_t index, const int8_t offset) const
 
T & scalar_attribute (const int64_t index, const int8_t offset)
 
void set (std::vector< T > val)
 Replace the internal data with val. More...
 
int64_t reserved_size () const
 The total number of elements in a vector. More...
 
int64_t dimension () const
 The number of values for each index. More...
 
void reserve (const int64_t size)
 
const T & default_value () const
 returns the default value of this attribute More...
 
bool operator== (const Attribute< T > &o) const
 
void push_scope ()
 
void pop_scope (bool apply_updates)
 
void rollback_current_scope ()
 
const internal::AttributeTransactionStack< T > & get_local_scope_stack () const
 
internal::AttributeTransactionStack< T > & get_local_scope_stack ()
 
void consolidate (const std::vector< int64_t > &new2old)
 Consolidate the vector, using the new2old map m provided and resizing the vector to m.size() More...
 
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 consolidate to account for the change in global indices. More...
 
void index_remap (const std::vector< T > &old2new, const std::vector< Eigen::Index > &cols)
 
template<int D = Eigen::Dynamic>
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 the single-arg const_vector_attribute and to help with serialization. More...
 
template<int D = Eigen::Dynamic>
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 the single-arg const_vector_attribute and to help with serialization. More...
 
template<int D = Eigen::Dynamic>
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 the single-arg vector_attribute and to help with serialization. More...
 
template<int D = Eigen::Dynamic>
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 the single-arg const_vector_attribute and to help with serialization. More...
 
const_scalar_attribute (const int64_t index, const std::vector< T > &data) const
 Accesses the attribute using the specified scalar as the underlying data This is internally used by the single-arg const_scalar_attribute and to help with serialization. More...
 
T & scalar_attribute (const int64_t index, std::vector< T > &data) const
 Accesses the attribute using the specified scalar as the underlying data This is internally used by the single-arg scalar_attribute and to help with serialization. More...
 
const_scalar_attribute (const int64_t index, const int8_t offset, const std::vector< T > &data) const
 Accesses the attribute using the specified scalar as the underlying data This is internally used by the single-arg const_scalar_attribute and to help with serialization. More...
 
T & scalar_attribute (const int64_t index, const int8_t offset, std::vector< T > &data) const
 Accesses the attribute using the specified scalar as the underlying data This is internally used by the single-arg scalar_attribute and to help with serialization. More...
 
int64_t reserved_size (const std::vector< T > &data) const
 
template<int D>
auto const_vector_attribute (const int64_t index) const -> ConstMapResult< D >
 
template<int D>
auto const_vector_attribute (const int64_t index, const std::vector< T > &data) const -> ConstMapResult< D >
 
template<int D>
auto const_vector_attribute_from_start (const int64_t start, const std::vector< T > &data) const -> ConstMapResult< D >
 
template<int D>
auto vector_attribute (const int64_t index) -> MapResult< D >
 
template<int D>
auto vector_attribute2 (const int64_t index) -> MapResult< D >
 
template<int D>
auto vector_attribute (const int64_t index, std::vector< T > &data) const -> MapResult< D >
 
template<int D>
auto vector_attribute_from_start (const int64_t start, std::vector< T > &data) const -> MapResult< D >
 
- Public Member Functions inherited from wmtk::utils::Hashable
 Hashable ()
 
 Hashable (const Hashable &)
 
 Hashable (Hashable &&)
 
Hashableoperator= (const Hashable &)
 
Hashableoperator= (Hashable &&)
 
virtual ~Hashable ()
 
virtual std::size_t hash () const
 

Public Attributes

std::string m_name
 

Private Attributes

std::vector< T > m_data
 
PerThreadAttributeScopeStacks< T > m_scope_stacks
 
int64_t m_dimension = -1
 
m_default_value = T(0)
 

Friends

template<typename U , int D>
class AccessorBase
 
class internal::AttributeTransactionStack< T >
 

Detailed Description

template<typename T>
class wmtk::attribute::Attribute< T >

This class stores data of type T in a vector.

If multiple values should be hold per index, the data will be automatically linearized. For example, per index we have a 3-dimensional vector. Then the data vector will contain: [x0,y0,z0,x1,y1,z1,...]

Definition at line 31 of file Attribute.hpp.

Member Typedef Documentation

◆ ConstMapResult

template<typename T >
template<int D = Eigen::Dynamic>
using wmtk::attribute::Attribute< T >::ConstMapResult = internal::ConstMapResult<T, D>

Definition at line 37 of file Attribute.hpp.

◆ MapResult

template<typename T >
template<int D = Eigen::Dynamic>
using wmtk::attribute::Attribute< T >::MapResult = internal::MapResult<T, D>

Definition at line 35 of file Attribute.hpp.

Constructor & Destructor Documentation

◆ Attribute() [1/2]

template<typename T >
wmtk::attribute::Attribute< T >::Attribute ( const std::string &  name,
int64_t  dimension,
default_value = T(0),
int64_t  size = 0 
)

Initialize the attribute.

Parameters
dimensionThe dimension of the attribute, e.g. 3 for a 3d vector.
default_valueA default value that is applied to every entry, also to new ones that are added later.
sizeThe number of expected indices. If size < 0 then the internal data is not initialized.

Definition at line 20 of file Attribute.cpp.

◆ Attribute() [2/2]

template<typename T >
wmtk::attribute::Attribute< T >::Attribute ( Attribute< T > &&  o)
default

◆ ~Attribute()

template<typename T >
wmtk::attribute::Attribute< T >::~Attribute ( )
default

Member Function Documentation

◆ child_hashes()

template<typename T >
std::map< std::string, size_t > wmtk::attribute::Attribute< T >::child_hashes
overridevirtual

Reimplemented from wmtk::utils::Hashable.

Definition at line 36 of file Attribute.cpp.

References wmtk::utils::vector_hash().

Here is the call graph for this function:

◆ consolidate()

template<typename T >
void wmtk::attribute::Attribute< T >::consolidate ( const std::vector< int64_t > &  new2old)

Consolidate the vector, using the new2old map m provided and resizing the vector to m.size()

Definition at line 91 of file Attribute.cpp.

◆ const_scalar_attribute() [1/4]

template<typename T >
T wmtk::attribute::Attribute< T >::const_scalar_attribute ( const int64_t  index) const
inline

Definition at line 269 of file Attribute.hpp.

◆ const_scalar_attribute() [2/4]

template<typename T >
T wmtk::attribute::Attribute< T >::const_scalar_attribute ( const int64_t  index,
const int8_t  offset 
) const
inline

Definition at line 295 of file Attribute.hpp.

◆ const_scalar_attribute() [3/4]

template<typename T >
T wmtk::attribute::Attribute< T >::const_scalar_attribute ( const int64_t  index,
const int8_t  offset,
const std::vector< T > &  data 
) const
inline

Accesses the attribute using the specified scalar as the underlying data This is internally used by the single-arg const_scalar_attribute and to help with serialization.

Definition at line 300 of file Attribute.hpp.

◆ const_scalar_attribute() [4/4]

template<typename T >
T wmtk::attribute::Attribute< T >::const_scalar_attribute ( const int64_t  index,
const std::vector< T > &  data 
) const
inline

Accesses the attribute using the specified scalar as the underlying data This is internally used by the single-arg const_scalar_attribute and to help with serialization.

Definition at line 274 of file Attribute.hpp.

◆ const_vector_attribute() [1/4]

template<typename T >
template<int D = Eigen::Dynamic>
ConstMapResult<D> wmtk::attribute::Attribute< T >::const_vector_attribute ( const int64_t  index) const

◆ const_vector_attribute() [2/4]

template<typename T >
template<int D>
auto wmtk::attribute::Attribute< T >::const_vector_attribute ( const int64_t  index) const -> ConstMapResult<D>
inline

Definition at line 192 of file Attribute.hpp.

◆ const_vector_attribute() [3/4]

template<typename T >
template<int D = Eigen::Dynamic>
ConstMapResult<D> wmtk::attribute::Attribute< T >::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 the single-arg const_vector_attribute and to help with serialization.

◆ const_vector_attribute() [4/4]

template<typename T >
template<int D>
auto wmtk::attribute::Attribute< T >::const_vector_attribute ( const int64_t  index,
const std::vector< T > &  data 
) const -> ConstMapResult<D>
inline

Definition at line 199 of file Attribute.hpp.

◆ const_vector_attribute_from_start() [1/2]

template<typename T >
template<int D = Eigen::Dynamic>
ConstMapResult<D> wmtk::attribute::Attribute< T >::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 the single-arg const_vector_attribute and to help with serialization.

Start allows for assignment to buffers that dont' represent a 2d array

Referenced by wmtk::attribute::internal::AttributeFlatCache< T >::apply_to(), and wmtk::attribute::internal::AttributeTransactionStack< T >::apply_to().

Here is the caller graph for this function:

◆ const_vector_attribute_from_start() [2/2]

template<typename T >
template<int D>
auto wmtk::attribute::Attribute< T >::const_vector_attribute_from_start ( const int64_t  start,
const std::vector< T > &  data 
) const -> ConstMapResult<D>
inline

Definition at line 209 of file Attribute.hpp.

◆ default_value()

template<typename T >
const T & wmtk::attribute::Attribute< T >::default_value
inline

returns the default value of this attribute

Definition at line 332 of file Attribute.hpp.

◆ dimension()

template<typename T >
int64_t wmtk::attribute::Attribute< T >::dimension
inline

The number of values for each index.

Definition at line 326 of file Attribute.hpp.

◆ get_local_scope_stack() [1/2]

template<typename T >
internal::AttributeTransactionStack< T > & wmtk::attribute::Attribute< T >::get_local_scope_stack
inline

Definition at line 343 of file Attribute.hpp.

◆ get_local_scope_stack() [2/2]

template<typename T >
const internal::AttributeTransactionStack< T > & wmtk::attribute::Attribute< T >::get_local_scope_stack
inline

Definition at line 338 of file Attribute.hpp.

◆ index_remap() [1/2]

template<typename T >
void wmtk::attribute::Attribute< T >::index_remap ( const std::vector< T > &  old2new)

Applies the scalar old2new map to the indices in the attribute This is commonly used after a consolidate to account for the change in global indices.

Definition at line 105 of file Attribute.cpp.

◆ index_remap() [2/2]

template<typename T >
void wmtk::attribute::Attribute< T >::index_remap ( const std::vector< T > &  old2new,
const std::vector< Eigen::Index > &  cols 
)

Definition at line 113 of file Attribute.cpp.

◆ operator=()

template<typename T >
Attribute< T > & wmtk::attribute::Attribute< T >::operator= ( Attribute< T > &&  o)
default

◆ operator==()

◆ pop_scope()

template<typename T >
void wmtk::attribute::Attribute< T >::pop_scope ( bool  apply_updates)
inline

Definition at line 354 of file Attribute.hpp.

◆ push_scope()

template<typename T >
void wmtk::attribute::Attribute< T >::push_scope
inline

Definition at line 349 of file Attribute.hpp.

◆ reserve()

template<typename T >
void wmtk::attribute::Attribute< T >::reserve ( const int64_t  size)

Definition at line 66 of file Attribute.cpp.

◆ reserved_size() [1/2]

template<typename T >
int64_t wmtk::attribute::Attribute< T >::reserved_size

The total number of elements in a vector.

This is greater than the number of active values in the attribute, and the set of active values is handled by a higher level abstraction

Definition at line 73 of file Attribute.cpp.

◆ reserved_size() [2/2]

template<typename T >
int64_t wmtk::attribute::Attribute< T >::reserved_size ( const std::vector< T > &  data) const

Definition at line 78 of file Attribute.cpp.

◆ rollback_current_scope()

template<typename T >
void wmtk::attribute::Attribute< T >::rollback_current_scope
inline

Definition at line 360 of file Attribute.hpp.

◆ scalar_attribute() [1/4]

template<typename T >
T & wmtk::attribute::Attribute< T >::scalar_attribute ( const int64_t  index)
inline

Definition at line 282 of file Attribute.hpp.

◆ scalar_attribute() [2/4]

template<typename T >
T & wmtk::attribute::Attribute< T >::scalar_attribute ( const int64_t  index,
const int8_t  offset 
)
inline

Definition at line 311 of file Attribute.hpp.

◆ scalar_attribute() [3/4]

template<typename T >
T & wmtk::attribute::Attribute< T >::scalar_attribute ( const int64_t  index,
const int8_t  offset,
std::vector< T > &  data 
) const
inline

Accesses the attribute using the specified scalar as the underlying data This is internally used by the single-arg scalar_attribute and to help with serialization.

Definition at line 317 of file Attribute.hpp.

◆ scalar_attribute() [4/4]

template<typename T >
T & wmtk::attribute::Attribute< T >::scalar_attribute ( const int64_t  index,
std::vector< T > &  data 
) const
inline

Accesses the attribute using the specified scalar as the underlying data This is internally used by the single-arg scalar_attribute and to help with serialization.

Definition at line 287 of file Attribute.hpp.

◆ serialize()

template<typename T >
void wmtk::attribute::Attribute< T >::serialize ( const std::string &  name,
const int  dim,
MeshWriter writer 
) const

Definition at line 12 of file Attribute.cpp.

References wmtk::MeshWriter::write().

Here is the call graph for this function:

◆ set()

template<typename T >
void wmtk::attribute::Attribute< T >::set ( std::vector< T >  val)

Replace the internal data with val.

Definition at line 84 of file Attribute.cpp.

◆ vector_attribute() [1/4]

template<typename T >
template<int D = Eigen::Dynamic>
MapResult<D> wmtk::attribute::Attribute< T >::vector_attribute ( const int64_t  index)

Referenced by wmtk::attribute::internal::AttributeFlatCache< T >::apply_to(), and wmtk::attribute::internal::AttributeTransactionStack< T >::apply_to().

Here is the caller graph for this function:

◆ vector_attribute() [2/4]

template<typename T >
template<int D>
auto wmtk::attribute::Attribute< T >::vector_attribute ( const int64_t  index) -> MapResult<D>
inline

Definition at line 227 of file Attribute.hpp.

◆ vector_attribute() [3/4]

template<typename T >
template<int D = Eigen::Dynamic>
MapResult<D> wmtk::attribute::Attribute< T >::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 the single-arg vector_attribute and to help with serialization.

◆ vector_attribute() [4/4]

template<typename T >
template<int D>
auto wmtk::attribute::Attribute< T >::vector_attribute ( const int64_t  index,
std::vector< T > &  data 
) const -> MapResult<D>
inline

Definition at line 243 of file Attribute.hpp.

◆ vector_attribute2() [1/2]

template<typename T >
template<int D = Eigen::Dynamic>
MapResult<D> wmtk::attribute::Attribute< T >::vector_attribute2 ( const int64_t  index)

◆ vector_attribute2() [2/2]

template<typename T >
template<int D>
auto wmtk::attribute::Attribute< T >::vector_attribute2 ( const int64_t  index) -> MapResult<D>
inline

Definition at line 235 of file Attribute.hpp.

◆ vector_attribute_from_start() [1/2]

template<typename T >
template<int D = Eigen::Dynamic>
MapResult<D> wmtk::attribute::Attribute< T >::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 the single-arg const_vector_attribute and to help with serialization.

Start allows for assignment to buffers that dont' represent a 2d array

◆ vector_attribute_from_start() [2/2]

template<typename T >
template<int D>
auto wmtk::attribute::Attribute< T >::vector_attribute_from_start ( const int64_t  start,
std::vector< T > &  data 
) const -> MapResult<D>
inline

Definition at line 254 of file Attribute.hpp.

Friends And Related Function Documentation

◆ AccessorBase

template<typename T >
template<typename U , int D>
friend class AccessorBase
friend

Definition at line 45 of file Attribute.hpp.

◆ internal::AttributeTransactionStack< T >

template<typename T >
friend class internal::AttributeTransactionStack< T >
friend

Definition at line 45 of file Attribute.hpp.

Member Data Documentation

◆ m_data

template<typename T >
std::vector<T> wmtk::attribute::Attribute< T >::m_data
private

◆ m_default_value

template<typename T >
T wmtk::attribute::Attribute< T >::m_default_value = T(0)
private

Definition at line 184 of file Attribute.hpp.

Referenced by wmtk::attribute::Attribute< T >::operator==().

◆ m_dimension

template<typename T >
int64_t wmtk::attribute::Attribute< T >::m_dimension = -1
private

Definition at line 183 of file Attribute.hpp.

Referenced by wmtk::attribute::Attribute< T >::operator==().

◆ m_name

template<typename T >
std::string wmtk::attribute::Attribute< T >::m_name

Definition at line 187 of file Attribute.hpp.

Referenced by wmtk::attribute::Attribute< T >::operator==().

◆ m_scope_stacks

template<typename T >
PerThreadAttributeScopeStacks<T> wmtk::attribute::Attribute< T >::m_scope_stacks
private

Definition at line 182 of file Attribute.hpp.


The documentation for this class was generated from the following files: