Wildmeshing Toolkit
Accessor.hxx
Go to the documentation of this file.
1 #pragma once
3 #include "Accessor.hpp"
4 
5 namespace wmtk::attribute {
6 
7 template <typename T, typename MeshType, int Dim>
9  : CachingBaseType(m, h)
10 {}
11 template <typename T, typename MeshType, int Dim>
13  : CachingBaseType(m, h)
14 {}
15 template <typename T, typename MeshType, int Dim>
16 template <typename OMType, int D>
18  : Accessor(static_cast<const MeshType&>(o.mesh()), o.handle())
19 {
20  static_assert(Dim == Eigen::Dynamic || D == Eigen::Dynamic || Dim == D);
21 }
22 
23 /*
24 template <typename T, typename MeshType, int Dim>
25 template <int D>
26 auto Accessor<T, MeshType, Dim>::const_vector_attribute(const Tuple& t) const -> ConstMapResult<D>
27 {
28  const int64_t idx = this->index(t);
29  return CachingBaseType::template const_vector_attribute<D>(idx);
30 }
31 
32 template <typename T, typename MeshType, int Dim>
33 template <int D>
34 auto Accessor<T, MeshType, Dim>::vector_attribute(const Tuple& t) -> MapResult<D>
35 {
36  const int64_t idx = this->index(t);
37  return CachingBaseType::template vector_attribute<D>(idx);
38 }
39 
40 template <typename T, typename MeshType, int Dim>
41 auto Accessor<T, MeshType, Dim>::scalar_attribute(const Tuple& t) -> T&
42 {
43  const int64_t idx = this->index(t);
44  return CachingBaseType::scalar_attribute(idx);
45 }
46 
47 template <typename T, typename MeshType, int Dim>
48 T Accessor<T, MeshType, Dim>::const_scalar_attribute(const Tuple& t) const
49 {
50  const int64_t idx = this->index(t);
51  return CachingBaseType::const_scalar_attribute(idx);
52 }
53 
54 template <typename T, typename MeshType, int Dim>
55 auto Accessor<T, MeshType, Dim>::topological_scalar_attribute(const Tuple& t) -> T&
56 {
57  const int64_t idx = this->index(t);
58  return CachingBaseType::scalar_attribute(idx);
59 }
60 */
61 
62 template <typename T, typename MeshType, int Dim>
64 {
65  assert(mesh().is_valid(t));
66  return this->mesh().id(t, BaseType::typed_handle().primitive_type());
67 }
68 
69 template <typename T, typename MeshType, int Dim>
71 {
72  assert(t.primitive_type() == primitive_type());
73  return this->index(t.tuple());
74 
75 }
76 
77 template <typename T, typename MeshType, int Dim>
79 {
80  assert(t.primitive_type() == primitive_type());
81  return this->mesh().id(t);
82 
83 }
84 
85 template <typename T, typename MeshType, int Dim>
86 template <int D, typename ArgType>
89 {
90  const int64_t idx = this->index(t);
91  return CachingBaseType::template const_vector_attribute<D>(idx);
92 }
93 
94 template <typename T, typename MeshType, int Dim>
95 template <int D, typename ArgType>
97 {
98  const int64_t idx = this->index(t);
99  return CachingBaseType::template vector_attribute<D>(idx);
100 }
101 
102 template <typename T, typename MeshType, int Dim>
103 template <typename ArgType>
105 {
106  const int64_t idx = this->index(t);
107  return CachingBaseType::scalar_attribute(idx);
108 }
109 
110 template <typename T, typename MeshType, int Dim>
111 template <typename ArgType>
113 {
114  const int64_t idx = this->index(t);
115  return CachingBaseType::const_scalar_attribute(idx);
116 }
117 template <typename T, typename MeshType, int Dim>
118 template <typename ArgType>
120 {
121  const int64_t idx = this->index(t);
122  return CachingBaseType::scalar_attribute(idx);
123 }
124 
125 
126 
127 
128 template <typename T, typename MeshType, int Dim>
130  const
131 {
132  assert(mesh().top_simplex_type() == BaseType::primitive_type());
133  switch (pt) {
135  return CachingBaseType::const_scalar_attribute(t.m_global_cid, t.m_local_vid);
136  case PrimitiveType::Edge:
137  return CachingBaseType::const_scalar_attribute(t.m_global_cid, t.m_local_eid);
139  return CachingBaseType::const_scalar_attribute(t.m_global_cid, t.m_local_fid);
140  case PrimitiveType::Tetrahedron: [[fallthrough]];
141  default: return T(0);
142  }
143 }
144 // template class Accessor<char>;
145 // template class Accessor<int64_t>;
146 // template class Accessor<double>;
147 // template class Accessor<Rational>;
148 } // namespace wmtk::attribute
int8_t m_local_vid
Definition: Tuple.hpp:47
int8_t m_local_eid
Definition: Tuple.hpp:48
int64_t m_global_cid
Definition: Tuple.hpp:46
int8_t m_local_fid
Definition: Tuple.hpp:49
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
MapResult< D > vector_attribute(const ArgType &t)
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
ConstMapResult< D > const_vector_attribute(const ArgType &t) const
An accessor for cached attribute values.
typename BaseType::template ConstMapResult< D > ConstMapResult
Handle that represents attributes for some mesh.
PrimitiveType primitive_type() const
Definition: IdSimplex.hpp:23
const Tuple & tuple() const
Definition: Simplex.hpp:53
PrimitiveType primitive_type() const
Definition: Simplex.hpp:51