From 2493c949e027f16d1bbf33061f1f64d75a2ec81a Mon Sep 17 00:00:00 2001 From: JcDai Date: Wed, 30 Oct 2024 14:05:05 -0400 Subject: [PATCH 01/14] fix triangle insertion pointer reference --- .../components/triangle_insertion/triangle_insertion.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/triangle_insertion/wmtk/components/triangle_insertion/triangle_insertion.cpp b/components/triangle_insertion/wmtk/components/triangle_insertion/triangle_insertion.cpp index 8097646181..c538bb0868 100644 --- a/components/triangle_insertion/wmtk/components/triangle_insertion/triangle_insertion.cpp +++ b/components/triangle_insertion/wmtk/components/triangle_insertion/triangle_insertion.cpp @@ -64,10 +64,10 @@ std::tuple, ChildMeshes> triangle_insertion( utils::generate_raw_tetmesh_from_input_surface(V, F, Vbg, Fbg); ChildMeshes child_meshes; - std::shared_ptr surface_mesh = child_meshes.surface_mesh; - std::shared_ptr open_boundary_mesh = child_meshes.open_boundary_mesh; - std::shared_ptr nonmanifold_edge_mesh = child_meshes.nonmanifold_edge_mesh; - std::shared_ptr bbox_mesh = child_meshes.bbox_mesh; + std::shared_ptr& surface_mesh = child_meshes.surface_mesh; + std::shared_ptr& open_boundary_mesh = child_meshes.open_boundary_mesh; + std::shared_ptr& nonmanifold_edge_mesh = child_meshes.nonmanifold_edge_mesh; + std::shared_ptr& bbox_mesh = child_meshes.bbox_mesh; /* -------------rounding------------ */ From 421f39fa53281408dcf0adfebf66686fe954d75c Mon Sep 17 00:00:00 2001 From: JcDai Date: Wed, 30 Oct 2024 14:05:23 -0400 Subject: [PATCH 02/14] fix parameter for tetwild simp --- applications/tetwild/tetwild_main.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/applications/tetwild/tetwild_main.cpp b/applications/tetwild/tetwild_main.cpp index 65d56af761..3bc280201b 100644 --- a/applications/tetwild/tetwild_main.cpp +++ b/applications/tetwild/tetwild_main.cpp @@ -69,7 +69,7 @@ int main(int argc, char* argv[]) auto [out, stats] = tetwild_simplification( static_cast(*mesh), "vertices", - j["target_edge_length"]); + j["envelope_size"]); mesh_after_simp = out; } @@ -103,6 +103,14 @@ int main(int argc, char* argv[]) true, false); + std::string output_file = j["output"]; + + wmtk::components::output::output(*main_mesh, output_file + "_after_insertion", "vertices"); + wmtk::components::output::output( + *child_meshes.surface_mesh, + output_file + "_surface_after_insertion", + "vertices"); + std::vector enves; wmtk::components::EnvelopeOptions e_surface; @@ -167,8 +175,6 @@ int main(int argc, char* argv[]) auto meshes_after_tetwild = wildmeshing(wmo); auto main_mesh_after_tetwild = meshes_after_tetwild[0].first; - std::string output_file = j["output"]; - std::shared_ptr surface_mesh; for (int64_t i = 1; i < meshes_after_tetwild.size(); ++i) { // output child meshes From 8ba26e329c2427374e1e240266f13754e59179c3 Mon Sep 17 00:00:00 2001 From: JcDai Date: Wed, 30 Oct 2024 14:05:35 -0400 Subject: [PATCH 03/14] fix tetwild spec --- applications/tetwild/tetwild_spec.hpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/applications/tetwild/tetwild_spec.hpp b/applications/tetwild/tetwild_spec.hpp index cfd26b3509..51d9210e00 100644 --- a/applications/tetwild/tetwild_spec.hpp +++ b/applications/tetwild/tetwild_spec.hpp @@ -14,7 +14,7 @@ nlohmann::json tetwild_spec = R"( "envelope_size", "target_edge_length", "skip_simplification", - "max_amips", + "target_max_amips", "max_passes", "intermediate_output" ] @@ -44,10 +44,15 @@ nlohmann::json tetwild_spec = R"( "default": false }, { - "pointer": "/max_amips", + "pointer": "/target_max_amips", "type": "float", "default": 10.0 }, +{ + "pointer": "/target_edge_length", + "type": "float", + "default": 0.05 +}, { "pointer": "/max_passes", "type": "int", From da6b35fae2d6e4d09084f31c0953e128fa38cc96 Mon Sep 17 00:00:00 2001 From: JcDai Date: Wed, 30 Oct 2024 14:05:48 -0400 Subject: [PATCH 04/14] consolidate for wildmeshing 2d --- .../wmtk/components/wildmeshing/internal/wildmeshing2d.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/wildmeshing/wmtk/components/wildmeshing/internal/wildmeshing2d.cpp b/components/wildmeshing/wmtk/components/wildmeshing/internal/wildmeshing2d.cpp index 99f247c782..2ed4e97f00 100644 --- a/components/wildmeshing/wmtk/components/wildmeshing/internal/wildmeshing2d.cpp +++ b/components/wildmeshing/wmtk/components/wildmeshing/internal/wildmeshing2d.cpp @@ -1285,6 +1285,8 @@ std::vector, std::string>> wildmeshing2d( min_energy, avg_energy); + multimesh::consolidate(*mesh); + std::vector, std::string>> all_meshes; all_meshes.push_back(std::make_pair(mesh, "main")); From 5c6059861da68e2fbb0cdb6b0f8746c48f3569a7 Mon Sep 17 00:00:00 2001 From: JcDai Date: Wed, 30 Oct 2024 14:05:58 -0400 Subject: [PATCH 05/14] add vtu to obj script --- scripts/convert_vtu_to_obj.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 scripts/convert_vtu_to_obj.py diff --git a/scripts/convert_vtu_to_obj.py b/scripts/convert_vtu_to_obj.py new file mode 100644 index 0000000000..8760d06be8 --- /dev/null +++ b/scripts/convert_vtu_to_obj.py @@ -0,0 +1,23 @@ +import meshio as mio +import sys + +def __main__(): + input_path,output_path = sys.argv[1:] + + mesh = mio.read(input_path) + + if "triangle" in mesh.cells_dict: + mio.write(output_path + ".obj", mesh) + elif "line" in mesh.cells_dict: + file = open(output_path + ".obj", "w") + for p in mesh.points: + file.write(f'v {p[0]} {p[1]} {p[2]}\n') + for l in mesh.cells_dict["line"]: + file.write(f'l {l[0] + 1} {l[1] + 1}\n') + file.close() + else: + print("wrong input data format") + + +if __name__ == "__main__": + __main__() \ No newline at end of file From c5cb70bbd8cb59053a91b5dd5c8168d130becb77 Mon Sep 17 00:00:00 2001 From: JcDai Date: Wed, 30 Oct 2024 14:31:34 -0400 Subject: [PATCH 06/14] add multimeshmapvalid invariant --- .../components/wildmeshing/internal/wildmeshing2d.cpp | 6 ++---- .../components/wildmeshing/internal/wildmeshing3d.cpp | 10 ++++++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/components/wildmeshing/wmtk/components/wildmeshing/internal/wildmeshing2d.cpp b/components/wildmeshing/wmtk/components/wildmeshing/internal/wildmeshing2d.cpp index 2ed4e97f00..fde71425d0 100644 --- a/components/wildmeshing/wmtk/components/wildmeshing/internal/wildmeshing2d.cpp +++ b/components/wildmeshing/wmtk/components/wildmeshing/internal/wildmeshing2d.cpp @@ -50,15 +50,12 @@ #include #include #include +#include #include #include #include #include #include -#include -#include -#include -#include #include #include @@ -637,6 +634,7 @@ std::vector, std::string>> wildmeshing2d( auto setup_collapse = [&](std::shared_ptr& collapse) { collapse->add_invariant(invariant_separate_substructures); + collapse->add_invariant(std::make_shared(*mesh)); collapse->add_invariant(link_condition); collapse->add_invariant(inversion_invariant); collapse->add_invariant(function_invariant); diff --git a/components/wildmeshing/wmtk/components/wildmeshing/internal/wildmeshing3d.cpp b/components/wildmeshing/wmtk/components/wildmeshing/internal/wildmeshing3d.cpp index 5c1e794564..185347c441 100644 --- a/components/wildmeshing/wmtk/components/wildmeshing/internal/wildmeshing3d.cpp +++ b/components/wildmeshing/wmtk/components/wildmeshing/internal/wildmeshing3d.cpp @@ -49,6 +49,7 @@ #include #include #include +#include #include #include #include @@ -597,6 +598,7 @@ std::vector, std::string>> wildmeshing3d( auto setup_collapse = [&](std::shared_ptr& collapse) { collapse->add_invariant(invariant_separate_substructures); + collapse->add_invariant(std::make_shared(*mesh)); collapse->add_invariant(link_condition); collapse->add_invariant(inversion_invariant); // collapse->add_invariant(function_invariant); @@ -637,7 +639,9 @@ std::vector, std::string>> wildmeshing3d( 1)); collapse1->set_new_attribute_strategy(pt_attribute, clps_strat1); - collapse1->set_new_attribute_strategy(sizing_field_scalar_attribute, clps_strat1); + collapse1->set_new_attribute_strategy( + sizing_field_scalar_attribute, + CollapseBasicStrategy::CopyOther); setup_collapse(collapse1); auto collapse2 = std::make_shared(*mesh); @@ -648,7 +652,9 @@ std::vector, std::string>> wildmeshing3d( 0)); collapse2->set_new_attribute_strategy(pt_attribute, clps_strat2); - collapse2->set_new_attribute_strategy(sizing_field_scalar_attribute, clps_strat2); + collapse2->set_new_attribute_strategy( + sizing_field_scalar_attribute, + CollapseBasicStrategy::CopyTuple); setup_collapse(collapse2); auto collapse = std::make_shared(*mesh); From b43d856d05bfedffad543b330752d61c1e66d0d3 Mon Sep 17 00:00:00 2001 From: JcDai Date: Wed, 30 Oct 2024 14:31:50 -0400 Subject: [PATCH 07/14] add nonmanifold vertex to passthrough --- .../wmtk/components/triangle_insertion/triangle_insertion.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/triangle_insertion/wmtk/components/triangle_insertion/triangle_insertion.cpp b/components/triangle_insertion/wmtk/components/triangle_insertion/triangle_insertion.cpp index c538bb0868..50e6cc69e0 100644 --- a/components/triangle_insertion/wmtk/components/triangle_insertion/triangle_insertion.cpp +++ b/components/triangle_insertion/wmtk/components/triangle_insertion/triangle_insertion.cpp @@ -249,6 +249,8 @@ std::tuple, ChildMeshes> triangle_insertion( auto nonmanifold_vertex_accessor = tetmesh->create_accessor(nonmanifold_vertex_handle); + pass_through.push_back(nonmanifold_vertex_handle); + for (const auto& v : tetmesh->get_all(PrimitiveType::Vertex)) { int64_t on_open_boundary_cnt = 0; int64_t on_nonmanifold_edge_cnt = 0; From 652218a7dc5e4701cfccc2ded0bb7053d7cf0d5f Mon Sep 17 00:00:00 2001 From: JcDai Date: Wed, 30 Oct 2024 16:41:44 -0400 Subject: [PATCH 08/14] turn on tetwild app --- applications/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/applications/CMakeLists.txt b/applications/CMakeLists.txt index 4155541590..22c4c71eef 100644 --- a/applications/CMakeLists.txt +++ b/applications/CMakeLists.txt @@ -29,6 +29,7 @@ add_application(multimesh OFF) add_application(isotropic_remeshing OFF) add_application(tetwild_simplification ON) add_application(triwild ON) +add_application(tetwild ON) add_application(cdt_sec ON) add_application(shortest_edge_collapse ON) add_application(insertion ON) From 7bc48c421403fca9de3f8dd8c387eac831d3a6ec Mon Sep 17 00:00:00 2001 From: JcDai Date: Wed, 30 Oct 2024 16:41:55 -0400 Subject: [PATCH 09/14] close logger --- applications/tetwild/tetwild_main.cpp | 1 + applications/tetwild/tetwild_spec.hpp | 5 ----- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/applications/tetwild/tetwild_main.cpp b/applications/tetwild/tetwild_main.cpp index 3bc280201b..d90dd5afc4 100644 --- a/applications/tetwild/tetwild_main.cpp +++ b/applications/tetwild/tetwild_main.cpp @@ -34,6 +34,7 @@ using wmtk::components::utils::resolve_paths; int main(int argc, char* argv[]) { + opt_logger().set_level(spdlog::level::off); CLI::App app{argv[0]}; app.ignore_case(); diff --git a/applications/tetwild/tetwild_spec.hpp b/applications/tetwild/tetwild_spec.hpp index 51d9210e00..f9c2532051 100644 --- a/applications/tetwild/tetwild_spec.hpp +++ b/applications/tetwild/tetwild_spec.hpp @@ -28,11 +28,6 @@ nlohmann::json tetwild_spec = R"( "type": "float", "default": 0.001 }, -{ - "pointer": "/length_rel", - "type": "float", - "default": 0.1 -}, { "pointer": "/skip_simplification", "type": "bool", From 82c5ddb2a32555f6651d71d4bf2d23a1b984418f Mon Sep 17 00:00:00 2001 From: JcDai Date: Fri, 1 Nov 2024 15:00:19 -0400 Subject: [PATCH 10/14] add integration test for triwild --- applications/triwild/CMakeLists.txt | 7 ++++++- applications/triwild/triwild_test.json | 0 applications/triwild/triwild_test_config.json | 11 +++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) delete mode 100644 applications/triwild/triwild_test.json create mode 100644 applications/triwild/triwild_test_config.json diff --git a/applications/triwild/CMakeLists.txt b/applications/triwild/CMakeLists.txt index d61b3e0a40..12cf865a91 100644 --- a/applications/triwild/CMakeLists.txt +++ b/applications/triwild/CMakeLists.txt @@ -11,4 +11,9 @@ wmtk::procedural wmtk::edge_insertion wmtk::wildmeshing wmtk::winding_number -wmtk::output) \ No newline at end of file +wmtk::output) + +wmtk_register_integration_test(EXEC_NAME triwild_app + CONFIG_FILE ${CMAKE_CURRENT_SOURCE_DIR}/triwild_test_config.json + GIT_REPOSITORY "https://github.com/wildmeshing/data.git" + GIT_TAG 82ea9d55c901bbc86d48de39383e9c85d8f67686) diff --git a/applications/triwild/triwild_test.json b/applications/triwild/triwild_test.json deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/applications/triwild/triwild_test_config.json b/applications/triwild/triwild_test_config.json new file mode 100644 index 0000000000..01902cbd59 --- /dev/null +++ b/applications/triwild/triwild_test_config.json @@ -0,0 +1,11 @@ +{ + "test_directory": "unit_test", + "tests": [], + "release_only_tests": [ + "triwild_siggraph_icon_out.json" + ], + "input_tag": "input", + "oracle_tag": "report", + "input_directory_tag": "root", + "checks": [] +} \ No newline at end of file From 15a431e1773ef0329f3504f4a05ced1a3ea8dd82 Mon Sep 17 00:00:00 2001 From: JcDai Date: Fri, 1 Nov 2024 15:12:11 -0400 Subject: [PATCH 11/14] add platform? --- applications/triwild/triwild_test_config.json | 1 + 1 file changed, 1 insertion(+) diff --git a/applications/triwild/triwild_test_config.json b/applications/triwild/triwild_test_config.json index 01902cbd59..7c8562dceb 100644 --- a/applications/triwild/triwild_test_config.json +++ b/applications/triwild/triwild_test_config.json @@ -7,5 +7,6 @@ "input_tag": "input", "oracle_tag": "report", "input_directory_tag": "root", + "platform": "Linux", "checks": [] } \ No newline at end of file From 31246c987335d5ecc304c316ed1917c71f414224 Mon Sep 17 00:00:00 2001 From: JcDai Date: Fri, 1 Nov 2024 15:32:07 -0400 Subject: [PATCH 12/14] add swapunroundedvertex inv, replace with before check later --- .../wildmeshing/internal/wildmeshing2d.cpp | 3 ++ src/wmtk/invariants/CMakeLists.txt | 2 + .../Swap2dUnroundedVertexInvariant.cpp | 42 +++++++++++++++++++ .../Swap2dUnroundedVertexInvariant.hpp | 20 +++++++++ 4 files changed, 67 insertions(+) create mode 100644 src/wmtk/invariants/Swap2dUnroundedVertexInvariant.cpp create mode 100644 src/wmtk/invariants/Swap2dUnroundedVertexInvariant.hpp diff --git a/components/wildmeshing/wmtk/components/wildmeshing/internal/wildmeshing2d.cpp b/components/wildmeshing/wmtk/components/wildmeshing/internal/wildmeshing2d.cpp index fde71425d0..69bb3edf90 100644 --- a/components/wildmeshing/wmtk/components/wildmeshing/internal/wildmeshing2d.cpp +++ b/components/wildmeshing/wmtk/components/wildmeshing/internal/wildmeshing2d.cpp @@ -56,6 +56,7 @@ #include #include #include +#include #include #include @@ -735,6 +736,8 @@ std::vector, std::string>> wildmeshing2d( if (is_edge) op.set_priority(long_edges_first); op.add_invariant(simplex_invariant); + op.add_invariant( + std::make_shared(*mesh, pt_attribute.as())); op.add_invariant(inversion_invariant); op.add_invariant(function_invariant); diff --git a/src/wmtk/invariants/CMakeLists.txt b/src/wmtk/invariants/CMakeLists.txt index 7baebc64af..8841db2f5f 100644 --- a/src/wmtk/invariants/CMakeLists.txt +++ b/src/wmtk/invariants/CMakeLists.txt @@ -95,6 +95,8 @@ set(SRC_FILES FrozenVertexInvariant.hpp FrozenVertexInvariant.cpp + Swap2dUnroundedVertexInvariant.hpp + Swap2dUnroundedVertexInvariant.cpp ) target_sources(wildmeshing_toolkit PRIVATE ${SRC_FILES}) diff --git a/src/wmtk/invariants/Swap2dUnroundedVertexInvariant.cpp b/src/wmtk/invariants/Swap2dUnroundedVertexInvariant.cpp new file mode 100644 index 0000000000..c47d6defc8 --- /dev/null +++ b/src/wmtk/invariants/Swap2dUnroundedVertexInvariant.cpp @@ -0,0 +1,42 @@ +#include "Swap2dUnroundedVertexInvariant.hpp" +#include +#include +#include + +namespace wmtk { +Swap2dUnroundedVertexInvariant::Swap2dUnroundedVertexInvariant( + const Mesh& m, + const attribute::TypedAttributeHandle& coordinate) + : Invariant(m, true, false, false) + , m_coordinate_handle(coordinate) +{} + +bool Swap2dUnroundedVertexInvariant::before(const simplex::Simplex& t) const +{ + constexpr static PrimitiveType PV = PrimitiveType::Vertex; + constexpr static PrimitiveType PE = PrimitiveType::Edge; + constexpr static PrimitiveType PF = PrimitiveType::Triangle; + + auto accessor = mesh().create_const_accessor(m_coordinate_handle); + int dim = mesh().get_attribute_dimension(m_coordinate_handle); + + // get the coords of the vertices + // input face end points + const std::array vs = { + {t.tuple(), + mesh().switch_tuple(t.tuple(), PV), + mesh().switch_tuples(t.tuple(), {PE, PV}), + mesh().switch_tuples(t.tuple(), {PF, PE, PV})}}; + + for (const auto& v : vs) { + for (int i = 0; i < dim; ++i) { + if (!accessor.const_vector_attribute(v)[i].is_rounded()) { + return false; + } + } + } + + return true; +} + +} // namespace wmtk diff --git a/src/wmtk/invariants/Swap2dUnroundedVertexInvariant.hpp b/src/wmtk/invariants/Swap2dUnroundedVertexInvariant.hpp new file mode 100644 index 0000000000..d192662072 --- /dev/null +++ b/src/wmtk/invariants/Swap2dUnroundedVertexInvariant.hpp @@ -0,0 +1,20 @@ +#pragma once + +#include +#include "Invariant.hpp" + +namespace wmtk { +class Swap2dUnroundedVertexInvariant : public Invariant +{ +public: + Swap2dUnroundedVertexInvariant( + const Mesh& m, + const attribute::TypedAttributeHandle& coordinate); + using Invariant::Invariant; + + bool before(const simplex::Simplex& t) const override; + +private: + const attribute::TypedAttributeHandle m_coordinate_handle; +}; +} // namespace wmtk From 30a4b67738950cfe3c00eef50a0275e58ed1defc Mon Sep 17 00:00:00 2001 From: JcDai Date: Mon, 4 Nov 2024 13:54:08 -0500 Subject: [PATCH 13/14] make daniel happy --- applications/triwild/triwild_test_config.json | 5 +- .../triangle_insertion/triangle_insertion.cpp | 57 ++++++++++--------- scripts/convert_vtu_to_obj.py | 6 ++ 3 files changed, 36 insertions(+), 32 deletions(-) diff --git a/applications/triwild/triwild_test_config.json b/applications/triwild/triwild_test_config.json index 7c8562dceb..10d836ab5a 100644 --- a/applications/triwild/triwild_test_config.json +++ b/applications/triwild/triwild_test_config.json @@ -1,9 +1,6 @@ { "test_directory": "unit_test", - "tests": [], - "release_only_tests": [ - "triwild_siggraph_icon_out.json" - ], + "tests": ["triwild_siggraph_icon_out.json"], "input_tag": "input", "oracle_tag": "report", "input_directory_tag": "root", diff --git a/components/triangle_insertion/wmtk/components/triangle_insertion/triangle_insertion.cpp b/components/triangle_insertion/wmtk/components/triangle_insertion/triangle_insertion.cpp index 50e6cc69e0..1649f3674c 100644 --- a/components/triangle_insertion/wmtk/components/triangle_insertion/triangle_insertion.cpp +++ b/components/triangle_insertion/wmtk/components/triangle_insertion/triangle_insertion.cpp @@ -63,12 +63,6 @@ std::tuple, ChildMeshes> triangle_insertion( auto [tetmesh, tet_face_on_input_surface] = utils::generate_raw_tetmesh_from_input_surface(V, F, Vbg, Fbg); - ChildMeshes child_meshes; - std::shared_ptr& surface_mesh = child_meshes.surface_mesh; - std::shared_ptr& open_boundary_mesh = child_meshes.open_boundary_mesh; - std::shared_ptr& nonmanifold_edge_mesh = child_meshes.nonmanifold_edge_mesh; - std::shared_ptr& bbox_mesh = child_meshes.bbox_mesh; - /* -------------rounding------------ */ if (round) { @@ -95,6 +89,8 @@ std::tuple, ChildMeshes> triangle_insertion( stats.executing_time); } + ChildMeshes child_meshes; + if (track_submeshes) { /* -----------input surface--------- */ @@ -133,18 +129,19 @@ std::tuple, ChildMeshes> triangle_insertion( if (make_child_free) { logger().info("Making free child surface mesh"); - surface_mesh = wmtk::multimesh::utils::extract_and_register_child_mesh_from_tag_handle( - *tetmesh, - surface_handle.as(), - 1, - /*free = */ true); + child_meshes.surface_mesh = + wmtk::multimesh::utils::extract_and_register_child_mesh_from_tag_handle( + *tetmesh, + surface_handle.as(), + 1, + /*free = */ true); } else { logger().info("Making child surface mesh"); internal::MultiMeshFromTag SurfaceMeshFromTag(*tetmesh, surface_handle, 1); SurfaceMeshFromTag.compute_substructure_mesh(); - surface_mesh = tetmesh->get_child_meshes().back(); + child_meshes.surface_mesh = tetmesh->get_child_meshes().back(); SurfaceMeshFromTag.remove_soup(); } @@ -168,12 +165,13 @@ std::tuple, ChildMeshes> triangle_insertion( bool has_nonmanifold_edge = false; logger().info("Looping edges for open/nonmanifold ones"); - for (const auto& e : surface_mesh->get_all(PrimitiveType::Edge)) { - const auto surface_edge = simplex::Simplex::edge(*surface_mesh, e); - if (!surface_mesh->is_boundary(surface_edge)) continue; + for (const auto& e : child_meshes.surface_mesh->get_all(PrimitiveType::Edge)) { + const auto surface_edge = simplex::Simplex::edge(*child_meshes.surface_mesh, e); + if (!child_meshes.surface_mesh->is_boundary(surface_edge)) continue; - const auto& parent_e = surface_mesh->map_to_parent(surface_edge); - const auto& child_e = tetmesh->map_to_child_tuples(*surface_mesh, parent_e); + const auto& parent_e = child_meshes.surface_mesh->map_to_parent(surface_edge); + const auto& child_e = + tetmesh->map_to_child_tuples(*child_meshes.surface_mesh, parent_e); assert(child_e.size() > 0); @@ -196,7 +194,7 @@ std::tuple, ChildMeshes> triangle_insertion( if (has_openboundary) { if (make_child_free) { logger().error("Creating free open boundary child mesh"); - open_boundary_mesh = + child_meshes.open_boundary_mesh = wmtk::multimesh::utils::extract_and_register_child_mesh_from_tag_handle( *tetmesh, open_boundary_handle.as(), @@ -208,7 +206,7 @@ std::tuple, ChildMeshes> triangle_insertion( internal::MultiMeshFromTag OpenBoundaryFromTag(*tetmesh, open_boundary_handle, 1); OpenBoundaryFromTag.compute_substructure_mesh(); - open_boundary_mesh = tetmesh->get_child_meshes().back(); + child_meshes.open_boundary_mesh = tetmesh->get_child_meshes().back(); OpenBoundaryFromTag.remove_soup(); } } @@ -218,7 +216,7 @@ std::tuple, ChildMeshes> triangle_insertion( internal::MultiMeshFromTag NonmanifoldEdgeFromTag(*tetmesh, nonmanifold_edge_handle, 1); NonmanifoldEdgeFromTag.compute_substructure_mesh(); - nonmanifold_edge_mesh = tetmesh->get_child_meshes().back(); + child_meshes.nonmanifold_edge_mesh = tetmesh->get_child_meshes().back(); NonmanifoldEdgeFromTag.remove_soup(); } @@ -237,7 +235,7 @@ std::tuple, ChildMeshes> triangle_insertion( internal::MultiMeshFromTag NonmanifoldEdgeFromTag(*tetmesh, bbox_handle, 1); NonmanifoldEdgeFromTag.compute_substructure_mesh(); - bbox_mesh = tetmesh->get_child_meshes().back(); + child_meshes.bbox_mesh = tetmesh->get_child_meshes().back(); NonmanifoldEdgeFromTag.remove_soup(); @@ -256,15 +254,16 @@ std::tuple, ChildMeshes> triangle_insertion( int64_t on_nonmanifold_edge_cnt = 0; if (has_openboundary) { - on_open_boundary_cnt = - tetmesh - ->map_to_child(*open_boundary_mesh, simplex::Simplex::vertex(*tetmesh, v)) - .size(); + on_open_boundary_cnt = tetmesh + ->map_to_child( + *child_meshes.open_boundary_mesh, + simplex::Simplex::vertex(*tetmesh, v)) + .size(); } if (process_nonmanifold_edges) { on_nonmanifold_edge_cnt = tetmesh ->map_to_child( - *nonmanifold_edge_mesh, + *child_meshes.nonmanifold_edge_mesh, simplex::Simplex::vertex(*tetmesh, v)) .size(); } @@ -275,8 +274,10 @@ std::tuple, ChildMeshes> triangle_insertion( } else if ( // not on the edgemeshes and more than 1 copy on the surface mesh on_open_boundary_cnt + on_nonmanifold_edge_cnt == 0 && - tetmesh->map_to_child(*surface_mesh, simplex::Simplex::vertex(*tetmesh, v)).size() > - 1) { + tetmesh->map_to_child( + *child_meshes.surface_mesh, + simplex::Simplex::vertex(*tetmesh, v)) + .size() > 1) { nonmanifold_vertex_accessor.scalar_attribute(v) = 1; } } diff --git a/scripts/convert_vtu_to_obj.py b/scripts/convert_vtu_to_obj.py index 8760d06be8..13c37c254e 100644 --- a/scripts/convert_vtu_to_obj.py +++ b/scripts/convert_vtu_to_obj.py @@ -1,6 +1,12 @@ import meshio as mio import sys +""" +This script is for convert surface vtu files to triangle/line .obj file + +usage: python convert_vtu_to_obj.py +""" + def __main__(): input_path,output_path = sys.argv[1:] From be6f3f41af6abeb8207e32cb6e3fe3378c06cfbc Mon Sep 17 00:00:00 2001 From: JcDai Date: Mon, 4 Nov 2024 14:50:21 -0500 Subject: [PATCH 14/14] add skip options to wildmeshing code --- applications/tetwild/tetwild_main.cpp | 4 ++ applications/tetwild/tetwild_spec.hpp | 26 ++++++++++- applications/triwild/triwild_main.cpp | 4 ++ applications/triwild/triwild_spec.hpp | 26 ++++++++++- .../internal/WildmeshingOptions.hpp | 5 ++ .../wildmeshing/internal/wildmeshing2d.cpp | 46 +++++++++++-------- .../wildmeshing/internal/wildmeshing3d.cpp | 46 +++++++++++-------- 7 files changed, 118 insertions(+), 39 deletions(-) diff --git a/applications/tetwild/tetwild_main.cpp b/applications/tetwild/tetwild_main.cpp index d90dd5afc4..26b9777651 100644 --- a/applications/tetwild/tetwild_main.cpp +++ b/applications/tetwild/tetwild_main.cpp @@ -172,6 +172,10 @@ int main(int argc, char* argv[]) wmo.intermediate_output_name = j["output"]; wmo.envelopes = enves; wmo.pass_through = pass_through; + wmo.skip_split = j["skip_split"]; + wmo.skip_collapse = j["skip_collapse"]; + wmo.skip_swap = j["skip_swap"]; + wmo.skip_smooth = j["skip_smooth"]; auto meshes_after_tetwild = wildmeshing(wmo); auto main_mesh_after_tetwild = meshes_after_tetwild[0].first; diff --git a/applications/tetwild/tetwild_spec.hpp b/applications/tetwild/tetwild_spec.hpp index f9c2532051..dcc56905e7 100644 --- a/applications/tetwild/tetwild_spec.hpp +++ b/applications/tetwild/tetwild_spec.hpp @@ -16,7 +16,11 @@ nlohmann::json tetwild_spec = R"( "skip_simplification", "target_max_amips", "max_passes", - "intermediate_output" + "intermediate_output", + "skip_split", + "skip_collapse", + "skip_swap", + "skip_smooth" ] }, { @@ -53,6 +57,26 @@ nlohmann::json tetwild_spec = R"( "type": "int", "default": 10 }, +{ + "pointer": "/skip_split", + "type": "bool", + "default": false +}, +{ + "pointer": "/skip_collapse", + "type": "bool", + "default": false +}, +{ + "pointer": "/skip_swap", + "type": "bool", + "default": false +}, +{ + "pointer": "/skip_smooth", + "type": "bool", + "default": false +}, { "pointer": "/output", "type": "string" diff --git a/applications/triwild/triwild_main.cpp b/applications/triwild/triwild_main.cpp index e467905416..b5df5af4cc 100644 --- a/applications/triwild/triwild_main.cpp +++ b/applications/triwild/triwild_main.cpp @@ -181,6 +181,10 @@ int main(int argc, char* argv[]) wmo.intermediate_output_name = j["output"]; wmo.envelopes = enves; wmo.pass_through = pass_through; + wmo.skip_split = j["skip_split"]; + wmo.skip_collapse = j["skip_collapse"]; + wmo.skip_swap = j["skip_swap"]; + wmo.skip_smooth = j["skip_smooth"]; auto meshes_after_tetwild = wildmeshing(wmo); auto main_mesh = meshes_after_tetwild[0].first; diff --git a/applications/triwild/triwild_spec.hpp b/applications/triwild/triwild_spec.hpp index 327af5b9e0..741d6cd599 100644 --- a/applications/triwild/triwild_spec.hpp +++ b/applications/triwild/triwild_spec.hpp @@ -15,7 +15,11 @@ nlohmann::json triwild_spec = R"( "target_edge_length", "target_max_amips", "max_passes", - "intermediate_output" + "intermediate_output", + "skip_split", + "skip_collapse", + "skip_swap", + "skip_smooth" ] }, { @@ -37,6 +41,26 @@ nlohmann::json triwild_spec = R"( "type": "bool", "default": false }, +{ + "pointer": "/skip_split", + "type": "bool", + "default": false +}, +{ + "pointer": "/skip_collapse", + "type": "bool", + "default": false +}, +{ + "pointer": "/skip_swap", + "type": "bool", + "default": false +}, +{ + "pointer": "/skip_smooth", + "type": "bool", + "default": false +}, { "pointer": "/target_max_amips", "type": "float", diff --git a/components/wildmeshing/wmtk/components/wildmeshing/internal/WildmeshingOptions.hpp b/components/wildmeshing/wmtk/components/wildmeshing/internal/WildmeshingOptions.hpp index de7652d573..539667f031 100644 --- a/components/wildmeshing/wmtk/components/wildmeshing/internal/WildmeshingOptions.hpp +++ b/components/wildmeshing/wmtk/components/wildmeshing/internal/WildmeshingOptions.hpp @@ -27,6 +27,11 @@ struct WildMeshingOptions std::string intermediate_output_path; std::string intermediate_output_name; + bool skip_split; + bool skip_collapse; + bool skip_swap; + bool skip_smooth; + std::vector envelopes; std::vector pass_through; }; diff --git a/components/wildmeshing/wmtk/components/wildmeshing/internal/wildmeshing2d.cpp b/components/wildmeshing/wmtk/components/wildmeshing/internal/wildmeshing2d.cpp index 69bb3edf90..d58c937bdf 100644 --- a/components/wildmeshing/wmtk/components/wildmeshing/internal/wildmeshing2d.cpp +++ b/components/wildmeshing/wmtk/components/wildmeshing/internal/wildmeshing2d.cpp @@ -609,11 +609,14 @@ std::vector, std::string>> wildmeshing2d( split_sequence->set_priority(long_edges_first); - ops.emplace_back(split_sequence); - ops_name.emplace_back("SPLIT"); - ops.emplace_back(rounding); - ops_name.emplace_back("rounding"); + if (!options.skip_split) { + ops.emplace_back(split_sequence); + ops_name.emplace_back("SPLIT"); + + ops.emplace_back(rounding); + ops_name.emplace_back("rounding"); + } ////////////////////////////////// @@ -718,11 +721,13 @@ std::vector, std::string>> wildmeshing2d( collapse_then_round->add_transfer_strategy(s); } - ops.emplace_back(collapse_then_round); - ops_name.emplace_back("COLLAPSE"); + if (!options.skip_collapse) { + ops.emplace_back(collapse_then_round); + ops_name.emplace_back("COLLAPSE"); - ops.emplace_back(rounding); - ops_name.emplace_back("rounding"); + ops.emplace_back(rounding); + ops_name.emplace_back("rounding"); + } ////////////////////////////////// // 3) Swap @@ -804,11 +809,13 @@ std::vector, std::string>> wildmeshing2d( auto swap = std::make_shared(*mesh); setup_swap(*swap, swap->collapse(), swap->split(), interior_edge); - ops.push_back(swap); - ops_name.push_back("swap"); + if (!options.skip_swap) { + ops.push_back(swap); + ops_name.push_back("swap"); - ops.emplace_back(rounding); - ops_name.emplace_back("rounding"); + ops.emplace_back(rounding); + ops_name.emplace_back("rounding"); + } // 4) Smoothing // ////////////////////////////////////// @@ -894,13 +901,16 @@ std::vector, std::string>> wildmeshing2d( } // proj_smoothing->add_transfer_strategy(target_edge_length_update); - for (int i = 0; i < 1; ++i) { - ops.push_back(proj_smoothing); - ops_name.push_back("SMOOTHING"); - } + if (!options.skip_smooth) { + for (int i = 0; i < 1; ++i) { + // some old code to do smoothing several times, maybe useful later + ops.push_back(proj_smoothing); + ops_name.push_back("SMOOTHING"); + } - ops.emplace_back(rounding); - ops_name.emplace_back("rounding"); + ops.emplace_back(rounding); + ops_name.emplace_back("rounding"); + } write( mesh, diff --git a/components/wildmeshing/wmtk/components/wildmeshing/internal/wildmeshing3d.cpp b/components/wildmeshing/wmtk/components/wildmeshing/internal/wildmeshing3d.cpp index 185347c441..343c1b4e26 100644 --- a/components/wildmeshing/wmtk/components/wildmeshing/internal/wildmeshing3d.cpp +++ b/components/wildmeshing/wmtk/components/wildmeshing/internal/wildmeshing3d.cpp @@ -572,11 +572,13 @@ std::vector, std::string>> wildmeshing3d( split_sequence->set_priority(long_edges_first); - ops.emplace_back(split_sequence); - ops_name.emplace_back("SPLIT"); + if (!options.skip_split) { + ops.emplace_back(split_sequence); + ops_name.emplace_back("SPLIT"); - ops.emplace_back(rounding); - ops_name.emplace_back("rounding"); + ops.emplace_back(rounding); + ops_name.emplace_back("rounding"); + } ////////////////////////////////// @@ -675,11 +677,13 @@ std::vector, std::string>> wildmeshing3d( collapse_then_round->add_transfer_strategy(s); } - ops.emplace_back(collapse_then_round); - ops_name.emplace_back("COLLAPSE"); + if (!options.skip_collapse) { + ops.emplace_back(collapse_then_round); + ops_name.emplace_back("COLLAPSE"); - ops.emplace_back(rounding); - ops_name.emplace_back("rounding"); + ops.emplace_back(rounding); + ops_name.emplace_back("rounding"); + } ////////////////////////////////// // 3) Swap @@ -1058,11 +1062,12 @@ std::vector, std::string>> wildmeshing3d( swap_then_round->add_transfer_strategy(s); } - ops.push_back(swap_then_round); - ops_name.push_back("EDGE SWAP"); - ops.emplace_back(rounding); - ops_name.emplace_back("rounding"); - + if (!options.skip_swap) { + ops.push_back(swap_then_round); + ops_name.push_back("EDGE SWAP"); + ops.emplace_back(rounding); + ops_name.emplace_back("rounding"); + } // 4) Smoothing // ////////////////////////////////////// @@ -1148,13 +1153,16 @@ std::vector, std::string>> wildmeshing3d( } // proj_smoothing->add_transfer_strategy(target_edge_length_update); - for (int i = 0; i < 1; ++i) { - ops.push_back(proj_smoothing); - ops_name.push_back("SMOOTHING"); - } + if (!options.skip_smooth) { + for (int i = 0; i < 1; ++i) { + // some old code to do smoothing several times, maybe useful later + ops.push_back(proj_smoothing); + ops_name.push_back("SMOOTHING"); + } - ops.emplace_back(rounding); - ops_name.emplace_back("rounding"); + ops.emplace_back(rounding); + ops_name.emplace_back("rounding"); + } write( mesh,