Wildmeshing Toolkit
Loading...
Searching...
No Matches
Accessor.hxx
Go to the documentation of this file.
1#pragma once
3#include "Accessor.hpp"
4
5namespace wmtk::attribute {
6
7template <typename T, typename MeshType, int Dim>
11template <typename T, typename MeshType, int Dim>
15template <typename T, typename MeshType, int Dim>
16template <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/*
24template <typename T, typename MeshType, int Dim>
25template <int D>
26auto 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
32template <typename T, typename MeshType, int Dim>
33template <int D>
34auto 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
40template <typename T, typename MeshType, int Dim>
41auto 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
47template <typename T, typename MeshType, int Dim>
48T Accessor<T, MeshType, Dim>::const_scalar_attribute(const Tuple& t) const
50 const int64_t idx = this->index(t);
51 return CachingBaseType::const_scalar_attribute(idx);
53
54template <typename T, typename MeshType, int Dim>
55auto 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
62template <typename T, typename MeshType, int Dim>
65 assert(mesh().is_valid(t));
66 return this->mesh().id(t, BaseType::typed_handle().primitive_type());
67}
68
69template <typename T, typename MeshType, int Dim>
71{
72 assert(t.primitive_type() == primitive_type());
73 return this->index(t.tuple());
74}
75
76template <typename T, typename MeshType, int Dim>
78{
79 assert(t.primitive_type() == primitive_type());
80 return this->mesh().id(t);
81}
82
83template <typename T, typename MeshType, int Dim>
84template <int D, typename ArgType>
86{
87 const int64_t idx = this->index(t);
88 return CachingBaseType::template const_vector_attribute<D>(idx);
91template <typename T, typename MeshType, int Dim>
92template <int D, typename ArgType>
94{
95 const int64_t idx = this->index(t);
96 return CachingBaseType::template vector_attribute<D>(idx);
97}
98
99template <typename T, typename MeshType, int Dim>
100template <typename ArgType>
102{
103 const int64_t idx = this->index(t);
104 return CachingBaseType::scalar_attribute(idx);
105}
106
107template <typename T, typename MeshType, int Dim>
108template <typename ArgType>
110{
111 const int64_t idx = this->index(t);
112 return CachingBaseType::const_scalar_attribute(idx);
113}
114template <typename T, typename MeshType, int Dim>
115template <typename ArgType>
117{
118 const int64_t idx = this->index(t);
119 return CachingBaseType::scalar_attribute(idx);
120}
121
122
123template <typename T, typename MeshType, int Dim>
125 const
126{
127 assert(mesh().top_simplex_type() == BaseType::primitive_type());
128 switch (pt) {
130 return CachingBaseType::const_scalar_attribute(t.global_cid(), t.local_vid());
132 return CachingBaseType::const_scalar_attribute(t.global_cid(), t.local_eid());
134 return CachingBaseType::const_scalar_attribute(t.global_cid(), t.local_fid());
135 case PrimitiveType::Tetrahedron: [[fallthrough]];
136 default: return T(0);
137 }
138}
139// template class Accessor<char>;
140// template class Accessor<int64_t>;
141// template class Accessor<double>;
142// template class Accessor<Rational>;
143} // namespace wmtk::attribute
The Tuple is the basic navigation tool in our mesh data structure.
Definition Tuple.hpp:19
int8_t local_vid() const
Definition Tuple.hxx:52
int8_t local_fid() const
Definition Tuple.hxx:62
int8_t local_eid() const
Definition Tuple.hxx:57
int64_t global_cid() const
Definition Tuple.hxx:47
A CachingAccessor that uses tuples for accessing attributes instead of indices.
Definition Accessor.hpp:28
T & scalar_attribute(const ArgType &t)
int64_t index(const Tuple &t) const
Definition Accessor.hxx:63
T const_scalar_attribute(const ArgType &t) const
Definition Accessor.hxx:109
T const_topological_scalar_attribute(const Tuple &t, PrimitiveType pt) const
Definition Accessor.hxx:124
internal::MapResult< T, D > MapResult
Definition Accessor.hpp:42
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
An accessor for cached attribute values.
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