Wildmeshing Toolkit
Loading...
Searching...
No Matches
CachingAccessor.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <optional>
4#include "AccessorBase.hpp"
5
6namespace wmtk {
7class Mesh;
8class TetMesh;
9class TriMesh;
10} // namespace wmtk
11namespace wmtk::attribute {
12
13
18template <typename T, int Dim = Eigen::Dynamic>
19class CachingAccessor : public AccessorBase<T, Dim>
20{
21public:
22 friend class wmtk::Mesh;
23 friend class wmtk::TetMesh;
24 friend class wmtk::TriMesh;
25 using Scalar = T;
26
28
29 template <int D = Dim>
31 typename BaseType::template ConstMapResult<D>; // Eigen::Map<const VectorX<T>>
32 template <int D = Dim>
33 using MapResult = typename BaseType::template MapResult<D>; // Eigen::Map<VectorX<T>>
34
35
38
44
45
46 // returns the size of the underlying attribute
47
48 //using BaseType::dimension; // const() -> int64_t
49 //using BaseType::reserved_size; // const() -> int64_t
50
51 //using BaseType::attribute; // access to Attribute object being used here
52 //using BaseType::set_attribute; // (const vector<T>&) -> void
53 // shows the depth of scope stacks if they exist, mostly for debug
54 int64_t stack_depth() const;
55
56 bool has_stack() const;
57
58 template <int D = Dim>
59 ConstMapResult<D> const_vector_attribute(const int64_t index) const;
60
61 T const_scalar_attribute(const int64_t index) const;
62 T const_scalar_attribute(const int64_t index, const int8_t offset) const;
63
64 template <int D = Dim>
65 MapResult<D> vector_attribute(const int64_t index);
66
67 T& scalar_attribute(const int64_t index);
68 T& scalar_attribute(const int64_t index, const int8_t offset);
69
70 // deprecated because we should be more explicit in const/nonconst on internal interfaces
71 ConstMapResult<> vector_attribute(const int64_t index) const;
72 // deprecated because we should be more explicit in const/nonconst on internal interfaces
73 T scalar_attribute(const int64_t index) const;
74
76 using BaseType::mesh;
77
78 bool writing_enabled() const;
79
80protected:
81 BaseType& base_type() { return *this; }
82 const BaseType& base_type() const { return *this; }
83
84private:
86};
87} // namespace wmtk::attribute
88#include "CachingAccessor.hxx"
MeshAttributeHandle handle() const
An accessor for cached attribute values.
typename BaseType::template MapResult< D > MapResult
typename BaseType::template ConstMapResult< D > ConstMapResult
const BaseType & base_type() const
T const_scalar_attribute(const int64_t index) const
CachingAccessor(CachingAccessor &&)=default
T & scalar_attribute(const int64_t index)
CachingAccessor & operator=(CachingAccessor &&)=default
internal::AttributeTransactionStack< T > & m_cache_stack
ConstMapResult< D > const_vector_attribute(const int64_t index) const
MapResult< D > vector_attribute(const int64_t index)
CachingAccessor(const CachingAccessor &)=delete
CachingAccessor & operator=(const CachingAccessor &)=delete
Handle that represents attributes for some mesh.