Wildmeshing Toolkit
HalfClosedStarIterable.cpp
Go to the documentation of this file.
2 
7 #include <wmtk/utils/Logger.hpp>
9 
10 namespace wmtk::simplex {
11 
12 
14  : m_mesh(mesh)
15  , m_tuple(tuple)
16  , m_tdc_itrbl(mesh, Simplex(mesh, PrimitiveType::Edge, tuple), true)
17  , m_it_end(m_tdc_itrbl.end())
18 {}
19 
21  : m_container(container)
22  , m_mesh(container.m_mesh)
23  , m_it(container.m_tdc_itrbl, t)
24  , m_t(t)
25 {
26  if (m_t.is_null()) {
27  return;
28  }
29 
30  m_pt = 1;
31 }
32 
34 {
35  if (m_phase == IteratorPhase::Faces) {
36  if (step_faces()) {
37  return *this;
38  } else {
39  m_face_counter = 0;
40  m_pt = 1;
41  m_phase = IteratorPhase::OpenStar;
42  }
43  }
44 
46  m_t = Tuple();
47  m_pt = -1;
48  return *this;
49  }
50 
51  switch (m_mesh.top_simplex_type()) {
52  case PrimitiveType::Triangle: return step_tri_mesh();
53  case PrimitiveType::Tetrahedron: return step_tet_mesh();
56  default: assert(false); break;
57  }
58 
59  // unreachable code
60  m_t = Tuple();
61  m_pt = -1;
62  return *this;
63 }
64 
66 {
67  return (m_t != other.m_t) || (m_pt != other.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  return m_container.m_mesh.get_id_simplex(m_t, get_primitive_type_from_id(m_pt));
78 }
79 
81 {
84 
85  ++m_face_counter;
86 
87  switch (m_face_counter) {
88  case 1: m_pt = 2; return *this;
89  case 2:
90  m_pt = 1;
91  m_t = m_mesh.switch_tuple(m_t, PE);
92  return *this;
93  default: break;
94  }
95  m_pt = 2;
96  m_face_counter = 1;
97 
98  ++m_it;
99  m_t = *m_it;
100 
101  if (m_t.is_null()) {
102  m_pt = -1;
103  }
104 
105  return *this;
106 }
107 
109 {
113 
114  ++m_face_counter;
115 
116  if (m_it.is_intermediate() && m_face_counter == 3) {
117  m_pt = 2;
118  m_face_counter = 1;
119  ++m_it;
120  m_t = *m_it;
121  if (m_t.is_null()) {
122  m_pt = -1;
123  }
124  return *this;
125  }
126  switch (m_face_counter) {
127  case 1: m_pt = 2; return *this; // coface triangle
128  case 2:
129  m_t = m_mesh.switch_tuples(m_t, {PE, PF});
130  m_pt = 1;
131  return *this;
132  case 3: m_pt = 2; return *this;
133  case 4: m_pt = 3; return *this;
134  default: break;
135  }
136  m_pt = 2;
137  m_face_counter = 1;
138 
139  ++m_it;
140  m_t = *m_it;
141 
142  if (m_t.is_null()) {
143  m_pt = -1;
144  }
145 
146  return *this;
147 }
148 
150 {
151  if (m_face_counter == 1) {
152  return false;
153  }
154  m_pt = 0;
155  ++m_face_counter;
156  return true;
157 }
158 
159 } // namespace wmtk::simplex
Tuple switch_tuples(const Tuple &tuple, const ContainerType &op_sequence) const
Definition: Mesh.hpp:968
virtual Tuple switch_tuple(const Tuple &tuple, PrimitiveType type) const =0
switch the orientation of the Tuple of the given dimension
PrimitiveType top_simplex_type() const
Definition: Mesh.hpp:997
bool is_null() const
Checks if a tuple is "null". This merely implies the global index is -1.
Definition: Tuple.hxx:40
Iterator(HalfClosedStarIterable &container, const Tuple &t=Tuple())
This iterator internally uses TopDimensionCofacesIterable.
HalfClosedStarIterable(const Mesh &mesh, const Tuple &tuple)
constexpr wmtk::PrimitiveType PF
constexpr PrimitiveType get_primitive_type_from_id(int8_t id)
Get the primitive type corresponding to its unique integer id.
constexpr PrimitiveType PV
constexpr PrimitiveType PE