Wildmeshing Toolkit
Loading...
Searching...
No Matches
FlagAccessor.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "Accessor.hpp"
4namespace wmtk::attribute {
5
6
7 // A wrapper around standard accessor specify the semantics of individual bits in Flag attributes
8 // This Index variant daels with indices as inputs directly
9template <typename MeshType = wmtk::Mesh>
11{
12public:
13 enum class FlagBit : char { Active = 0x1 };
14 static bool _is_active(char value) { return value & static_cast<char>(FlagBit::Active); }
15 static void _activate(char& value) { value |= static_cast<char>(FlagBit::Active); }
16 static void _deactivate(char& value) { value &= inverse_mask(FlagBit::Active); }
18
19
23 template <typename MeshType2>
27
28
29 bool is_active(int64_t t) const
30 {
31 return _is_active(attribute().const_scalar_attribute(t));
32 }
33 void activate(int64_t t)
34 {
35 return _activate(attribute().scalar_attribute(t));
36 }
37 void deactivate(int64_t t)
38 {
39 return _deactivate(attribute().scalar_attribute(t));
40 }
41
42 constexpr static char inverse_mask(FlagBit bit) { return 0xFF ^ static_cast<char>(bit); }
43
44
46 const BaseAccessor& base_accessor() const { return m_base_accessor; }
47 operator BaseAccessor() const { return m_base_accessor; }
48
51
52protected:
54
55
56 IndexFlagAccessor index_access() const { return IndexAccessor(*this); }
57};
58
59 // A wrawpper around standard accessor specify the semantics of individual bits in Flag attributes
60 // This Index variant daels with simplices/tuples as inputs
61template <typename MeshType = wmtk::Mesh>
62class FlagAccessor : private IndexFlagAccessor<MeshType>
63{
64public:
65 enum class FlagBit : char { Active = 1 };
67
69 using IndexBaseType::IndexBaseType;
70
71 template <typename MeshType2>
75
76 template <typename T>
77 bool is_active(const T& t) const
78 {
79 return IndexBaseType::_is_active(IndexBaseType::m_base_accessor.const_scalar_attribute(t));
80 }
81 template <typename T>
82 void activate(const T& t)
83 {
85 }
86 template <typename T>
87 void deactivate(const T& t)
88 {
90 }
91
92
93 const IndexBaseType& index_access() const { return *this; }
94 IndexBaseType& index_access() { return *this; }
95};
96
97
98} // namespace wmtk::attribute
An Accessor that uses tuples for accessing attributes instead of indices.
Definition Accessor.hpp:28
AttributeType & attribute()
Definition Accessor.hxx:147
FlagAccessor(const FlagAccessor< MeshType2 > &o)
const IndexBaseType & index_access() const
bool is_active(const T &t) const
static bool _is_active(char value)
CachingAttribute< char > & attribute()
static void _deactivate(char &value)
IndexFlagAccessor(const IndexFlagAccessor< MeshType2 > &o)
static constexpr char inverse_mask(FlagBit bit)
IndexFlagAccessor index_access() const
const CachingAttribute< char > & attribute() const
Accessor< char, MeshType, CachingAttribute< char >, 1 > BaseAccessor
const BaseAccessor & base_accessor() const
static void _activate(char &value)