Wildmeshing Toolkit
Loading...
Searching...
No Matches
MeshAttributeHandle.cpp
Go to the documentation of this file.
2#include <cassert>
3#include <wmtk/Mesh.hpp>
5
6namespace wmtk::attribute {
8 : m_mesh(&m)
9 , m_handle(h)
10{}
11
13{
14 assert(m_mesh != nullptr);
15 return m_mesh == &m;
16}
17
19{
20 assert(m_mesh != nullptr);
21 return *m_mesh;
22}
24{
25 assert(m_mesh != nullptr);
26 return *m_mesh;
27}
29{
30 return std::visit(
31 [](const auto& h) -> HeldType {
32 using T = std::decay_t<decltype(h)>;
33 return held_type_from_handle<T>();
34 },
35 m_handle);
36}
37
39{
40 if (!m_mesh) {
41 return false;
42 }
43 // forward to TypedAttributeHandle
44 if (!std::visit([](const auto& h) -> bool { return h.is_valid(); }, m_handle)) {
45 return false;
46 }
47
48 // verify that the handle exists in MeshAttributes
49
50 return std::visit([&](const auto& h) -> bool { return m_mesh->validate_handle(h); }, m_handle);
51}
52
54{
55 return std::visit(
56 [&](auto&& h) -> int64_t { return mesh().get_attribute_dimension(h); },
57 m_handle);
58}
59
60std::string MeshAttributeHandle::name() const
61{
62 return std::visit([&](auto&& h) { return mesh().get_attribute_name(h); }, m_handle);
63}
64
65
66// AttributeHandle MeshAttributeHandle::base_handle() const
67//{
68// return std::visit([](const auto& h) { return h.m_base_handle; }, m_handle);
69// }
70} // namespace wmtk::attribute
int64_t get_attribute_dimension(const TypedAttributeHandle< T > &handle) const
Definition Mesh.hpp:927
bool validate_handle(const TypedAttributeHandle< T > &handle) const
Definition Mesh.hpp:1005
std::string get_attribute_name(const TypedAttributeHandle< T > &handle) const
Definition Mesh.hpp:933
std::variant< TypedAttributeHandle< char >, TypedAttributeHandle< int64_t >, TypedAttributeHandle< double >, TypedAttributeHandle< wmtk::Rational > > HandleVariant
bool is_valid() const
Returns true if handle was initialized.