Wildmeshing Toolkit
Loading...
Searching...
No Matches
OpenStarIterable.cpp
Go to the documentation of this file.
2
8
9namespace wmtk::simplex {
10
11
13 : m_mesh(mesh)
14 , m_simplex(simplex)
15 , m_tdc_itrbl(mesh, simplex, true)
16 , m_it_end(m_tdc_itrbl.end())
17{}
18
20 : m_container(container)
21 , m_it(container.m_tdc_itrbl, t)
22 , m_t(t)
23 , m_pt(get_primitive_type_id(container.m_simplex.primitive_type()))
24{
25 if (m_t.is_null()) {
26 return;
27 }
28
29 init();
30}
31
33{
34 if (depth() == 3) {
35 return step_depth_3();
36 }
37
38 const Mesh& mesh = m_container.m_mesh;
39 const simplex::Simplex& simplex = m_container.m_simplex;
40 const int8_t m = mesh.top_cell_dimension();
41 const int8_t s = get_primitive_type_id(simplex.primitive_type());
42
43 if (m_pt < m && !m_it.is_intermediate()) {
44 // go to next primitive type
45 ++m_pt;
46 } else {
47 m_pt = s + 1;
48 // change tuple
49 ++m_it;
50 m_t = *m_it;
51 }
52
53 if (m_t.is_null()) {
54 m_pt = s;
55 }
56
57 return *this;
58}
59
61{
62 return (m_t != other.m_t) || (m_pt != other.m_pt);
63}
64
66{
67 return m_container.m_mesh.get_id_simplex(m_t, get_primitive_type_from_id(m_pt));
68}
69
71{
72 return m_container.m_mesh.get_id_simplex(m_t, get_primitive_type_from_id(m_pt));
73}
74
76{
77 const Mesh& mesh = m_container.m_mesh;
78 const simplex::Simplex& simplex = m_container.m_simplex;
79 assert(mesh.top_cell_dimension() >= get_primitive_type_id(simplex.primitive_type()));
80 assert(mesh.top_cell_dimension() - get_primitive_type_id(simplex.primitive_type()) < 4);
81
83}
84
86
88{
89 const Mesh& mesh = m_container.m_mesh;
90 const simplex::Simplex& simplex = m_container.m_simplex;
91 auto& visited = m_container.m_visited_cofaces;
92
94 assert(simplex.primitive_type() == PrimitiveType::Vertex);
95
96 ++m_pt;
97
98 if (m_pt == 4) {
99 // go to next cell
100 m_pt = 1;
101 m_edge_counter = 0;
102 ++m_it;
103 m_t = *m_it;
104 if (m_t.is_null()) {
105 m_pt = 0;
106 return *this;
107 }
108 }
109
110 for (; m_edge_counter < 3; ++m_edge_counter) {
111 for (; m_pt < 3; ++m_pt) {
112 if (!visited[m_pt - 1].is_visited(
113 mesh.get_id_simplex(m_t, get_primitive_type_from_id(m_pt)))) {
114 return *this;
115 }
116 }
118 m_pt = 1;
119 }
120
121 // return tet
122 m_pt = 3;
123 return *this;
124}
125
126} // namespace wmtk::simplex
Tuple switch_tuples(const Tuple &tuple, const ContainerType &op_sequence) const
Definition Mesh.hpp:953
int64_t top_cell_dimension() const
Definition Mesh.hpp:978
simplex::IdSimplex get_id_simplex(const Tuple &tuple, PrimitiveType pt) const
Retrieve the IdSimplex that is represented by the tuple and primitive type.
Definition Mesh.cpp:28
PrimitiveType top_simplex_type() const
Definition Mesh.hpp:982
The Tuple is the basic navigation tool in our mesh data structure.
Definition Tuple.hpp:19
bool is_null() const
Checks if a tuple is "null". This merely implies the global index is -1.
Definition Tuple.hxx:41
void init()
Depending on the depth, the iterator must be initialized differently.
bool operator!=(const Iterator &other) const
int64_t depth()
Compute the depth from the mesh and the simplex type.
Iterator(OpenStarIterable &container, const Tuple &t=Tuple())
Iterator & step_depth_3()
Use breadth first search to find all d-simplices, and iterate through all cofaces in a d-simplex.
This iterator internally uses TopDimensionCofacesIterable.
OpenStarIterable(const Mesh &mesh, const Simplex &simplex)
PrimitiveType primitive_type() const
Definition Simplex.hpp:51
constexpr PrimitiveType get_primitive_type_from_id(int8_t id)
Get the primitive type corresponding to its unique integer id.
constexpr int8_t get_primitive_type_id(PrimitiveType t)
Get a unique integer id corresponding to each primitive type.