Wildmeshing Toolkit
Loading...
Searching...
No Matches
TupleAccessor.hxx
Go to the documentation of this file.
1
2#pragma once
4#include "TupleAccessor.hpp"
5
6namespace wmtk::attribute {
7
8
9template <typename MeshType, int Dim>
11 MeshType& m,
13 : m_base_accessor(m, handle)
14 , m_dimension(m_base_accessor.dimension() / (sizeof(Tuple) / sizeof(int64_t)))
15{}
16template <typename MeshType, int Dim>
18 const MeshType& m,
20 : TupleAccessor(const_cast<MeshType&>(m), handle)
21{}
22template <typename MeshType, int Dim>
23template <int Dim2>
25 const Accessor<int64_t, MeshType, CachingAttribute<int64_t>, Dim2>& accessor)
26 : TupleAccessor(accessor.mesh(), accessor.typed_handle())
27{
28 static_assert(Dim == Eigen::Dynamic || Dim2 == Eigen::Dynamic || Dim == Dim2);
29}
30
31template <typename MeshType, int Dim>
32template <int D>
34{
35 auto base_map = m_base_accessor.template const_vector_attribute<D>(t);
36
37 const int64_t* int_data = base_map.data();
38 const Tuple* data = reinterpret_cast<const Tuple*>(int_data);
39 return ConstMapResult<D>(data, dimension());
40}
41
42template <typename MeshType, int Dim>
43template <int D>
45{
46 auto base_map = m_base_accessor.template vector_attribute<D>(t);
47 int64_t* int_data = base_map.data();
48 Tuple* data = reinterpret_cast<Tuple*>(int_data);
49 return MapResult<D>(data, dimension());
50}
51
52template <typename MeshType, int Dim>
54{
55 auto base_map = m_base_accessor.template vector_attribute<2>(t);
56
57 assert(m_dimension == 1);
58 return *reinterpret_cast<Tuple*>(base_map.data());
59}
60
61template <typename MeshType, int Dim>
63{
64 assert(m_dimension == 1);
65 auto base_map = m_base_accessor.template const_vector_attribute<2>(t);
66 return *reinterpret_cast<const Tuple*>(base_map.data());
67}
68
69
70} // namespace wmtk::attribute
The Tuple is the basic navigation tool in our mesh data structure.
Definition Tuple.hpp:19
An Accessor that uses tuples for accessing attributes instead of indices.
Definition Accessor.hpp:28
const Tuple & const_scalar_attribute(const Tuple &t) const
TupleAccessor(MeshType &m, const TypedAttributeHandle< int64_t > &handle)
MapResult< Tuple, D > MapResult
ConstMapResult< Tuple, D > ConstMapResult
Tuple & scalar_attribute(const Tuple &t)
MapResult< D > vector_attribute(const Tuple &t)
ConstMapResult< D > const_vector_attribute(const Tuple &t) const
Handle that represents attributes for some mesh.