Wildmeshing Toolkit
IdSimplex.hpp
Go to the documentation of this file.
1 #pragma once
2 #include <tuple>
3 #include <wmtk/PrimitiveType.hpp>
4 
5 
6 namespace wmtk {
7 class Mesh;
8 class Tuple;
9 } // namespace wmtk
10 namespace wmtk::simplex {
11 
12 class NavigatableSimplex;
13 
14 class IdSimplex
15 {
16 public:
17  friend class wmtk::Mesh;
18  friend class NavigatableSimplex;
19  IdSimplex() = default;
20  IdSimplex(const NavigatableSimplex& s);
21  bool valid() const { return m_index == -1; }
22 
24  int64_t dimension() const { return get_primitive_type_id(m_primitive_type); }
25 
26  bool operator<(const IdSimplex& o) const;
27  bool operator==(const IdSimplex& o) const;
28  bool operator!=(const IdSimplex& o) const;
29 
30 protected:
31  friend class Mesh;
32  int64_t index() const { return m_index; }
33 
34 protected:
36  : m_primitive_type(pt)
37  , m_index(index)
38  {}
39 
40  static int64_t id(const Mesh& m, PrimitiveType pt, const Tuple& t);
41 
42 private:
44  int64_t m_index = -1;
45 
46 private:
47  decltype(auto) as_tuple() const { return std::tie(m_primitive_type, m_index); }
48 };
49 
50 inline bool IdSimplex::operator<(const IdSimplex& o) const
51 {
52  return as_tuple() < o.as_tuple();
53 }
54 inline bool IdSimplex::operator==(const IdSimplex& o) const
55 {
56  return as_tuple() == o.as_tuple();
57 }
58 inline bool IdSimplex::operator!=(const IdSimplex& o) const
59 {
60  return as_tuple() != o.as_tuple();
61 }
62 } // namespace wmtk::simplex
static int64_t id(const Mesh &m, PrimitiveType pt, const Tuple &t)
Definition: IdSimplex.cpp:10
decltype(auto) as_tuple() const
Definition: IdSimplex.hpp:47
bool operator!=(const IdSimplex &o) const
Definition: IdSimplex.hpp:58
IdSimplex(PrimitiveType pt, int64_t index)
Definition: IdSimplex.hpp:35
bool operator==(const IdSimplex &o) const
Definition: IdSimplex.hpp:54
PrimitiveType m_primitive_type
Definition: IdSimplex.hpp:43
PrimitiveType primitive_type() const
Definition: IdSimplex.hpp:23
int64_t index() const
Definition: IdSimplex.hpp:32
bool operator<(const IdSimplex &o) const
Definition: IdSimplex.hpp:50
int64_t dimension() const
Definition: IdSimplex.hpp:24
Definition: Accessor.hpp:6
constexpr int8_t get_primitive_type_id(PrimitiveType t)
Get a unique integer id corresponding to each primitive type.