Wildmeshing Toolkit
Simplex.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <wmtk/PrimitiveType.hpp>
4 #include <wmtk/Tuple.hpp>
5 
6 namespace wmtk {
7 class Mesh;
8 
9 namespace multimesh {
10 class MultiMeshManager;
11 }
12 template <typename Derived>
13 class MeshCRTP;
14 namespace attribute {
15 template <typename T, typename MeshType, int Dim>
16 class Accessor;
17 }
18 } // namespace wmtk
19 namespace wmtk::simplex {
20 
21 class Simplex
22 {
23  friend class wmtk::Mesh;
25  template <typename Derived>
26  friend class wmtk::MeshCRTP;
27  template <typename T, typename MeshType, int Dim>
28  friend class attribute::Accessor;
29 
30  friend class NavigatableSimplex;
33 
34 public:
35  // the mesh class can use this index value to cache/accelerate operations
36  Simplex(const PrimitiveType& ptype, const Tuple& t)
37  : m_primitive_type{ptype}
38  , m_tuple{t}
39  {}
40 
41 
42  Simplex() = default;
43  // TODO: deprecate
44  Simplex(const Mesh& m, const PrimitiveType& ptype, const Tuple& t);
45 
46  Simplex(const Simplex&) = default;
47  Simplex(Simplex&&) = default;
48  Simplex& operator=(const Simplex&) = default;
49  Simplex& operator=(Simplex&&) = default;
50 
52  int64_t dimension() const { return get_primitive_type_id(m_primitive_type); }
53  const Tuple& tuple() const { return m_tuple; }
54 
55  // TODO: deprecate
56  static Simplex vertex(const Mesh& m, const Tuple& t)
57  {
58  return Simplex(PrimitiveType::Vertex, t);
59  }
60  // TODO: deprecate
61  static Simplex edge(const Mesh& m, const Tuple& t) { return Simplex(PrimitiveType::Edge, t); }
62  // TODO: deprecate
63  static Simplex face(const Mesh& m, const Tuple& t)
64  {
66  }
67  // TODO: deprecate
68  static Simplex tetrahedron(const Mesh& m, const Tuple& t)
69  {
71  }
72 
73  static Simplex vertex(const Tuple& t) { return Simplex(PrimitiveType::Vertex, t); }
74  static Simplex edge(const Tuple& t) { return Simplex(PrimitiveType::Edge, t); }
75  static Simplex face(const Tuple& t) { return Simplex(PrimitiveType::Triangle, t); }
76  static Simplex tetrahedron(const Tuple& t) { return Simplex(PrimitiveType::Tetrahedron, t); }
77 
78  // these operations are only internally defined if caching is enabled to make sure there's a
79  // consistent semantic when simplex id caching is enabled vs not
80 #if defined(WMTK_ENABLE_SIMPLEX_ID_CACHING)
81  bool operator==(const Simplex& o) const;
82  bool operator<(const Simplex& o) const;
83 #endif
84 };
85 } // namespace wmtk::simplex
A Curiously Recurring Template Pattern shim to enable generic specialization of functions.
Definition: MeshCRTP.hpp:24
A CachingAccessor that uses tuples for accessing attributes instead of indices.
Definition: Accessor.hpp:25
Implementation details for how the Mesh class implements multiple meshes.
static Simplex face(const Mesh &m, const Tuple &t)
Definition: Simplex.hpp:63
const Tuple & tuple() const
Definition: Simplex.hpp:53
Simplex(Simplex &&)=default
Simplex(const Simplex &)=default
Simplex & operator=(Simplex &&)=default
PrimitiveType m_primitive_type
Definition: Simplex.hpp:31
static Simplex tetrahedron(const Tuple &t)
Definition: Simplex.hpp:76
static Simplex vertex(const Tuple &t)
Definition: Simplex.hpp:73
Simplex(const PrimitiveType &ptype, const Tuple &t)
Definition: Simplex.hpp:36
static Simplex edge(const Mesh &m, const Tuple &t)
Definition: Simplex.hpp:61
static Simplex tetrahedron(const Mesh &m, const Tuple &t)
Definition: Simplex.hpp:68
static Simplex vertex(const Mesh &m, const Tuple &t)
Definition: Simplex.hpp:56
static Simplex edge(const Tuple &t)
Definition: Simplex.hpp:74
PrimitiveType primitive_type() const
Definition: Simplex.hpp:51
Simplex & operator=(const Simplex &)=default
int64_t dimension() const
Definition: Simplex.hpp:52
static Simplex face(const Tuple &t)
Definition: Simplex.hpp:75
std::pair< std::shared_ptr< Mesh >, std::shared_ptr< Mesh > > multimesh(const MultiMeshType &type, Mesh &parent, std::shared_ptr< Mesh > child, const attribute::MeshAttributeHandle parent_position_handle, const std::string &tag_name, const int64_t tag_value, const int64_t primitive)
Definition: multimesh.cpp:15
Definition: Accessor.hpp:6
constexpr bool operator==(PrimitiveType a, PrimitiveType b)
constexpr int8_t get_primitive_type_id(PrimitiveType t)
Get a unique integer id corresponding to each primitive type.
constexpr bool operator<(PrimitiveType a, PrimitiveType b)