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