Wildmeshing Toolkit
Loading...
Searching...
No Matches
CompoundAccessor.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <bitset>
5
6
8
9template <size_t N, typename MeshType, typename... AttributeType>
11{
12public:
13 using Type = std::tuple<AttributeType...>;
14 CompoundAccessor(MeshType& m, const TypedAttributeHandle<AttributeType>&... handle);
15 CompoundAccessor(const MeshType& m, const TypedAttributeHandle<AttributeType>&... handle);
16 template <typename FirstAcc, int FirstDim, typename... AccTypes, int... Dims>
20
21 using AccessorTuple = std::tuple<Accessor<AttributeType, MeshType>...>;
22 using ValueType = std::tuple<MapResult<AttributeType>...>;
23 using ConstValueType = std::tuple<ConstMapResult<AttributeType>...>;
24
25
26 template <size_t... Ns>
27 ValueType _value(const Tuple& t, std::integer_sequence<size_t, Ns...>)
28 {
29 return std::make_tuple(std::get<Ns>(m_base_accessors).vector_attribute(t)...);
30 }
31 ValueType value(const Tuple& t) { return _value(t, std::make_integer_sequence<size_t, N>{}); }
32
33 template <size_t... Ns>
34 ConstValueType _const_value(const Tuple& t, std::integer_sequence<size_t, Ns...>) const
35 {
36 return std::make_tuple(std::get<Ns>(m_base_accessors).const_vector_attribute(t)...);
37 }
39 {
40 return _const_value(t, std::make_integer_sequence<size_t, N>{});
41 }
42
43 template <size_t Index>
44 const auto& get() const
45 {
46 return std::get<Index>(m_base_accessors);
47 }
48 template <size_t Index>
49 auto& get()
50 {
51 return std::get<Index>(m_base_accessors);
52 }
53
54
56 template <size_t Index>
58 // Eigen::Map<VectorX<T>>
59 // template <int D = Eigen::Dynamic>
60 // using MapResult = internal::MapResult<Compound, D>;
62 // template <int D = Eigen::Dynamic>
63 // using ConstMapResult = internal::ConstMapResult<Compound, D>;
64
65
66 // const & const_scalar_attribute(const Compound& t) const;
67 // Compound& scalar_attribute(const Compound& t);
68
69 // template <int D = Eigen::Dynamic>
70 // ConstMapResult<D> const_vector_attribute(const Compound& t) const;
71 // template <int D = Eigen::Dynamic>
72 // MapResult<D> vector_attribute(const Compound& t);
73
74 // Eigen::Index dimension() const { return 1; }
75
76private:
77 std::tuple<Accessor<AttributeType, MeshType>...> m_base_accessors;
78};
79
80
81template <typename MeshType, typename... AttrType>
83 -> CompoundAccessor<sizeof...(AttrType), MeshType, AttrType...>;
84template <typename FirstAcc, typename MeshType, int FirstDim, typename... AccTypes, int... Dims>
88 -> CompoundAccessor<sizeof...(AccTypes) + 1, MeshType, FirstAcc, AccTypes...>;
89// template <typename MeshType> CompoundAccessor(const MeshType& m,
90// const TypedAttributeHandle<int64_t>& handle)
91// -> CompoundAccessor<MeshType>;
92
93} // namespace wmtk::attribute::internal
94#include "CompoundAccessor.hxx"
95
The Tuple is the basic navigation tool in our mesh data structure.
Definition Tuple.hpp:19
A CachingAccessor that uses tuples for accessing attributes instead of indices.
Definition Accessor.hpp:28
Handle that represents attributes for some mesh.
PrimitiveType primitive_type() const
returns the primitive type of the Index'th type
std::tuple< ConstMapResult< AttributeType >... > ConstValueType
std::tuple< Accessor< AttributeType, MeshType >... > m_base_accessors
std::tuple< MapResult< AttributeType >... > ValueType
CompoundAccessor(const Accessor< FirstAcc, MeshType, FirstDim > &, const Accessor< AccTypes, MeshType, Dims > &...)
ValueType _value(const Tuple &t, std::integer_sequence< size_t, Ns... >)
ConstValueType _const_value(const Tuple &t, std::integer_sequence< size_t, Ns... >) const
ConstValueType const_value(const Tuple &t) const
std::tuple< Accessor< AttributeType, MeshType >... > AccessorTuple