23TEST_CASE(
"multimesh_from_tag_tri_tri",
"[components][multimesh][multimesh_from_tag]")
25 auto mesh_in = tests::disk(6);
26 DEBUG_TriMesh& m =
static_cast<DEBUG_TriMesh&
>(*mesh_in);
28 auto tag_handle = m.register_attribute<int64_t>(
"tag", PrimitiveType::Triangle, 1);
29 int64_t tag_value = 1;
33 int64_t n_vertices = -1;
36 auto tag_acc = m.create_accessor<int64_t>(tag_handle);
38 SECTION(
"one_component")
40 tag_acc.scalar_attribute(m.face_tuple_from_vids(0, 1, 2)) = tag_value;
41 tag_acc.scalar_attribute(m.face_tuple_from_vids(0, 2, 3)) = tag_value;
42 tag_acc.scalar_attribute(m.face_tuple_from_vids(0, 3, 4)) = tag_value;
43 tag_acc.scalar_attribute(m.face_tuple_from_vids(0, 4, 5)) = tag_value;
48 SECTION(
"two_components")
50 tag_acc.scalar_attribute(m.face_tuple_from_vids(0, 1, 2)) = tag_value;
51 tag_acc.scalar_attribute(m.face_tuple_from_vids(0, 2, 3)) = tag_value;
52 tag_acc.scalar_attribute(m.face_tuple_from_vids(0, 3, 4)) = tag_value;
53 tag_acc.scalar_attribute(m.face_tuple_from_vids(0, 5, 6)) = tag_value;
57 non_manifold_root_simplices.
add(PrimitiveType::Vertex, m.vertex_tuple_from_id(0));
59 SECTION(
"three_components")
61 tag_acc.scalar_attribute(m.face_tuple_from_vids(0, 1, 2)) = tag_value;
62 tag_acc.scalar_attribute(m.face_tuple_from_vids(0, 3, 4)) = tag_value;
63 tag_acc.scalar_attribute(m.face_tuple_from_vids(0, 5, 6)) = tag_value;
67 non_manifold_root_simplices.
add(PrimitiveType::Vertex, m.vertex_tuple_from_id(0));
74 REQUIRE(m.get_child_meshes().size() == 2);
75 REQUIRE(m.is_multi_mesh_root());
78 CHECK(m.get_child_meshes().size() == 1);
79 REQUIRE(m.is_multi_mesh_root());
82 Mesh& sub_mesh = *substructure_mesh_ptr;
85 CHECK(sub_mesh.
get_all(PrimitiveType::Triangle).size() == n_faces);
86 CHECK(sub_mesh.
get_all(PrimitiveType::Edge).size() == n_edges);
87 CHECK(sub_mesh.
get_all(PrimitiveType::Vertex).size() == n_vertices);
91 for (
const Tuple& t : m.get_all(pt)) {
93 if (non_manifold_root_simplices.
contains(s)) {
102TEST_CASE(
"multimesh_from_tag_tri_edge",
"[components][multimesh][multimesh_from_tag]")
104 auto mesh_in = tests::disk(6);
105 DEBUG_TriMesh& m =
static_cast<DEBUG_TriMesh&
>(*mesh_in);
107 auto tag_handle = m.register_attribute<int64_t>(
"tag", PrimitiveType::Edge, 1);
108 int64_t tag_value = 1;
110 int64_t n_edges = -1;
111 int64_t n_vertices = -1;
114 auto tag_acc = m.create_accessor<int64_t>(tag_handle);
116 SECTION(
"one_component")
118 tag_acc.scalar_attribute(m.edge_tuple_from_vids(0, 1)) = tag_value;
119 tag_acc.scalar_attribute(m.edge_tuple_from_vids(1, 2)) = tag_value;
120 tag_acc.scalar_attribute(m.edge_tuple_from_vids(2, 3)) = tag_value;
124 SECTION(
"two_components")
126 tag_acc.scalar_attribute(m.edge_tuple_from_vids(0, 1)) = tag_value;
127 tag_acc.scalar_attribute(m.edge_tuple_from_vids(0, 4)) = tag_value;
128 tag_acc.scalar_attribute(m.edge_tuple_from_vids(5, 6)) = tag_value;
132 SECTION(
"three_components")
134 tag_acc.scalar_attribute(m.edge_tuple_from_vids(0, 1)) = tag_value;
135 tag_acc.scalar_attribute(m.edge_tuple_from_vids(0, 4)) = tag_value;
136 tag_acc.scalar_attribute(m.edge_tuple_from_vids(5, 0)) = tag_value;
137 non_manifold_root_simplices.
add(PrimitiveType::Vertex, m.vertex_tuple_from_id(0));
141 SECTION(
"two_closed_loops")
143 tag_acc.scalar_attribute(m.edge_tuple_from_vids(0, 1)) = tag_value;
144 tag_acc.scalar_attribute(m.edge_tuple_from_vids(1, 2)) = tag_value;
145 tag_acc.scalar_attribute(m.edge_tuple_from_vids(2, 0)) = tag_value;
146 tag_acc.scalar_attribute(m.edge_tuple_from_vids(0, 4)) = tag_value;
147 tag_acc.scalar_attribute(m.edge_tuple_from_vids(4, 5)) = tag_value;
148 tag_acc.scalar_attribute(m.edge_tuple_from_vids(5, 0)) = tag_value;
149 non_manifold_root_simplices.
add(PrimitiveType::Vertex, m.vertex_tuple_from_id(0));
158 REQUIRE(m.get_child_meshes().size() == 2);
159 REQUIRE(m.is_multi_mesh_root());
162 CHECK(m.get_child_meshes().size() == 1);
163 REQUIRE(m.is_multi_mesh_root());
166 Mesh& sub_mesh = *substructure_mesh_ptr;
169 CHECK(sub_mesh.
get_all(PrimitiveType::Edge).size() == n_edges);
170 CHECK(sub_mesh.
get_all(PrimitiveType::Vertex).size() == n_vertices);
174 for (
const Tuple& t : m.get_all(pt)) {
176 if (non_manifold_root_simplices.
contains(s)) {
185TEST_CASE(
"multimesh_from_tag_tri_point",
"[components][multimesh][multimesh_from_tag]")
187 auto mesh_in = tests::disk(6);
188 DEBUG_TriMesh& m =
static_cast<DEBUG_TriMesh&
>(*mesh_in);
190 auto tag_handle = m.register_attribute<int64_t>(
"tag", PrimitiveType::Vertex, 1);
191 int64_t tag_value = 1;
194 auto tag_acc = m.create_accessor<int64_t>(tag_handle);
196 auto vertices = m.get_all(PrimitiveType::Vertex);
197 for (
size_t i = 0; i < 4; ++i) {
198 tag_acc.scalar_attribute(
vertices[i]) = tag_value;
205 REQUIRE(m.get_child_meshes().size() == 2);
206 REQUIRE(m.is_multi_mesh_root());
209 CHECK(m.get_child_meshes().size() == 1);
210 REQUIRE(m.is_multi_mesh_root());
213 Mesh& sub_mesh = *substructure_mesh_ptr;
216 CHECK(sub_mesh.
get_all(PrimitiveType::Vertex).size() == 4);
219 for (
const Tuple& t : m.get_all(pt)) {
226TEST_CASE(
"multimesh_from_tag_tet_tet",
"[components][multimesh][multimesh_from_tag]")
228 DEBUG_TetMesh m = six_cycle_tets();
230 auto tag_handle = m.register_attribute<int64_t>(
"tag", PrimitiveType::Tetrahedron, 1);
231 int64_t tag_value = 1;
234 int64_t n_faces = -1;
235 int64_t n_edges = -1;
236 int64_t n_vertices = -1;
239 auto tag_acc = m.create_accessor<int64_t>(tag_handle);
241 SECTION(
"one_component")
243 tag_acc.scalar_attribute(m.tet_tuple_from_vids(0, 1, 2, 3)) = tag_value;
244 tag_acc.scalar_attribute(m.tet_tuple_from_vids(0, 2, 3, 4)) = tag_value;
245 tag_acc.scalar_attribute(m.tet_tuple_from_vids(2, 3, 4, 5)) = tag_value;
251 SECTION(
"two_components")
253 tag_acc.scalar_attribute(m.tet_tuple_from_vids(0, 1, 2, 3)) = tag_value;
254 tag_acc.scalar_attribute(m.tet_tuple_from_vids(0, 2, 3, 4)) = tag_value;
255 tag_acc.scalar_attribute(m.tet_tuple_from_vids(2, 3, 4, 5)) = tag_value;
256 tag_acc.scalar_attribute(m.tet_tuple_from_vids(2, 3, 6, 7)) = tag_value;
261 non_manifold_root_simplices.
add(PrimitiveType::Vertex, m.vertex_tuple_from_id(2));
262 non_manifold_root_simplices.
add(PrimitiveType::Vertex, m.vertex_tuple_from_id(3));
263 non_manifold_root_simplices.
add(PrimitiveType::Edge, m.edge_tuple_from_vids(2, 3));
265 SECTION(
"three_components")
267 tag_acc.scalar_attribute(m.tet_tuple_from_vids(0, 1, 2, 3)) = tag_value;
268 tag_acc.scalar_attribute(m.tet_tuple_from_vids(2, 3, 4, 5)) = tag_value;
269 tag_acc.scalar_attribute(m.tet_tuple_from_vids(2, 3, 6, 7)) = tag_value;
275 non_manifold_root_simplices.
add(PrimitiveType::Vertex, m.vertex_tuple_from_id(2));
276 non_manifold_root_simplices.
add(PrimitiveType::Vertex, m.vertex_tuple_from_id(3));
277 non_manifold_root_simplices.
add(PrimitiveType::Edge, m.edge_tuple_from_vids(2, 3));
284 REQUIRE(m.get_child_meshes().size() == 2);
285 REQUIRE(m.is_multi_mesh_root());
288 CHECK(m.get_child_meshes().size() == 1);
289 REQUIRE(m.is_multi_mesh_root());
292 Mesh& sub_mesh = *substructure_mesh_ptr;
295 CHECK(sub_mesh.
get_all(PrimitiveType::Tetrahedron).size() == n_tets);
296 CHECK(sub_mesh.
get_all(PrimitiveType::Triangle).size() == n_faces);
297 CHECK(sub_mesh.
get_all(PrimitiveType::Edge).size() == n_edges);
298 CHECK(sub_mesh.
get_all(PrimitiveType::Vertex).size() == n_vertices);
302 for (
const Tuple& t : m.get_all(pt)) {
304 if (non_manifold_root_simplices.
contains(s)) {
313TEST_CASE(
"multimesh_from_tag_tet_tri",
"[components][multimesh][multimesh_from_tag]")
315 DEBUG_TetMesh m = six_cycle_tets();
317 auto tag_handle = m.register_attribute<int64_t>(
"tag", PrimitiveType::Triangle, 1);
318 int64_t tag_value = 1;
320 int64_t n_faces = -1;
321 int64_t n_edges = -1;
322 int64_t n_vertices = -1;
325 auto tag_acc = m.create_accessor<int64_t>(tag_handle);
327 SECTION(
"one_component")
329 tag_acc.scalar_attribute(m.face_tuple_from_vids(1, 2, 3)) = tag_value;
330 tag_acc.scalar_attribute(m.face_tuple_from_vids(0, 1, 2)) = tag_value;
331 tag_acc.scalar_attribute(m.face_tuple_from_vids(2, 3, 5)) = tag_value;
336 SECTION(
"non_manifold_vertex")
338 tag_acc.scalar_attribute(m.face_tuple_from_vids(0, 1, 2)) = tag_value;
339 tag_acc.scalar_attribute(m.face_tuple_from_vids(0, 2, 4)) = tag_value;
340 tag_acc.scalar_attribute(m.face_tuple_from_vids(1, 2, 6)) = tag_value;
341 tag_acc.scalar_attribute(m.face_tuple_from_vids(2, 5, 7)) = tag_value;
342 tag_acc.scalar_attribute(m.face_tuple_from_vids(3, 5, 7)) = tag_value;
346 non_manifold_root_simplices.
add(PrimitiveType::Vertex, m.vertex_tuple_from_id(2));
348 SECTION(
"non_manifold_vertex_2")
350 tag_acc.scalar_attribute(m.face_tuple_from_vids(0, 1, 2)) = tag_value;
351 tag_acc.scalar_attribute(m.face_tuple_from_vids(1, 2, 3)) = tag_value;
352 tag_acc.scalar_attribute(m.face_tuple_from_vids(0, 2, 3)) = tag_value;
353 tag_acc.scalar_attribute(m.face_tuple_from_vids(0, 1, 3)) = tag_value;
354 tag_acc.scalar_attribute(m.face_tuple_from_vids(2, 5, 7)) = tag_value;
358 non_manifold_root_simplices.
add(PrimitiveType::Vertex, m.vertex_tuple_from_id(2));
360 SECTION(
"non_manifold_edge")
362 tag_acc.scalar_attribute(m.face_tuple_from_vids(0, 1, 2)) = tag_value;
363 tag_acc.scalar_attribute(m.face_tuple_from_vids(1, 2, 3)) = tag_value;
364 tag_acc.scalar_attribute(m.face_tuple_from_vids(0, 2, 3)) = tag_value;
365 tag_acc.scalar_attribute(m.face_tuple_from_vids(0, 1, 3)) = tag_value;
367 tag_acc.scalar_attribute(m.face_tuple_from_vids(2, 3, 5)) = tag_value;
368 tag_acc.scalar_attribute(m.face_tuple_from_vids(3, 5, 7)) = tag_value;
369 tag_acc.scalar_attribute(m.face_tuple_from_vids(2, 5, 7)) = tag_value;
370 tag_acc.scalar_attribute(m.face_tuple_from_vids(2, 3, 7)) = tag_value;
374 non_manifold_root_simplices.
add(PrimitiveType::Vertex, m.vertex_tuple_from_id(2));
375 non_manifold_root_simplices.
add(PrimitiveType::Vertex, m.vertex_tuple_from_id(3));
376 non_manifold_root_simplices.
add(PrimitiveType::Edge, m.edge_tuple_from_vids(2, 3));
383 REQUIRE(m.get_child_meshes().size() == 2);
384 REQUIRE(m.is_multi_mesh_root());
387 CHECK(m.get_child_meshes().size() == 1);
388 REQUIRE(m.is_multi_mesh_root());
391 Mesh& sub_mesh = *substructure_mesh_ptr;
394 CHECK(sub_mesh.
get_all(PrimitiveType::Triangle).size() == n_faces);
395 CHECK(sub_mesh.
get_all(PrimitiveType::Edge).size() == n_edges);
396 CHECK(sub_mesh.
get_all(PrimitiveType::Vertex).size() == n_vertices);
400 for (
const Tuple& t : m.get_all(pt)) {
402 if (non_manifold_root_simplices.
contains(s)) {
411TEST_CASE(
"multimesh_from_tag_tri_visualization",
"[components][multimesh][multimesh_from_tag][.]")
413 DEBUG_TriMesh m = tests::edge_region_with_position();
415 auto tag_handle = m.register_attribute<int64_t>(
"tag", PrimitiveType::Triangle, 1);
416 int64_t tag_value = 1;
418 int64_t n_faces = -1;
419 int64_t n_edges = -1;
420 int64_t n_vertices = -1;
422 auto tag_acc = m.create_accessor<int64_t>(tag_handle);
424 tag_acc.scalar_attribute(m.face_tuple_from_vids(0, 3, 4)) = tag_value;
425 tag_acc.scalar_attribute(m.face_tuple_from_vids(3, 7, 4)) = tag_value;
426 tag_acc.scalar_attribute(m.face_tuple_from_vids(4, 5, 1)) = tag_value;
427 tag_acc.scalar_attribute(m.face_tuple_from_vids(5, 6, 2)) = tag_value;
436 CHECK(m.get_child_meshes().size() == 2);
437 CHECK(m.is_multi_mesh_root());
440 Mesh& sub_mesh = *substructure_mesh_ptr;
443 CHECK(sub_mesh.
get_all(PrimitiveType::Triangle).size() == n_faces);
444 CHECK(sub_mesh.
get_all(PrimitiveType::Edge).size() == n_edges);
445 CHECK(sub_mesh.
get_all(PrimitiveType::Vertex).size() == n_vertices);
448 auto root_pos_handle = m.get_attribute_handle<
double>(
"vertices", PrimitiveType::Vertex);
449 auto subs_pos_handle =
452 auto propagate_to_child_position = [](
const Eigen::MatrixXd& P) -> Eigen::VectorXd {
457 std::make_shared<wmtk::operations::SingleAttributeTransferStrategy<double, double>>(
460 propagate_to_child_position);
461 pos_transfer->run_on_all();
463 ParaviewWriter writer(
"child_mesh",
"vertices", sub_mesh,
false,
false,
true,
false);
465 ParaviewWriter writer2(
"root_mesh",
"vertices", m,
false,
false,
true,
false);
466 m.serialize(writer2);
469TEST_CASE(
"multimesh_from_tag",
"[components][multimesh][multimesh_from_tag]")
473 auto mesh_in = tests::disk(6);
474 DEBUG_TriMesh& m =
static_cast<DEBUG_TriMesh&
>(*mesh_in);
476 auto tag_handle = m.register_attribute<int64_t>(
"tag", PrimitiveType::Triangle, 1);
477 auto tag_acc = m.create_accessor<int64_t>(tag_handle);
478 tag_acc.scalar_attribute(m.face_tuple_from_vids(0, 1, 2)) = 1;
479 tag_acc.scalar_attribute(m.face_tuple_from_vids(0, 2, 3)) = 1;
480 tag_acc.scalar_attribute(m.face_tuple_from_vids(0, 3, 4)) = 1;
481 tag_acc.scalar_attribute(m.face_tuple_from_vids(0, 5, 6)) = 1;
488 "input": "input_mesh",
489 "output": "output_mesh",
490 "substructure_label": "tag",
491 "substructure_value": 1,