1 #include <catch2/catch_test_macros.hpp>
3 #include <tools/DEBUG_TetMesh.hpp>
4 #include <tools/DEBUG_TriMesh.hpp>
5 #include <tools/TetMesh_examples.hpp>
6 #include <tools/TriMesh_examples.hpp>
18 TEST_CASE(
"marching_component_tri",
"[components][marching]")
20 const int64_t input_tag_value_0 = 0;
21 const int64_t input_tag_value_1 = 1;
22 const int64_t isosurface_tag_value = 2;
29 tests::DEBUG_TriMesh m = tests::hex_plus_two_with_position();
42 options.
input_values = {input_tag_value_0, input_tag_value_1};
45 int64_t expected_isosurface_vertex_num = 0;
46 int64_t expected_isosurface_edge_num = 0;
55 expected_isosurface_vertex_num = 6;
56 expected_isosurface_edge_num = 6;
66 expected_isosurface_vertex_num = 9;
67 expected_isosurface_edge_num = 8;
78 expected_isosurface_vertex_num = 10;
79 expected_isosurface_edge_num = 8;
81 SECTION(
"0-4-5-with-filter")
101 expected_isosurface_vertex_num = 5;
102 expected_isosurface_edge_num = 4;
105 int64_t expected_vertex_num =
115 CHECK(
vertices.size() == expected_vertex_num);
117 int64_t isosurface_vertex_num = 0;
120 isosurface_vertex_num++;
123 CHECK(isosurface_vertex_num == expected_isosurface_vertex_num);
131 int64_t isosurface_edge_num = 0;
134 isosurface_edge_num++;
137 CHECK(isosurface_edge_num == expected_isosurface_edge_num);
147 int64_t tagged_neighbors = 0;
148 for (
const Tuple& neigh : one_ring) {
154 if (m.is_boundary_vertex(v)) {
155 CHECK(tagged_neighbors == 1);
157 CHECK(tagged_neighbors == 2);
165 writer(
"marching_2d_result",
"vertices", m,
true,
true,
true,
false);
170 TEST_CASE(
"marching_component_tet",
"[components][marching]")
172 const int64_t input_tag_value_0 = 0;
173 const int64_t input_tag_value_1 = 1;
174 const int64_t isosurface_tag_value = 2;
184 tests_3d::DEBUG_TetMesh m = tests_3d::three_incident_tets_with_positions();
199 options.
input_values = {input_tag_value_0, input_tag_value_1};
203 int64_t expected_isosurface_vertex_num = 0;
204 int64_t expected_isosurface_face_num = 0;
214 expected_isosurface_vertex_num = 8;
215 expected_isosurface_face_num = 6;
225 expected_isosurface_vertex_num = 5;
226 expected_isosurface_face_num = 3;
238 expected_isosurface_vertex_num = 8;
239 expected_isosurface_face_num = 6;
242 int64_t expected_vertex_num =
246 std::vector<attribute::MeshAttributeHandle> pass_through_attributes;
247 pass_through_attributes.emplace_back(
257 CHECK(
vertices.size() == expected_vertex_num);
259 int64_t isosurface_vertex_num = 0;
262 isosurface_vertex_num++;
265 CHECK(isosurface_vertex_num == expected_isosurface_vertex_num);
273 int64_t isosurface_face_num = 0;
276 isosurface_face_num++;
279 CHECK(isosurface_face_num == expected_isosurface_face_num);
284 writer(
"marching_3d_result",
"vertices", m,
true,
true,
true,
true);
T & scalar_attribute(const ArgType &t)
std::vector< Tuple > simplex_vector_tuples(PrimitiveType ptype) const
Return vector of all simplices of the requested type, as tuples.
static Simplex vertex(const Mesh &m, const Tuple &t)
void marching(Mesh &mesh, const MarchingOptions &options)
Perform maching tetrahedra/triangles.
std::vector< Tuple > vertices(const Mesh &m, const Simplex &simplex)
SimplexCollection link(const Mesh &mesh, const simplex::Simplex &simplex, const bool sort_and_clean)
std::vector< Tuple > edges(const Mesh &m, const Simplex &simplex)
SimplexCollection faces(const Mesh &mesh, const Simplex &simplex, const bool sort_and_clean)
Returns all faces of a simplex.
std::vector< std::pair< attribute::MeshAttributeHandle, int64_t > > edge_filter_handles
Filters (int64_t) on edge labels.
attribute::MeshAttributeHandle position_handle
vertex positions (double)
std::vector< int64_t > input_values
The label values (int64_t) in between the marching surface should be placed.
int64_t output_value
The output label value (int 64_t) is assigned to the marching surface in all primitive types for whic...
std::map< PrimitiveType, attribute::MeshAttributeHandle > label_handles
Labels for inside, outside, and marching surface (int64_t).
TEST_CASE("marching_component_tri", "[components][marching]")