Wildmeshing Toolkit
TupleAccessor.hxx
Go to the documentation of this file.
1 
2 #pragma once
4 #include "TupleAccessor.hpp"
5 
6 namespace wmtk::attribute {
7 
8 
9 template <typename MeshType, int Dim>
11  : m_base_accessor(m, handle)
12  , m_dimension(m_base_accessor.dimension() / (sizeof(Tuple) / sizeof(int64_t)))
13 {}
14 template <typename MeshType, int Dim>
16  const MeshType& m,
17  const TypedAttributeHandle<int64_t>& handle)
18  : TupleAccessor(const_cast<MeshType&>(m), handle)
19 {}
20 template <typename MeshType, int Dim>
21 template <int Dim2>
23  : TupleAccessor(accessor.mesh(), accessor.typed_handle())
24 {
25  static_assert(Dim == Eigen::Dynamic || Dim2 == Eigen::Dynamic || Dim == Dim2);
26 }
27 
28 template <typename MeshType, int Dim>
29 template <int D>
31 {
32  auto base_map = m_base_accessor.template const_vector_attribute<D>(t);
33 
34  const int64_t* int_data = base_map.data();
35  const Tuple* data = reinterpret_cast<const Tuple*>(int_data);
36  return ConstMapResult<D>(data, dimension());
37 }
38 
39 template <typename MeshType, int Dim>
40 template <int D>
42 {
43  auto base_map = m_base_accessor.template vector_attribute<D>(t);
44  int64_t* int_data = base_map.data();
45  Tuple* data = reinterpret_cast<Tuple*>(int_data);
46  return MapResult<D>(data, dimension());
47 }
48 
49 template <typename MeshType, int Dim>
51 {
52  auto base_map = m_base_accessor.template vector_attribute<2>(t);
53 
54  assert(m_dimension == 1);
55  return *reinterpret_cast<Tuple*>(base_map.data());
56 }
57 
58 template <typename MeshType, int Dim>
60 {
61  assert(m_dimension == 1);
62  auto base_map = m_base_accessor.template const_vector_attribute<2>(t);
63  return *reinterpret_cast<const Tuple*>(base_map.data());
64 }
65 
66 
67 } // namespace wmtk::attribute
A CachingAccessor that uses tuples for accessing attributes instead of indices.
Definition: Accessor.hpp:25
ConstMapResult< D > const_vector_attribute(const Tuple &t) const
const Tuple & const_scalar_attribute(const Tuple &t) const
internal::ConstMapResult< Tuple, D > ConstMapResult
MapResult< D > vector_attribute(const Tuple &t)
TupleAccessor(MeshType &m, const TypedAttributeHandle< int64_t > &handle)
Tuple & scalar_attribute(const Tuple &t)
internal::MapResult< Tuple, D > MapResult