Wildmeshing Toolkit
Loading...
Searching...
No Matches
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

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)
 
Attributeoperator= (Attribute &&o)
 
 Attribute (const Attribute &o)=delete
 
Attributeoperator= (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)
 
- 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
 

Protected Attributes

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

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 21 of file Attribute.hpp.

Member Typedef Documentation

◆ ConstMapResult

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

Definition at line 29 of file Attribute.hpp.

◆ MapResult

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

Definition at line 27 of file Attribute.hpp.

◆ Scalar

template<typename T >
using wmtk::attribute::Attribute< T >::Scalar = T

Definition at line 24 of file Attribute.hpp.

Constructor & Destructor Documentation

◆ Attribute() [1/3]

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
nameThe name of the attribute (used for debugging)
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 18 of file Attribute.cpp.

References wmtk::attribute::Attribute< T >::m_dimension, and wmtk::attribute::Attribute< T >::reserve().

Here is the call graph for this function:

◆ Attribute() [2/3]

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

◆ Attribute() [3/3]

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

◆ ~Attribute()

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

Member Function Documentation

◆ child_hashes()

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

Reimplemented from wmtk::utils::Hashable.

Definition at line 31 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 93 of file Attribute.cpp.

◆ const_scalar_attribute() [1/2]

template<typename T >
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.

◆ const_scalar_attribute() [2/2]

template<typename T >
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.

◆ const_vector_attribute() [1/4]

template<typename T >
template<int D = Eigen::Dynamic>
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.

◆ const_vector_attribute() [2/4]

template<typename T >
template<int D>
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.

◆ const_vector_attribute() [3/4]

template<typename T >
template<int D = Eigen::Dynamic>
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.

◆ const_vector_attribute() [4/4]

template<typename T >
template<int D>
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.

◆ const_vector_attribute_without_stride() [1/2]

template<typename T >
template<int D = Eigen::Dynamic>
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

◆ const_vector_attribute_without_stride() [2/2]

template<typename T >
template<int D>
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_vector_single_value() [1/4]

template<typename T >
template<int D = Eigen::Dynamic>
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.

◆ const_vector_single_value() [2/4]

template<typename T >
template<int D>
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_vector_single_value() [3/4]

template<typename T >
template<int D = Eigen::Dynamic>
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.

◆ const_vector_single_value() [4/4]

template<typename T >
template<int D>
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.

◆ default_value()

template<typename T >
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.

◆ dimension()

template<typename T >
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().

Here is the caller graph for this function:

◆ 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 107 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 115 of file Attribute.cpp.

◆ name()

template<typename T >
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().

Here is the caller graph for this function:

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ operator==()

◆ reserve()

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

Definition at line 61 of file Attribute.cpp.

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

Here is the caller graph for this function:

◆ reserved_size() [1/2]

template<typename T >
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.

◆ reserved_size() [2/2]

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

Definition at line 73 of file Attribute.cpp.

◆ scalar_attribute() [1/2]

template<typename T >
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.

◆ scalar_attribute() [2/2]

template<typename T >
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.

◆ serialize()

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

Definition at line 11 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 86 of file Attribute.cpp.

◆ set_name()

template<typename T >
void wmtk::attribute::Attribute< T >::set_name ( const std::string &  name)
inline

Definition at line 184 of file Attribute.hpp.

References wmtk::attribute::Attribute< T >::m_name, and wmtk::attribute::Attribute< T >::name().

Here is the call graph for this function:

◆ vector_attribute() [1/4]

template<typename T >
template<int D = Eigen::Dynamic>
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.

◆ vector_attribute() [2/4]

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

Definition at line 151 of file Attribute.hxx.

◆ vector_attribute() [3/4]

template<typename T >
template<int D = Eigen::Dynamic>
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.

◆ vector_attribute() [4/4]

template<typename T >
template<int D>
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.

◆ vector_attribute_without_stride() [1/2]

template<typename T >
template<int D = Eigen::Dynamic>
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

◆ vector_attribute_without_stride() [2/2]

template<typename T >
template<int D>
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.

◆ vector_single_value() [1/4]

template<typename T >
template<int D = Eigen::Dynamic>
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.

◆ vector_single_value() [2/4]

template<typename T >
template<int D>
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.

◆ vector_single_value() [3/4]

template<typename T >
template<int D = Eigen::Dynamic>
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.

◆ vector_single_value() [4/4]

template<typename T >
template<int D>
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.

Member Data Documentation

◆ m_data

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

Definition at line 187 of file Attribute.hpp.

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

◆ m_default_value

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

Definition at line 189 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
protected

◆ m_name

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

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