55#include < iostream>
66#include < tuple>
77#include < wmtk/Tuple.hpp>
8+ #include < wmtk/autogen/edge_mesh/get_tuple_from_simplex_local_id.hpp>
89#include < wmtk/autogen/edge_mesh/is_ccw.hpp>
910#include < wmtk/autogen/edge_mesh/local_switch_tuple.hpp>
1011#include < wmtk/autogen/is_ccw.hpp>
1112#include < wmtk/autogen/local_switch_tuple.hpp>
1213#include < wmtk/autogen/tet_mesh/autogenerated_tables.hpp>
14+ #include < wmtk/autogen/tet_mesh/get_tuple_from_simplex_local_id.hpp>
1315#include < wmtk/autogen/tet_mesh/is_ccw.hpp>
1416#include < wmtk/autogen/tet_mesh/local_id_table_offset.hpp>
1517#include < wmtk/autogen/tet_mesh/local_switch_tuple.hpp>
1618#include < wmtk/autogen/tri_mesh/autogenerated_tables.hpp>
19+ #include < wmtk/autogen/tri_mesh/get_tuple_from_simplex_local_id.hpp>
1720#include < wmtk/autogen/tri_mesh/is_ccw.hpp>
1821#include < wmtk/autogen/tri_mesh/local_id_table_offset.hpp>
1922#include < wmtk/autogen/tri_mesh/local_switch_tuple.hpp>
20- #include " tools/all_valid_local_tuples.hpp"
23+ #include " ../tools/DEBUG_Tuple.hpp"
24+ #include " ../tools/all_valid_local_tuples.hpp"
2125
2226using namespace wmtk ;
2327using namespace wmtk ::autogen;
2428using namespace wmtk ::tests;
2529
30+ namespace {
31+
32+ template <typename T>
33+ auto get_array_range (const T& array) -> std::array<decltype(&array[0 ]), 2>
34+ {
35+ return std::array<decltype (&array[0 ]), 2 >{{array, array + std::size (array)}};
36+ }
37+ } // namespace
2638
2739TEST_CASE (" tuple_autogen_sizes" , " [tuple]" )
2840{
@@ -32,9 +44,6 @@ TEST_CASE("tuple_autogen_sizes", "[tuple]")
3244 REQUIRE (all_valid_local_tuples (PrimitiveType::Triangle).size () == valid_face);
3345 REQUIRE (all_valid_local_tuples (PrimitiveType::Tetrahedron).size () == valid_tet);
3446
35- auto get_array_range = [](const auto & array) -> std::array<decltype (&array[0 ]), 2 > {
36- return std::array<decltype (&array[0 ]), 2 >{{array, array + std::size (array)}};
37- };
3847 { // ccw check
3948 { // tri
4049 auto ccw_range = get_array_range (tri_mesh::auto_2d_table_ccw);
@@ -222,3 +231,112 @@ TEST_CASE("tuple_autogen_switch_still_valid", "[tuple]")
222231 }
223232 }
224233}
234+ TEST_CASE (" tuple_autogen_is_ccw" , " [tuple]" )
235+ {
236+ for (const auto & ve : tri_mesh::auto_2d_table_complete_vertex) {
237+ wmtk::Tuple t (ve[0 ], ve[1 ], -1 , 0 );
238+ CHECK (tri_mesh::tuple_is_valid_for_ccw (t));
239+ CHECK (tri_mesh::is_ccw (t));
240+ CHECK (tuple_is_valid_for_ccw (PrimitiveType::Triangle, t));
241+ CHECK (is_ccw (PrimitiveType::Triangle, t));
242+ }
243+ for (const auto & ve : tri_mesh::auto_2d_table_complete_edge) {
244+ wmtk::Tuple t (ve[0 ], ve[1 ], -1 , 0 );
245+ CHECK (tri_mesh::tuple_is_valid_for_ccw (t));
246+ CHECK (tri_mesh::is_ccw (t));
247+ CHECK (tuple_is_valid_for_ccw (PrimitiveType::Triangle, t));
248+ CHECK (is_ccw (PrimitiveType::Triangle, t));
249+ }
250+ for (const auto & ve : tet_mesh::auto_3d_table_complete_vertex) {
251+ wmtk::Tuple t (ve[0 ], ve[1 ], ve[2 ], 0 );
252+ CHECK (tet_mesh::tuple_is_valid_for_ccw (t));
253+ CHECK (tet_mesh::is_ccw (t));
254+ CHECK (tuple_is_valid_for_ccw (PrimitiveType::Tetrahedron, t));
255+ CHECK (is_ccw (PrimitiveType::Tetrahedron, t));
256+ }
257+ for (const auto & ve : tet_mesh::auto_3d_table_complete_edge) {
258+ wmtk::Tuple t (ve[0 ], ve[1 ], ve[2 ], 0 );
259+ CHECK (tet_mesh::tuple_is_valid_for_ccw (t));
260+ CHECK (tet_mesh::is_ccw (t));
261+ CHECK (tuple_is_valid_for_ccw (PrimitiveType::Tetrahedron, t));
262+ CHECK (is_ccw (PrimitiveType::Tetrahedron, t));
263+ }
264+ for (const auto & ve : tet_mesh::auto_3d_table_complete_face) {
265+ wmtk::Tuple t (ve[0 ], ve[1 ], ve[2 ], 0 );
266+ CHECK (tet_mesh::tuple_is_valid_for_ccw (t));
267+ CHECK (tet_mesh::is_ccw (t));
268+ CHECK (tuple_is_valid_for_ccw (PrimitiveType::Tetrahedron, t));
269+ CHECK (is_ccw (PrimitiveType::Tetrahedron, t));
270+ }
271+ }
272+ TEST_CASE (" tuple_autogen_from_id_is_ccw" , " [tuple]" )
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;
292+ for (int i = 0 ; i < 2 ; ++i) {
293+ Tuple t = wmtk::autogen::edge_mesh::get_tuple_from_simplex_local_vertex_id (i, 0 );
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
297+ CHECK (edge_mesh::tuple_is_valid_for_ccw (t));
298+ CHECK (edge_mesh::is_ccw (t) == (i == 0 ));
299+ }
300+ pt = PrimitiveType::Vertex;
301+ for (int i = 0 ; i < 3 ; ++i) {
302+ Tuple t = wmtk::autogen::tri_mesh::get_tuple_from_simplex_local_vertex_id (i, 0 );
303+ Tuple t2 = wmtk::autogen::tri_mesh::get_tuple_from_simplex_local_id (pt, i, 0 );
304+ run_checks (3 , t, t2, i, pt);
305+ CHECK (tri_mesh::tuple_is_valid_for_ccw (t));
306+ CHECK (tri_mesh::is_ccw (t));
307+ }
308+ pt = PrimitiveType::Edge;
309+ for (int i = 0 ; i < 3 ; ++i) {
310+ Tuple t = wmtk::autogen::tri_mesh::get_tuple_from_simplex_local_edge_id (i, 0 );
311+ Tuple t2 = wmtk::autogen::tri_mesh::get_tuple_from_simplex_local_id (pt, i, 0 );
312+ run_checks (3 , t, t2, i, pt);
313+ CHECK (tri_mesh::tuple_is_valid_for_ccw (t));
314+ CHECK (tri_mesh::is_ccw (t));
315+ }
316+
317+ pt = PrimitiveType::Vertex;
318+ for (int i = 0 ; i < 4 ; ++i) {
319+ Tuple t = wmtk::autogen::tet_mesh::get_tuple_from_simplex_local_vertex_id (i, 0 );
320+ Tuple t2 = wmtk::autogen::tet_mesh::get_tuple_from_simplex_local_id (pt, i, 0 );
321+ run_checks (4 , t, t2, i, pt);
322+ CHECK (tet_mesh::tuple_is_valid_for_ccw (t));
323+ CHECK (tet_mesh::is_ccw (t));
324+ }
325+ pt = PrimitiveType::Edge;
326+ for (int i = 0 ; i < 6 ; ++i) {
327+ Tuple t = wmtk::autogen::tet_mesh::get_tuple_from_simplex_local_edge_id (i, 0 );
328+ Tuple t2 = wmtk::autogen::tet_mesh::get_tuple_from_simplex_local_id (pt, i, 0 );
329+ CHECK (tet_mesh::tuple_is_valid_for_ccw (t));
330+ run_checks (4 , t, t2, i, pt);
331+ CHECK (tet_mesh::is_ccw (t));
332+ }
333+
334+ pt = PrimitiveType::Triangle;
335+ for (int i = 0 ; i < 4 ; ++i) {
336+ Tuple t = wmtk::autogen::tet_mesh::get_tuple_from_simplex_local_face_id (i, 0 );
337+ Tuple t2 = wmtk::autogen::tet_mesh::get_tuple_from_simplex_local_id (pt, i, 0 );
338+ CHECK (tet_mesh::tuple_is_valid_for_ccw (t));
339+ run_checks (4 , t, t2, i, pt);
340+ CHECK (tet_mesh::is_ccw (t));
341+ }
342+ }
0 commit comments