Wildmeshing Toolkit
|
This class stores data of type T in a vector. More...
#include <Attribute.hpp>
Public Types | |
using | Scalar = T |
template<int D = Eigen::Dynamic> | |
using | MapResult = MapResult< T, D > |
template<int D = Eigen::Dynamic> | |
using | ConstMapResult = ConstMapResult< T, D > |
Public Member Functions | |
std::map< std::string, size_t > | child_hashes () const override |
void | serialize (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. | |
Attribute (Attribute &&o) | |
Attribute & | operator= (Attribute &&o) |
Attribute (const Attribute &o)=delete | |
Attribute & | operator= (const Attribute &&o)=delete |
~Attribute () override | |
template<int D = Eigen::Dynamic> | |
ConstMapResult< D > | const_vector_attribute (int64_t index) const |
Access the value of an attribute at a particular index. If the dimension of the attribute is known at compile time then the template parameter should be elided to improve performance. | |
template<int D = Eigen::Dynamic> | |
MapResult< D > | vector_attribute (int64_t index) |
Access the value of an attribute at a particular index. If the dimension of the attribute is known at compile time then the template parameter should be elided to improve performance. | |
const T & | const_scalar_attribute (int64_t index) const |
Access the value of a scalar attribute. | |
T & | scalar_attribute (int64_t index) |
Access the value of a scalar attribute. Assignment to the returned value will change the value. | |
template<int D = Eigen::Dynamic> | |
const T & | const_vector_single_value (int64_t index, int8_t vector_index) const |
Access a single entry in a vector attribute. TODO: this might not actually be more performant than. | |
template<int D = Eigen::Dynamic> | |
T & | vector_single_value (int64_t index, int8_t vector_index) |
Access to a single a single value of a scalr attribute. | |
void | set (std::vector< T > val) |
Replace the internal data with val . | |
int64_t | reserved_size () const |
The total number of elements in a vector. | |
int64_t | dimension () const |
The number of values for each index. | |
void | reserve (int64_t size) |
const T & | default_value () const |
returns the default value of this attribute | |
bool | operator== (const Attribute< T > &o) const |
void | consolidate (const std::vector< int64_t > &new2old) |
Consolidate the vector, using the new2old map m provided and resizing the vector to m.size() | |
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. | |
void | index_remap (const std::vector< T > &old2new, const std::vector< Eigen::Index > &cols) |
template<int D = Eigen::Dynamic> | |
ConstMapResult< D > | const_vector_attribute (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. | |
template<int D = Eigen::Dynamic> | |
ConstMapResult< D > | const_vector_attribute_without_stride (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. | |
template<int D = Eigen::Dynamic> | |
MapResult< D > | vector_attribute (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. | |
template<int D = Eigen::Dynamic> | |
MapResult< D > | vector_attribute_without_stride (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. | |
const T & | const_scalar_attribute (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. | |
T & | scalar_attribute (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. | |
template<int D = Eigen::Dynamic> | |
const T & | const_vector_single_value (int64_t index, int8_t vector_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_vector_single_value and to help with serialization. | |
template<int D = Eigen::Dynamic> | |
T & | vector_single_value (int64_t index, int8_t vector_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 vector_single_value and to help with serialization. | |
int64_t | reserved_size (const std::vector< T > &data) const |
const std::string & | name () const |
void | set_name (const std::string &name) |
template<int D> | |
WMTK_ATTRIBUTE_INLINE auto | const_vector_attribute_without_stride (int64_t start, const std::vector< T > &data) const -> ConstMapResult< D > |
template<int D> | |
WMTK_ATTRIBUTE_INLINE auto | vector_attribute_without_stride (int64_t start, std::vector< T > &data) const -> MapResult< D > |
template<int D> | |
WMTK_ATTRIBUTE_INLINE auto | const_vector_attribute (int64_t index, const std::vector< T > &data) const -> ConstMapResult< D > |
template<int D> | |
WMTK_ATTRIBUTE_INLINE auto | vector_attribute (int64_t index, std::vector< T > &data) const -> MapResult< D > |
template<int D> | |
WMTK_ATTRIBUTE_INLINE const T & | const_vector_single_value (int64_t index, int8_t vector_index, const std::vector< T > &data) const |
template<int D> | |
WMTK_ATTRIBUTE_INLINE T & | vector_single_value (int64_t index, int8_t vector_index, std::vector< T > &data) const |
template<int D> | |
WMTK_ATTRIBUTE_INLINE auto | const_vector_attribute (int64_t index) const -> ConstMapResult< D > |
template<int D> | |
WMTK_ATTRIBUTE_INLINE auto | vector_attribute (int64_t index) -> MapResult< D > |
template<int D> | |
WMTK_ATTRIBUTE_INLINE const T & | const_vector_single_value (int64_t index, int8_t vector_index) const |
template<int D> | |
WMTK_ATTRIBUTE_INLINE T & | vector_single_value (int64_t index, int8_t vector_index) |
![]() | |
Hashable () | |
Hashable (const Hashable &) | |
Hashable (Hashable &&) | |
Hashable & | operator= (const Hashable &) |
Hashable & | operator= (Hashable &&) |
virtual | ~Hashable () |
virtual std::size_t | hash () const |
Protected Attributes | |
std::vector< T > | m_data |
int64_t | m_dimension = -1 |
T | m_default_value = T(0) |
std::string | m_name |
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 21 of file Attribute.hpp.
using wmtk::attribute::Attribute< T >::ConstMapResult = ConstMapResult<T, D> |
Definition at line 29 of file Attribute.hpp.
using wmtk::attribute::Attribute< T >::MapResult = MapResult<T, D> |
Definition at line 27 of file Attribute.hpp.
using wmtk::attribute::Attribute< T >::Scalar = T |
Definition at line 24 of file Attribute.hpp.
wmtk::attribute::Attribute< T >::Attribute | ( | const std::string & | name, |
int64_t | dimension, | ||
T | default_value = T(0) , |
||
int64_t | size = 0 |
||
) |
Initialize the attribute.
name | The name of the attribute (used for debugging) |
dimension | The dimension of the attribute, e.g. 3 for a 3d vector. |
default_value | A default value that is applied to every entry, also to new ones that are added later. |
size | The number of expected indices. If size < 0 then the internal data is not initialized. |
Definition at line 18 of file Attribute.cpp.
References wmtk::attribute::Attribute< T >::m_dimension, and wmtk::attribute::Attribute< T >::reserve().
|
default |
|
delete |
|
overridedefault |
|
overridevirtual |
Reimplemented from wmtk::utils::Hashable.
Definition at line 31 of file Attribute.cpp.
References wmtk::utils::vector_hash().
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 93 of file Attribute.cpp.
WMTK_ATTRIBUTE_INLINE const T & wmtk::attribute::Attribute< T >::const_scalar_attribute | ( | int64_t | index | ) | const |
Access the value of a scalar attribute.
Definition at line 126 of file Attribute.hxx.
WMTK_ATTRIBUTE_INLINE const T & wmtk::attribute::Attribute< T >::const_scalar_attribute | ( | 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.
Definition at line 14 of file Attribute.hxx.
ConstMapResult< D > wmtk::attribute::Attribute< T >::const_vector_attribute | ( | int64_t | index | ) | const |
Access the value of an attribute at a particular index. If the dimension of the attribute is known at compile time then the template parameter should be elided to improve performance.
WMTK_ATTRIBUTE_INLINE auto wmtk::attribute::Attribute< T >::const_vector_attribute | ( | int64_t | index | ) | const -> ConstMapResult<D> |
Definition at line 142 of file Attribute.hxx.
ConstMapResult< D > wmtk::attribute::Attribute< T >::const_vector_attribute | ( | 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.
WMTK_ATTRIBUTE_INLINE auto wmtk::attribute::Attribute< T >::const_vector_attribute | ( | int64_t | index, |
const std::vector< T > & | data | ||
) | const -> ConstMapResult<D> |
Definition at line 68 of file Attribute.hxx.
ConstMapResult< D > wmtk::attribute::Attribute< T >::const_vector_attribute_without_stride | ( | 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
WMTK_ATTRIBUTE_INLINE auto wmtk::attribute::Attribute< T >::const_vector_attribute_without_stride | ( | int64_t | start, |
const std::vector< T > & | data | ||
) | const -> ConstMapResult<D> |
Definition at line 36 of file Attribute.hxx.
const T & wmtk::attribute::Attribute< T >::const_vector_single_value | ( | int64_t | index, |
int8_t | vector_index | ||
) | const |
Access a single entry in a vector attribute. TODO: this might not actually be more performant than.
WMTK_ATTRIBUTE_INLINE const T & wmtk::attribute::Attribute< T >::const_vector_single_value | ( | int64_t | index, |
int8_t | vector_index | ||
) | const |
Definition at line 162 of file Attribute.hxx.
const T & wmtk::attribute::Attribute< T >::const_vector_single_value | ( | int64_t | index, |
int8_t | vector_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_vector_single_value and to help with serialization.
WMTK_ATTRIBUTE_INLINE const T & wmtk::attribute::Attribute< T >::const_vector_single_value | ( | int64_t | index, |
int8_t | vector_index, | ||
const std::vector< T > & | data | ||
) | const |
Definition at line 98 of file Attribute.hxx.
WMTK_ATTRIBUTE_INLINE const T & wmtk::attribute::Attribute< T >::default_value | ( | ) | const |
returns the default value of this attribute
Definition at line 187 of file Attribute.hxx.
WMTK_ATTRIBUTE_INLINE int64_t wmtk::attribute::Attribute< T >::dimension | ( | ) | const |
The number of values for each index.
Definition at line 181 of file Attribute.hxx.
Referenced by wmtk::attribute::TypedAttributeManager< T >::dimension().
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 107 of file Attribute.cpp.
void wmtk::attribute::Attribute< T >::index_remap | ( | const std::vector< T > & | old2new, |
const std::vector< Eigen::Index > & | cols | ||
) |
Definition at line 115 of file Attribute.cpp.
const std::string & wmtk::attribute::Attribute< T >::name | ( | ) | const |
Definition at line 79 of file Attribute.cpp.
Referenced by wmtk::attribute::Attribute< T >::set_name().
|
default |
|
delete |
bool wmtk::attribute::Attribute< T >::operator== | ( | const Attribute< T > & | o | ) | const |
Definition at line 53 of file Attribute.cpp.
References wmtk::attribute::Attribute< T >::m_data, wmtk::attribute::Attribute< T >::m_default_value, wmtk::attribute::Attribute< T >::m_dimension, and wmtk::attribute::Attribute< T >::m_name.
void wmtk::attribute::Attribute< T >::reserve | ( | int64_t | size | ) |
Definition at line 61 of file Attribute.cpp.
Referenced by wmtk::attribute::Attribute< T >::Attribute().
int64_t wmtk::attribute::Attribute< T >::reserved_size | ( | ) | const |
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 68 of file Attribute.cpp.
int64_t wmtk::attribute::Attribute< T >::reserved_size | ( | const std::vector< T > & | data | ) | const |
Definition at line 73 of file Attribute.cpp.
WMTK_ATTRIBUTE_INLINE T & wmtk::attribute::Attribute< T >::scalar_attribute | ( | int64_t | index | ) |
Access the value of a scalar attribute. Assignment to the returned value will change the value.
Definition at line 131 of file Attribute.hxx.
WMTK_ATTRIBUTE_INLINE T & wmtk::attribute::Attribute< T >::scalar_attribute | ( | 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.
Definition at line 24 of file Attribute.hxx.
void wmtk::attribute::Attribute< T >::serialize | ( | int | dim, |
MeshWriter & | writer | ||
) | const |
Definition at line 11 of file Attribute.cpp.
References wmtk::MeshWriter::write().
void wmtk::attribute::Attribute< T >::set | ( | std::vector< T > | val | ) |
Replace the internal data with val
.
Definition at line 86 of file Attribute.cpp.
|
inline |
Definition at line 184 of file Attribute.hpp.
References wmtk::attribute::Attribute< T >::m_name, and wmtk::attribute::Attribute< T >::name().
MapResult< D > wmtk::attribute::Attribute< T >::vector_attribute | ( | int64_t | index | ) |
Access the value of an attribute at a particular index. If the dimension of the attribute is known at compile time then the template parameter should be elided to improve performance.
WMTK_ATTRIBUTE_INLINE auto wmtk::attribute::Attribute< T >::vector_attribute | ( | int64_t | index | ) | -> MapResult<D> |
Definition at line 151 of file Attribute.hxx.
MapResult< D > wmtk::attribute::Attribute< T >::vector_attribute | ( | 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.
WMTK_ATTRIBUTE_INLINE auto wmtk::attribute::Attribute< T >::vector_attribute | ( | int64_t | index, |
std::vector< T > & | data | ||
) | const -> MapResult<D> |
Definition at line 81 of file Attribute.hxx.
MapResult< D > wmtk::attribute::Attribute< T >::vector_attribute_without_stride | ( | 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
WMTK_ATTRIBUTE_INLINE auto wmtk::attribute::Attribute< T >::vector_attribute_without_stride | ( | int64_t | start, |
std::vector< T > & | data | ||
) | const -> MapResult<D> |
Definition at line 51 of file Attribute.hxx.
T & wmtk::attribute::Attribute< T >::vector_single_value | ( | int64_t | index, |
int8_t | vector_index | ||
) |
Access to a single a single value of a scalr attribute.
WMTK_ATTRIBUTE_INLINE T & wmtk::attribute::Attribute< T >::vector_single_value | ( | int64_t | index, |
int8_t | vector_index | ||
) |
Definition at line 171 of file Attribute.hxx.
T & wmtk::attribute::Attribute< T >::vector_single_value | ( | int64_t | index, |
int8_t | vector_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 vector_single_value and to help with serialization.
WMTK_ATTRIBUTE_INLINE T & wmtk::attribute::Attribute< T >::vector_single_value | ( | int64_t | index, |
int8_t | vector_index, | ||
std::vector< T > & | data | ||
) | const |
Definition at line 112 of file Attribute.hxx.
|
protected |
Definition at line 187 of file Attribute.hpp.
Referenced by wmtk::attribute::Attribute< T >::operator==().
|
protected |
Definition at line 189 of file Attribute.hpp.
Referenced by wmtk::attribute::Attribute< T >::operator==().
|
protected |
Definition at line 188 of file Attribute.hpp.
Referenced by wmtk::attribute::Attribute< T >::Attribute(), and wmtk::attribute::Attribute< T >::operator==().
|
protected |
Definition at line 191 of file Attribute.hpp.
Referenced by wmtk::attribute::Attribute< T >::operator==(), and wmtk::attribute::Attribute< T >::set_name().