Wildmeshing Toolkit
Tuple.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <array>
4 #include "PrimitiveType.hpp"
5 
6 namespace wmtk {
7 
8 class Mesh;
9 class PointMesh;
10 class TriMesh;
11 class EdgeMesh;
12 class TetMesh;
13 
14 namespace components::internal {
15 class MultiMeshFromTag;
16 }
17 
18 namespace attribute {
19 template <typename T, typename MeshType, int Dim>
20 class Accessor;
21 }
22 namespace utils {
23 class TupleInspector;
24 }
25 namespace operations {
26 class Operation;
27 namespace internal {
28 class SplitAlternateFacetData;
29 class CollapseAlternateFacetData;
30 } // namespace internal
31 class EdgeOperationData;
32 } // namespace operations
33 namespace utils {
34 // for identifying unique top level simplices between tuples
35 class TupleCellLessThan;
36 } // namespace utils
37 namespace multimesh {
38 class MultiMeshManager;
39 }
40 
41 class Tuple
42 {
43 private:
44  // if Tuple is in 2d mesh m_global_cid is the global triangle id, and local_fid is -1
45  // if Tuple is in 3d mesh m_global_cid is the global tetrahedron id
46  int64_t m_global_cid = -1;
47  int8_t m_local_vid = -1;
48  int8_t m_local_eid = -1;
49  int8_t m_local_fid = -1;
50  std::array<int8_t, 5> m_pad = {{0, 0, 0, 0, 0}}; // align Tuple with 2*int64_t
51 
52 public:
53  friend class Mesh;
54  friend class PointMesh;
55  friend class EdgeMesh;
56  friend class TriMesh;
57  friend class TetMesh;
59  template <typename T, typename MeshType, int Dim>
60  friend class attribute::Accessor;
61  friend class operations::Operation;
66  friend class utils::TupleInspector;
68  // friend int64_t Mesh::id(const Tuple& tuple, const PrimitiveType& type) const;
69  // friend Mesh::is_ccw(const Tuple& tuple) const;
70  // friend Mesh::switch_tuple(const Tuple& tuple, const PrimitiveType& type) const;
71 
72  Tuple(int8_t local_vid, int8_t local_eid, int8_t local_fid, int64_t global_cid);
73 
74  // v2
75  // / \.
76  // e1 / \ e0
77  // v0 - - - v1
78  // e2
79 
80  Tuple() = default;
81  Tuple(const Tuple& other) = default;
82  Tuple(Tuple&& other) = default;
83  Tuple& operator=(const Tuple& other) = default;
84  Tuple& operator=(Tuple&& other) = default;
85 
86  bool operator==(const Tuple& t) const;
87  bool operator!=(const Tuple& t) const;
88  bool operator<(const Tuple& t) const;
90  bool same_ids(const Tuple& t) const;
91 
93  bool is_null() const;
94 
95 private:
96  int8_t local_vid() const;
97  int8_t local_eid() const;
98  int8_t local_fid() const;
99 };
100 inline Tuple::Tuple(int8_t local_vid, int8_t local_eid, int8_t local_fid, int64_t global_cid)
101  : m_global_cid(global_cid)
102  , m_local_vid(local_vid)
103  , m_local_eid(local_eid)
104  , m_local_fid(local_fid)
105 {}
106 // #if !defined(WMTK_ENABLE_HASH_UPDATE)
107 // inline Tuple::Tuple(
108 // int8_t local_vid,
109 // int8_t local_eid,
110 // int8_t local_fid,
111 // int64_t global_cid)
112 // : m_global_cid(global_cid)
113 // , m_local_vid(local_vid)
114 // , m_local_eid(local_eid)
115 // , m_local_fid(local_fid)
116 //{}
117 // #endif
118 } // namespace wmtk
119 #include "Tuple.hxx"
bool is_null() const
Checks if a tuple is "null". This merely implies the global index is -1.
Definition: Tuple.hxx:40
Tuple(const Tuple &other)=default
bool operator==(const Tuple &t) const
Definition: Tuple.hxx:22
int8_t m_local_vid
Definition: Tuple.hpp:47
Tuple & operator=(const Tuple &other)=default
bool same_ids(const Tuple &t) const
Checks whether two tuples are equal, but ignores the hash.
Definition: Tuple.hxx:34
int8_t local_vid() const
Definition: Tuple.hxx:46
bool operator<(const Tuple &t) const
Definition: Tuple.hxx:29
int8_t m_local_eid
Definition: Tuple.hpp:48
int64_t m_global_cid
Definition: Tuple.hpp:46
int8_t m_local_fid
Definition: Tuple.hpp:49
int8_t local_fid() const
Definition: Tuple.hxx:56
bool operator!=(const Tuple &t) const
Definition: Tuple.hxx:18
Tuple & operator=(Tuple &&other)=default
int8_t local_eid() const
Definition: Tuple.hxx:51
std::array< int8_t, 5 > m_pad
Definition: Tuple.hpp:50
Tuple(Tuple &&other)=default
Tuple()=default
A CachingAccessor that uses tuples for accessing attributes instead of indices.
Definition: Accessor.hpp:25
This class generates a multi-mesh from a mesh where the substructure is represented by a tag.
Implementation details for how the Mesh class implements multiple meshes.
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