|
20 | 20 | #include <wmtk/autogen/tri_mesh/is_ccw.hpp> |
21 | 21 | #include <wmtk/autogen/tri_mesh/local_id_table_offset.hpp> |
22 | 22 | #include <wmtk/autogen/tri_mesh/local_switch_tuple.hpp> |
| 23 | +#include "../tools/DEBUG_Tuple.hpp" |
23 | 24 | #include "../tools/all_valid_local_tuples.hpp" |
24 | 25 |
|
25 | 26 | using namespace wmtk; |
@@ -270,54 +271,72 @@ TEST_CASE("tuple_autogen_is_ccw", "[tuple]") |
270 | 271 | } |
271 | 272 | TEST_CASE("tuple_autogen_from_id_is_ccw", "[tuple]") |
272 | 273 | { |
| 274 | + auto run_checks = [](int ic, const Tuple& t, const Tuple& t2, int i, PrimitiveType pt) { |
| 275 | + wmtk::tests::DEBUG_Tuple dt(t); |
| 276 | + switch (ic) { |
| 277 | + case 4: REQUIRE(dt.local_fid() >= 0); REQUIRE(dt.local_fid() < 4); |
| 278 | + case 3: REQUIRE(dt.local_eid() >= 0); REQUIRE(dt.local_eid() < 6); |
| 279 | + case 2: REQUIRE(dt.local_vid() >= 0); REQUIRE(dt.local_vid() < 4); |
| 280 | + default: break; |
| 281 | + } |
| 282 | + switch (pt) { |
| 283 | + case PrimitiveType::Tetrahedron: CHECK(dt.local_fid() == i); break; |
| 284 | + case PrimitiveType::Edge: CHECK(dt.local_eid() == i); break; |
| 285 | + case PrimitiveType::Vertex: CHECK(dt.local_vid() == i); break; |
| 286 | + default: break; |
| 287 | + } |
| 288 | + |
| 289 | + CHECK(t == t2); |
| 290 | + }; |
| 291 | + PrimitiveType pt = PrimitiveType::Vertex; |
273 | 292 | for (int i = 0; i < 2; ++i) { |
274 | 293 | Tuple t = wmtk::autogen::edge_mesh::get_tuple_from_simplex_local_vertex_id(i, 0); |
275 | | - Tuple t2 = |
276 | | - wmtk::autogen::edge_mesh::get_tuple_from_simplex_local_id(PrimitiveType::Vertex, i, 0); |
277 | | - CHECK(t == t2); |
| 294 | + Tuple t2 = wmtk::autogen::edge_mesh::get_tuple_from_simplex_local_id(pt, i, 0); |
| 295 | + run_checks(2, t, t2, i, pt); |
| 296 | + // not every simplex has a ccw tuple in an edge_mesh |
278 | 297 | CHECK(edge_mesh::tuple_is_valid_for_ccw(t)); |
279 | | - // edge mesh does not always have a ccw tuple for every simplex |
280 | 298 | CHECK(edge_mesh::is_ccw(t) == (i == 0)); |
281 | 299 | } |
| 300 | + pt = PrimitiveType::Vertex; |
282 | 301 | for (int i = 0; i < 3; ++i) { |
283 | 302 | Tuple t = wmtk::autogen::tri_mesh::get_tuple_from_simplex_local_vertex_id(i, 0); |
284 | | - Tuple t2 = |
285 | | - wmtk::autogen::tri_mesh::get_tuple_from_simplex_local_id(PrimitiveType::Vertex, i, 0); |
286 | | - CHECK(t == t2); |
| 303 | + Tuple t2 = wmtk::autogen::tri_mesh::get_tuple_from_simplex_local_id(pt, i, 0); |
| 304 | + run_checks(3, t, t2, i, pt); |
287 | 305 | CHECK(tri_mesh::tuple_is_valid_for_ccw(t)); |
288 | 306 | CHECK(tri_mesh::is_ccw(t)); |
289 | 307 | } |
| 308 | + pt = PrimitiveType::Edge; |
290 | 309 | for (int i = 0; i < 3; ++i) { |
291 | 310 | Tuple t = wmtk::autogen::tri_mesh::get_tuple_from_simplex_local_edge_id(i, 0); |
292 | | - Tuple t2 = |
293 | | - wmtk::autogen::tri_mesh::get_tuple_from_simplex_local_id(PrimitiveType::Edge, i, 0); |
294 | | - CHECK(t == t2); |
| 311 | + Tuple t2 = wmtk::autogen::tri_mesh::get_tuple_from_simplex_local_id(pt, i, 0); |
| 312 | + run_checks(3, t, t2, i, pt); |
295 | 313 | CHECK(tri_mesh::tuple_is_valid_for_ccw(t)); |
296 | 314 | CHECK(tri_mesh::is_ccw(t)); |
297 | 315 | } |
298 | 316 |
|
| 317 | + pt = PrimitiveType::Vertex; |
299 | 318 | for (int i = 0; i < 4; ++i) { |
300 | 319 | Tuple t = wmtk::autogen::tet_mesh::get_tuple_from_simplex_local_vertex_id(i, 0); |
301 | | - Tuple t2 = |
302 | | - wmtk::autogen::tet_mesh::get_tuple_from_simplex_local_id(PrimitiveType::Vertex, i, 0); |
303 | | - CHECK(t == t2); |
| 320 | + Tuple t2 = wmtk::autogen::tet_mesh::get_tuple_from_simplex_local_id(pt, i, 0); |
| 321 | + run_checks(4, t, t2, i, pt); |
304 | 322 | CHECK(tet_mesh::tuple_is_valid_for_ccw(t)); |
305 | 323 | CHECK(tet_mesh::is_ccw(t)); |
306 | 324 | } |
| 325 | + pt = PrimitiveType::Edge; |
307 | 326 | for (int i = 0; i < 6; ++i) { |
308 | 327 | Tuple t = wmtk::autogen::tet_mesh::get_tuple_from_simplex_local_edge_id(i, 0); |
309 | | - Tuple t2 = |
310 | | - wmtk::autogen::tet_mesh::get_tuple_from_simplex_local_id(PrimitiveType::Edge, i, 0); |
311 | | - CHECK(t == t2); |
| 328 | + Tuple t2 = wmtk::autogen::tet_mesh::get_tuple_from_simplex_local_id(pt, i, 0); |
312 | 329 | CHECK(tet_mesh::tuple_is_valid_for_ccw(t)); |
| 330 | + run_checks(4, t, t2, i, pt); |
313 | 331 | CHECK(tet_mesh::is_ccw(t)); |
314 | 332 | } |
| 333 | + |
| 334 | + pt = PrimitiveType::Triangle; |
315 | 335 | for (int i = 0; i < 4; ++i) { |
316 | 336 | Tuple t = wmtk::autogen::tet_mesh::get_tuple_from_simplex_local_face_id(i, 0); |
317 | | - Tuple t2 = |
318 | | - wmtk::autogen::tet_mesh::get_tuple_from_simplex_local_id(PrimitiveType::Triangle, i, 0); |
319 | | - CHECK(t == t2); |
| 337 | + Tuple t2 = wmtk::autogen::tet_mesh::get_tuple_from_simplex_local_id(pt, i, 0); |
320 | 338 | CHECK(tet_mesh::tuple_is_valid_for_ccw(t)); |
| 339 | + run_checks(4, t, t2, i, pt); |
321 | 340 | CHECK(tet_mesh::is_ccw(t)); |
322 | 341 | } |
323 | 342 | } |
0 commit comments