Wildmeshing Toolkit
Loading...
Searching...
No Matches
LinkSingleDimensionIterable.cpp
Go to the documentation of this file.
2
8
9namespace wmtk::simplex {
10
11
13 const Mesh& mesh,
14 const Simplex& simplex,
15 const PrimitiveType link_type)
16 : m_mesh(mesh)
17 , m_simplex(simplex)
18 , m_link_type(link_type)
19 , m_tdc_itrbl(mesh, simplex, link_type == PrimitiveType::Vertex)
20 , m_it_end(m_tdc_itrbl.end())
21{}
22
25 const Tuple& t)
26 : m_container(container)
27 , m_it(container.m_tdc_itrbl, t)
28 , m_t(t)
29{
30 if (m_t.is_null()) {
31 return;
32 }
33
34 // check if link_type can exist
35 {
36 const Mesh& mesh = m_container.m_mesh;
37 const simplex::Simplex& simplex = m_container.m_simplex;
39 const int8_t m = mesh.top_cell_dimension();
40 const int8_t s = get_primitive_type_id(simplex.primitive_type());
41 const int8_t l = get_primitive_type_id(link_pt);
42 if (l >= m - s) {
43 logger().warn("Trying to retrieve simplices in the link that cannot exist!");
44 m_t = Tuple();
45 return;
46 }
47 }
48
49 init();
50}
51
53{
54 if (depth() == 3) {
55 return step_depth_3();
56 }
57
58 ++m_it;
59 m_t = navigate_to_link(*m_it);
60 return *this;
61}
62
64{
65 return m_t != *other;
66}
67
72
74{
75 return m_t;
76}
77
79{
80 const Mesh& mesh = m_container.m_mesh;
81 const simplex::Simplex& simplex = m_container.m_simplex;
82 assert(mesh.top_cell_dimension() >= get_primitive_type_id(simplex.primitive_type()));
83 assert(mesh.top_cell_dimension() - get_primitive_type_id(simplex.primitive_type()) < 4);
84
86}
87
89{
90 return m_container.m_mesh.top_cell_dimension() - 1 ==
91 get_primitive_type_id(m_container.m_link_type);
92}
93
95{
96 m_t = navigate_to_link(*m_it);
97
98 if (depth() == 3) {
99 const Mesh& mesh = m_container.m_mesh;
100 const PrimitiveType& link_type = m_container.m_link_type;
101
102 m_container.m_visited_link.is_visited(mesh.get_id_simplex(m_t, link_type));
103 }
104}
105
107{
108 const Mesh& mesh = m_container.m_mesh;
109 const PrimitiveType& link_type = m_container.m_link_type;
110 auto& visited = m_container.m_visited_link;
111
112 if (!is_link_d1()) {
114 ++m_edge_counter;
115
116 while (!m_t.is_null()) {
117 for (; m_edge_counter < 3; ++m_edge_counter) {
118 if (!visited.is_visited(mesh.get_id_simplex(m_t, link_type))) {
119 return *this;
120 }
122 }
123
124 // go to next cell
125 m_edge_counter = 0;
126 ++m_it;
127 m_t = navigate_to_link(*m_it);
128 }
129 } else {
130 ++m_it;
131 m_t = navigate_to_link(*m_it);
132 }
133 return *this;
134}
135
137{
138 if (t.is_null()) {
139 return t;
140 }
141 // invert the simplex using SimplexDart
142 const Mesh& mesh = m_container.m_mesh;
143 // const PrimitiveType& mesh_pt = mesh.top_simplex_type();
144 // autogen::SimplexDart sd(mesh_pt);
145
146 // switch (mesh.top_simplex_type()) {
147 // case PrimitiveType::Triangle: {
148 // const int8_t index_switch = sd.product(
149 // sd.primitive_as_index(PrimitiveType::Edge),
150 // sd.primitive_as_index(PrimitiveType::Vertex));
151 // m_t = autogen::local_switch_tuple(mesh_pt, m_t, index_switch);
152 // break;
153 // }
154 // default: log_and_throw_error("missing mesh navigation in link"); break;
155 // }
156
157 {
158 /*
159 * Assume a tuple that contains the vertices (a,b,c,d) and the simplex is an edge, i.e.,
160 * (a,b). The link contains all the vertices that are not in the simplex. To get a tuple
161 * that represents all simplices of the link, we need to move (a,b) to the end of that
162 * tuple.
163 * (a,b,c,d) becomes (c,d,a,b) with the following permutations
164 * (a,b,c,d)
165 * switch edge: (a,c,b,d)
166 * switch face: (a,c,d,b)
167 * switch vert: (c,a,d,b)
168 * switch edge: (c,d,a,b)
169 *
170 * The following code implements these permutations.
171 */
172 const simplex::Simplex& simplex = m_container.m_simplex;
173 const PrimitiveType link_pt = m_container.m_link_type;
174 const int8_t m = mesh.top_cell_dimension();
175 const int8_t s = get_primitive_type_id(simplex.primitive_type());
176
177 for (int8_t j = s; j > -1; --j) {
178 for (int8_t i = 0; i < m - s; ++i) {
179 t = mesh.switch_tuple(t, get_primitive_type_from_id(j + i));
180 }
181 }
182 }
183
184 return t;
185}
186
187} // 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
virtual Tuple switch_tuple(const Tuple &tuple, PrimitiveType type) const =0
switch the orientation of the Tuple of the given dimension
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
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
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.
spdlog::logger & logger()
Retrieves the current logger.
Definition Logger.cpp:58