Wildmeshing Toolkit
Loading...
Searching...
No Matches
Simplex.hpp
Go to the documentation of this file.
1#pragma once
2
4#include <wmtk/Tuple.hpp>
5
6namespace wmtk {
7class Mesh;
8
9namespace multimesh {
10class MultiMeshManager;
11}
12template <typename Derived>
13class MeshCRTP;
14namespace attribute {
15template <typename T, typename MeshType, int Dim>
16class Accessor;
17}
18} // namespace wmtk
19namespace wmtk::simplex {
20
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
34public:
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
53 const Tuple& tuple() const { return m_tuple; }
54
55 // TODO: deprecate
56 static Simplex vertex(const Mesh& m, const Tuple& t)
57 {
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); }
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
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
Implementation details for how the Mesh class implements multiple meshes.
static Simplex face(const Mesh &m, const Tuple &t)
Definition Simplex.hpp:63
Simplex(Simplex &&)=default
Simplex & operator=(const Simplex &)=default
Simplex(const 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
Simplex & operator=(Simplex &&)=default
const Tuple & tuple() const
Definition Simplex.hpp:53
PrimitiveType primitive_type() const
Definition Simplex.hpp:51
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
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)