Wildmeshing Toolkit
AccessorBase.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <type_traits>
5 #include "internal/MapTypes.hpp"
6 
7 #include <Eigen/Dense>
8 
9 namespace wmtk {
10 class AttributeManager;
11 }
12 namespace wmtk::attribute {
13 
14 template <typename T>
15 class Attribute;
16 template <typename T, typename MeshType, int Dim>
17 class Accessor;
18 template <typename T>
19 class MeshAttributes;
20 template <typename T>
22 
23 // The basic implementation of an accessor using indices.
24 // This should never be externally used except within the main accessor
25 // interface, in unit tests, or in topological updates
26 template <typename _T, int Dim = Eigen::Dynamic>
28 {
29 public:
30  using T = _T;
31  friend class AccessorCache<T>;
33  template <typename U, typename MeshType, int D>
34  friend class Accessor;
36 
37  template <int D = Dim>
39  template <int D = Dim>
41 
42 
43 public:
44  // returns the size of the underlying attribute
45  int64_t reserved_size() const;
46  int64_t dimension() const;
47  const T& default_value() const;
48 
49 
50  void set_attribute(std::vector<T> value);
51 
52  template <int D = Dim>
53  ConstMapResult<D> const_vector_attribute(const int64_t index) const;
54  template <int D = Dim>
55  MapResult<D> vector_attribute(const int64_t index);
56 
57  T const_scalar_attribute(const int64_t index) const;
58  T& scalar_attribute(const int64_t index);
59 
60  T const_scalar_attribute(const int64_t index, const int8_t offset) const;
61  T& scalar_attribute(const int64_t index, const int8_t offset);
62 
64  const MeshAttributes<T>& attributes() const;
65 
67  const Attribute<T>& attribute() const;
68 
69 
73 
77 
78  Mesh& mesh();
79  const Mesh& mesh() const;
80 
81 
82 protected:
86 
87  const AttributeManager& attribute_manager() const;
89 };
90 
91 
92 } // namespace wmtk::attribute
93 #include "AccessorBase.hxx"
T const_scalar_attribute(const int64_t index) const
const T & default_value() const
MeshAttributes< T > & attributes()
AccessorBase(Mesh &m, const TypedAttributeHandle< T > &handle)
TypedAttributeHandle< T > m_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
A CachingAccessor that uses tuples for accessing attributes instead of indices.
Definition: Accessor.hpp:25
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.
typename VectorResult< T, R >::MapType MapResult
the default map type used by attributes is a map of our vector type.
Definition: MapTypes.hpp:21
typename VectorResult< T, R >::ConstMapType ConstMapResult
Definition: MapTypes.hpp:23
Definition: Accessor.hpp:6