1 #include <fmt/ranges.h>
2 #include <catch2/catch_test_macros.hpp>
3 #include <nlohmann/json.hpp>
6 #include "tools/TriMesh_examples.hpp"
14 const std::filesystem::path
data_dir = WMTK_DATA_DIR;
18 return wmtk::tests::disk(5);
21 auto make_child(
wmtk::Mesh& m,
const std::vector<int64_t>& path)
23 if (path.size() == 0) {
27 for (
size_t j = 0; j < path.size(); ++j) {
28 std::vector<int64_t> p(path.begin(), path.begin() + j);
30 int64_t child_index = path[j];
32 for (int64_t index = child_meshes.size(); index <= child_index; ++index) {
36 cur_mesh.register_child_mesh(new_mesh, map);
43 TEST_CASE(
"named_multimesh_parse",
"[components][multimesh]")
52 CHECK(std::vector<int64_t>{} == named_mm.
get_id(
"roo"));
53 CHECK(m == named_mm.
root().shared_from_this());
54 CHECK(m == named_mm.
get_mesh(
"roo").shared_from_this());
67 js[
"roo"] = nlohmann::json::array({
"child"});
68 named_mm.set_names(js);
70 CHECK(std::vector<int64_t>{} == named_mm.get_id(
"roo"));
71 CHECK(std::vector<int64_t>{0} == named_mm.get_id(
"roo.child"));
72 CHECK(m == named_mm.root().shared_from_this());
73 CHECK(m == named_mm.get_mesh(
"roo").shared_from_this());
75 m->get_multi_mesh_child_mesh({0}).shared_from_this() ==
76 named_mm.get_mesh(
"roo.child").shared_from_this());
83 CHECK(std::vector<int64_t>{} == named_mm.
get_id(
"roo"));
84 CHECK(std::vector<int64_t>{0} == named_mm.
get_id(
"roo.child"));
89 js[
"roo"][
"child"] = {};
91 CHECK(std::vector<int64_t>{} == named_mm.
get_id(
"roo"));
92 CHECK(std::vector<int64_t>{0} == named_mm.
get_id(
"roo.child"));
100 make_child(*m, {0, 0, 0});
101 make_child(*m, {1, 1});
107 js[
"roo"][
"c"][
"d"][
"e"] = {};
108 js[
"roo"][
"child"] = nlohmann::json::array({
"c1",
"c2"});
111 CHECK(std::vector<int64_t>{} == named_mm.
get_id(
"roo"));
112 CHECK(std::vector<int64_t>{0, 0, 0} == named_mm.
get_id(
"roo.c.d.e"));
113 CHECK(std::vector<int64_t>{1} == named_mm.
get_id(
"roo.child"));
114 CHECK(std::vector<int64_t>{1, 0} == named_mm.
get_id(
"roo.child.c1"));
115 CHECK(std::vector<int64_t>{1, 1} == named_mm.
get_id(
"roo.child.c2"));
117 m->get_multi_mesh_child_mesh({0, 0, 0}).shared_from_this() ==
118 named_mm.
get_mesh(
"roo.c.d.e").shared_from_this());
120 m->get_multi_mesh_child_mesh({1, 1}).shared_from_this() ==
121 named_mm.
get_mesh(
"roo.child.c2").shared_from_this());
124 m->get_multi_mesh_child_mesh({0, 0, 0}).shared_from_this() ==
125 named_mm.
get_mesh(
".c.d.e").shared_from_this());
127 m->get_multi_mesh_child_mesh({1, 1}).shared_from_this() ==
128 named_mm.
get_mesh(
".child.c2").shared_from_this());
Mesh & get_multi_mesh_mesh(const std::vector< int64_t > &absolute_id)
std::vector< std::shared_ptr< Mesh > > get_child_meshes() const
returns the direct multimesh child meshes for the current mesh
std::vector< int64_t > get_id(const std::string_view &path) const
void set_mesh(Mesh &m)
Navigates to the root of the multimesh.
Mesh & get_mesh(const std::string_view &path) const
void set_names(const nlohmann::json &js)
void set_name(const std::string_view &root_name="")
TEST_CASE("named_multimesh_parse", "[components][multimesh]")
std::shared_ptr< TriMesh > make_mesh(const DiskOptions &opt)
std::vector< std::array< Tuple, 2 > > same_simplex_dimension_bijection(const Mesh &parent, const Mesh &child)
const std::filesystem::path data_dir