Wildmeshing Toolkit
Accessor.hpp
Go to the documentation of this file.
1 #pragma once
2 #include "CachingAccessor.hpp"
5 
6 namespace wmtk {
7 class Mesh;
8 class TriMesh;
9 class TetMesh;
10 class TriMeshOperationExecutor;
11 class EdgeMesh;
12 namespace tests {
13 class DEBUG_TriMesh;
14 class DEBUG_EdgeMesh;
15 } // namespace tests
16 } // namespace wmtk
17 namespace wmtk::attribute {
23 template <typename T, typename MeshType = Mesh, int Dim = Eigen::Dynamic>
24 class Accessor : protected CachingAccessor<T, Dim>
25 {
26 public:
27  friend class wmtk::Mesh;
28  friend class wmtk::TetMesh;
29  friend class wmtk::TriMesh;
30  friend class wmtk::EdgeMesh;
31  friend class wmtk::PointMesh;
32  using Scalar = T;
33 
36 
37  // Eigen::Map<VectorX<T>>
38  template <int D = Dim>
40  // Eigen::Map<const VectorX<T>>
41  template <int D = Dim>
43 
44 
45  Accessor(MeshType& m, const TypedAttributeHandle<T>& handle);
46  Accessor(const MeshType& m, const TypedAttributeHandle<T>& handle);
47 
48  template <typename OMType, int D>
50 
51 
52  // =============
53  // Access methods
54  // =============
55  // NOTE: If any compilation warnings occur check that there is an overload for an index method
56 
58  template <typename ArgType>
59  T& topological_scalar_attribute(const ArgType& t);
60  template <typename ArgType>
61  T const_scalar_attribute(const ArgType& t) const;
62  template <typename ArgType>
63  T& scalar_attribute(const ArgType& t);
64 
65  template < int D = Dim, typename ArgType = wmtk::Tuple>
66  ConstMapResult<D> const_vector_attribute(const ArgType& t) const;
67  template < int D = Dim, typename ArgType = wmtk::Tuple>
68  MapResult<D> vector_attribute(const ArgType& t);
69 
70  using BaseType::dimension; // const() -> int64_t
71  using BaseType::reserved_size; // const() -> int64_t
72 
73  using BaseType::attribute; // access to Attribute object being used here
74  using BaseType::handle;
80 
81  MeshType& mesh() { return static_cast<MeshType&>(BaseType::mesh()); }
82  const MeshType& mesh() const { return static_cast<const MeshType&>(BaseType::mesh()); }
83 
84 protected:
85 
86  int64_t index(const Tuple& t) const;
87  int64_t index(const simplex::Simplex& t) const;
88  int64_t index(const simplex::IdSimplex& t) const;
89 
91  CachingBaseType& caching_base_type() { return *this; }
92  const CachingBaseType& caching_base_type() const { return *this; }
93 
94 public:
96  const CachingBaseType& index_access() const { return caching_base_type(); }
97 };
98 } // namespace wmtk::attribute
99 #include "Accessor.hxx"
const TypedAttributeHandle< T > & typed_handle() const
MeshAttributeHandle handle() const
PrimitiveType primitive_type() const
Attribute< T > & attribute()
A CachingAccessor that uses tuples for accessing attributes instead of indices.
Definition: Accessor.hpp:25
int64_t index(const Tuple &t) const
Definition: Accessor.hxx:63
const CachingBaseType & index_access() const
Definition: Accessor.hpp:96
CachingBaseType & index_access()
Definition: Accessor.hpp:95
MapResult< D > vector_attribute(const ArgType &t)
MeshAttributeHandle handle() const
T & topological_scalar_attribute(const ArgType &t)
T & scalar_attribute(const ArgType &t)
T const_scalar_attribute(const ArgType &t) const
Definition: Accessor.hxx:112
T const_topological_scalar_attribute(const Tuple &t, PrimitiveType pt) const
Definition: Accessor.hxx:129
internal::MapResult< T, D > MapResult
Definition: Accessor.hpp:39
const MeshType & mesh() const
Definition: Accessor.hpp:82
CachingBaseType & caching_base_type()
Definition: Accessor.hpp:91
internal::ConstMapResult< T, D > ConstMapResult
Definition: Accessor.hpp:42
const CachingBaseType & caching_base_type() const
Definition: Accessor.hpp:92
ConstMapResult< D > const_vector_attribute(const ArgType &t) const
An accessor for cached attribute values.
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