diff --git a/CMakeLists.txt b/CMakeLists.txt index a16ae7c3f2..00b1d88e42 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,7 +75,6 @@ include(onetbb) include(mshio) include(metis) include(gmp) -include(lagrange) include(libigl) include(spdlog) include(paraviewo) @@ -134,7 +133,6 @@ target_link_libraries(wildmeshing_toolkit PUBLIC TBB::tbb mshio::mshio metis::metis - lagrange::core nlohmann_json::nlohmann_json nanoflann::nanoflann paraviewo::paraviewo diff --git a/cmake/recipes/lagrange.cmake b/cmake/recipes/lagrange.cmake deleted file mode 100644 index 3e0ee44a85..0000000000 --- a/cmake/recipes/lagrange.cmake +++ /dev/null @@ -1,11 +0,0 @@ -if(TARGET lagrange::core) - return() -endif() - -include(FetchContent) -FetchContent_Declare( - lagrange - GIT_REPOSITORY https://github.com/adobe/lagrange.git - GIT_TAG v6.35.0 -) -FetchContent_MakeAvailable(lagrange) diff --git a/cmake/recipes/spdlog.cmake b/cmake/recipes/spdlog.cmake index 0cf7f57347..08254ae995 100644 --- a/cmake/recipes/spdlog.cmake +++ b/cmake/recipes/spdlog.cmake @@ -9,28 +9,20 @@ # OF ANY KIND, either express or implied. See the License for the specific language # governing permissions and limitations under the License. # - -# MIT - if(TARGET spdlog::spdlog) return() endif() message(STATUS "Third-party (external): creating target 'spdlog::spdlog'") -include(FetchContent) -FetchContent_Declare( - spdlog - URL https://github.com/gabime/spdlog/archive/refs/tags/v1.9.2.zip - URL_HASH MD5=a3d2fb9e5c811ba100380aa82d48f989 +include(CPM) +CPMAddPackage( + NAME spdlog + GITHUB_REPOSITORY gabime/spdlog + GIT_TAG v1.17.0 ) -option(SPDLOG_INSTALL "Generate the install target" ON) -set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "spdlog") -FetchContent_MakeAvailable(spdlog) - set_target_properties(spdlog PROPERTIES POSITION_INDEPENDENT_CODE ON) - set_target_properties(spdlog PROPERTIES FOLDER third_party) if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang" OR diff --git a/cmake/wmtk_data.cmake b/cmake/wmtk_data.cmake index 33c2b4e2f2..cc6ada593c 100644 --- a/cmake/wmtk_data.cmake +++ b/cmake/wmtk_data.cmake @@ -16,7 +16,7 @@ ExternalProject_Add( SOURCE_DIR ${WMTK_DATA_ROOT} GIT_REPOSITORY https://github.com/wildmeshing/data2.git - GIT_TAG f2bd8ed5e8af5a125ee4d92cd0af8f32cec60e02 + GIT_TAG f21aa84d50a3ac6ffb3b04daf8a3e132b24803b0 CONFIGURE_COMMAND "" BUILD_COMMAND "" diff --git a/cmake/wmtk_warnings.cmake b/cmake/wmtk_warnings.cmake index 7a5fe4dd8b..ead70e5200 100644 --- a/cmake/wmtk_warnings.cmake +++ b/cmake/wmtk_warnings.cmake @@ -29,7 +29,7 @@ set(MY_FLAGS -Werror=nonnull -Werror=init-self -Werror=main - -Werror=missing-braces + -Werror=no-missing-braces -Werror=sequence-point -Werror=return-type -Werror=trigraphs diff --git a/components/image_simulation/wmtk/components/image_simulation/EdgeSwapping.cpp b/components/image_simulation/wmtk/components/image_simulation/EdgeSwapping.cpp index 72051e3505..dae6af2c03 100644 --- a/components/image_simulation/wmtk/components/image_simulation/EdgeSwapping.cpp +++ b/components/image_simulation/wmtk/components/image_simulation/EdgeSwapping.cpp @@ -251,7 +251,7 @@ bool ImageSimulationMesh::swap_face_before(const Tuple& t) const size_t v2 = tt.switch_edge().switch_vertex().vid(); const size_t v3 = tt.switch_face().switch_edge().switch_vertex().vid(); - std::array tri{v0, v1, v2}; + std::array tri{{v0, v1, v2}}; for (auto i = 0; i < 3; i++) { std::array new_tet = t1_vids; diff --git a/components/image_simulation/wmtk/components/image_simulation/EmbedSurface.cpp b/components/image_simulation/wmtk/components/image_simulation/EmbedSurface.cpp index d984c0aa8b..7dedc5ff46 100644 --- a/components/image_simulation/wmtk/components/image_simulation/EmbedSurface.cpp +++ b/components/image_simulation/wmtk/components/image_simulation/EmbedSurface.cpp @@ -17,8 +17,6 @@ #include #include #include -#include -#include #include #include @@ -55,9 +53,7 @@ std::vector> triangulate_polygon_face(std::vector t = { - size_t(cur.second), - size_t(next.second), - size_t(nextnext.second)}; + {size_t(cur.second), size_t(next.second), size_t(nextnext.second)}}; triangulated_faces.push_back(t); points_vector.erase(points_vector.begin() + ((i + 1) % points_vector.size())); break; @@ -74,9 +70,9 @@ std::vector> triangulate_polygon_face(std::vector= 3) { std::array t = { - size_t(points_vector[0].second), - size_t(points_vector[1].second), - size_t(points_vector[points_vector.size() - 1].second)}; + {size_t(points_vector[0].second), + size_t(points_vector[1].second), + size_t(points_vector[points_vector.size() - 1].second)}}; triangulated_faces.push_back(t); points_vector.erase(points_vector.begin()); } @@ -327,9 +323,7 @@ void embed_surface( if (polygon_face.size() == 3) { // already a triangle std::array triangle_face = { - polygon_face[0], - polygon_face[1], - polygon_face[2]}; + {polygon_face[0], polygon_face[1], polygon_face[2]}}; int idx = triangulated_faces.size(); triangulated_faces.push_back(triangle_face); if (polygon_faces_on_input_surface[i]) { @@ -348,9 +342,9 @@ void embed_surface( for (int j = 0; j < clipped_indices.size(); j++) { // need to map oldface index to new face indices std::array triangle_face = { - polygon_face[clipped_indices[j][0]], - polygon_face[clipped_indices[j][1]], - polygon_face[clipped_indices[j][2]]}; + {polygon_face[clipped_indices[j][0]], + polygon_face[clipped_indices[j][1]], + polygon_face[clipped_indices[j][2]]}}; int idx = triangulated_faces.size(); triangulated_faces.push_back(triangle_face); @@ -404,14 +398,14 @@ void embed_surface( } } - std::array tetra = {v0, v1, v2, v3}; + std::array tetra = {{v0, v1, v2, v3}}; // if inverted then fix the orientation Vector3r v0v1 = v_rational[v1] - v_rational[v0]; Vector3r v0v2 = v_rational[v2] - v_rational[v0]; Vector3r v0v3 = v_rational[v3] - v_rational[v0]; if ((v0v1.cross(v0v2)).dot(v0v3) < 0) { - tetra = {v1, v0, v2, v3}; + tetra = {{v1, v0, v2, v3}}; } // push the tet to final queue; @@ -467,20 +461,20 @@ void embed_surface( for (const size_t f : polygon_cell) { for (const size_t t : map_poly_to_tri_face[f]) { std::array tetra = { - triangulated_faces[t][0], - triangulated_faces[t][1], - triangulated_faces[t][2], - centroid_idx}; + {triangulated_faces[t][0], + triangulated_faces[t][1], + triangulated_faces[t][2], + centroid_idx}}; // check inverted tet and fix Vector3r v0v1 = v_rational[tetra[1]] - v_rational[tetra[0]]; Vector3r v0v2 = v_rational[tetra[2]] - v_rational[tetra[0]]; Vector3r v0v3 = v_rational[tetra[3]] - v_rational[tetra[0]]; if ((v0v1.cross(v0v2)).dot(v0v3) < 0) { tetra = { - triangulated_faces[t][1], - triangulated_faces[t][0], - triangulated_faces[t][2], - centroid_idx}; + {triangulated_faces[t][1], + triangulated_faces[t][0], + triangulated_faces[t][2], + centroid_idx}}; } tets_final.push_back(tetra); @@ -605,9 +599,7 @@ EmbedSurface::EmbedSurface( std::vector verts; std::vector> tris; - verts.resize(V.rows()); - tris.resize(F.rows()); - wmtk::eigen_to_wmtk_input(verts, tris, V, F); + VF_to_vectors(V, F, verts, tris); V_surf_from_vector(verts); F_surf_from_vector(tris); diff --git a/components/image_simulation/wmtk/components/image_simulation/ImageSimulationMesh.cpp b/components/image_simulation/wmtk/components/image_simulation/ImageSimulationMesh.cpp index ad81fe6dd0..c89706f5c1 100644 --- a/components/image_simulation/wmtk/components/image_simulation/ImageSimulationMesh.cpp +++ b/components/image_simulation/wmtk/components/image_simulation/ImageSimulationMesh.cpp @@ -1238,7 +1238,7 @@ size_t ImageSimulationMesh::get_order_of_vertex(const size_t vid) const void ImageSimulationMesh::init_vertex_order() { - std::array count{0, 0, 0, 0}; + std::array count{{0, 0, 0, 0}}; for (const Tuple& t : get_vertices()) { const size_t vid = t.vid(*this); diff --git a/components/image_simulation/wmtk/components/image_simulation/ImageSimulationMeshTri.cpp b/components/image_simulation/wmtk/components/image_simulation/ImageSimulationMeshTri.cpp index 9eef337b0b..5bdb1cd220 100644 --- a/components/image_simulation/wmtk/components/image_simulation/ImageSimulationMeshTri.cpp +++ b/components/image_simulation/wmtk/components/image_simulation/ImageSimulationMeshTri.cpp @@ -279,8 +279,7 @@ void ImageSimulationMeshTri::init_surfaces_and_boundaries() const auto surf_edges = get_edges_by_condition([](auto& f) { return f.m_is_surface_fs; }); for (const auto& verts : surf_edges) { std::array pp = { - m_vertex_attribute[verts[0]].m_pos, - m_vertex_attribute[verts[1]].m_pos}; + {m_vertex_attribute[verts[0]].m_pos, m_vertex_attribute[verts[1]].m_pos}}; if (m_envelope->is_outside(pp)) { log_and_throw_error("Edge {} is outside!", verts); } @@ -1239,7 +1238,7 @@ bool ImageSimulationMeshTri::collapse_edge_after(const Tuple& loc) const Vector2d a = VA.at(vids[0]).m_pos; const Vector2d b = VA.at(vids[1]).m_pos; // surface envelope - bool is_out = m_envelope->is_outside(std::array{a, b}); + bool is_out = m_envelope->is_outside(std::array{{a, b}}); if (is_out) { return false; } @@ -1854,7 +1853,7 @@ std::tuple ImageSimulationMeshTri::local_operations( for (const auto& verts : faces) { const auto& p0 = m_vertex_attribute[verts[0]].m_pos; const auto& p1 = m_vertex_attribute[verts[1]].m_pos; - if (m_envelope->is_outside(std::array{p0, p1})) { + if (m_envelope->is_outside(std::array{{p0, p1}})) { logger().error("Edge {} is outside!", verts); } } diff --git a/components/isotropic_remeshing/wmtk/components/isotropic_remeshing/isotropic_remeshing.cpp b/components/isotropic_remeshing/wmtk/components/isotropic_remeshing/isotropic_remeshing.cpp index c5c0e35175..89c2b91f9a 100644 --- a/components/isotropic_remeshing/wmtk/components/isotropic_remeshing/isotropic_remeshing.cpp +++ b/components/isotropic_remeshing/wmtk/components/isotropic_remeshing/isotropic_remeshing.cpp @@ -4,7 +4,8 @@ #include #include -#include +#include +#include #include #include "IsotropicRemeshing.h" @@ -78,15 +79,16 @@ void isotropic_remeshing(nlohmann::json json_params) std::vector verts; std::vector> tris; std::pair box_minmax; - double remove_duplicate_eps = 1e-5; std::vector modified_nonmanifold_v; - wmtk::stl_to_manifold_wmtk_input( - input_path, - remove_duplicate_eps, - box_minmax, - verts, - tris, - modified_nonmanifold_v); + { + double remove_duplicate_eps = 1e-5; + MatrixXd V; + MatrixXi F; + wmtk::io::read_triangle_mesh(input_path, V, F, remove_duplicate_eps); + box_minmax.first = V.colwise().minCoeff(); + box_minmax.second = V.colwise().maxCoeff(); + VF_to_vectors(V, F, verts, tris); + } double diag = (box_minmax.first - box_minmax.second).norm(); const double envelope_size = env_rel * diag; diff --git a/components/isotropic_remeshing/wmtk/components/isotropic_remeshing/tests/test_remeshing.cpp b/components/isotropic_remeshing/wmtk/components/isotropic_remeshing/tests/test_remeshing.cpp index 304bc6e00b..f9ba0ef5cf 100644 --- a/components/isotropic_remeshing/wmtk/components/isotropic_remeshing/tests/test_remeshing.cpp +++ b/components/isotropic_remeshing/wmtk/components/isotropic_remeshing/tests/test_remeshing.cpp @@ -4,7 +4,6 @@ #include #include #include -#include using namespace wmtk; using namespace components::isotropic_remeshing; @@ -83,8 +82,12 @@ TEST_CASE("test_swap", "[test_remeshing]") std::vector new_e; int cnt = 0; for (auto edge : edges) { - if (cnt > 200) break; - if (!edge.is_valid(m)) continue; + if (cnt > 200) { + break; + } + if (!edge.is_valid(m)) { + continue; + } if (!(edge.switch_face(m)).has_value()) { REQUIRE_FALSE(m.swap_edge(edge, new_e)); continue; @@ -158,11 +161,6 @@ TEST_CASE("remeshing_hanging", "[test_remeshing]") const double envelope_size = env_rel * diag; Eigen::VectorXi dummy; std::vector modified_v; - if (!igl::is_edge_manifold(F) || !igl::is_vertex_manifold(F, dummy)) { - auto v1 = v; - auto tri1 = tri; - wmtk::separate_to_manifold(v1, tri1, v, tri, modified_v); - } IsotropicRemeshing m(v, thread); m.create_mesh(v.size(), tri, modified_v, envelope_size); diff --git a/components/qslim/wmtk/components/qslim/qslim.cpp b/components/qslim/wmtk/components/qslim/qslim.cpp index fbf6dab4ac..db1d823f7d 100644 --- a/components/qslim/wmtk/components/qslim/qslim.cpp +++ b/components/qslim/wmtk/components/qslim/qslim.cpp @@ -1,9 +1,9 @@ #include "qslim.hpp" #include -#include #include -#include +#include +#include #include #include "QSlimMesh.h" @@ -62,18 +62,20 @@ void qslim(nlohmann::json json_params) const int num_thread = json_params["num_threads"]; double target_abs = json_params["target_abs"]; + const double remove_duplicate_eps = 1e-5; + MatrixXd V; + MatrixXi F; + io::read_triangle_mesh(input_path, V, F, remove_duplicate_eps); + std::vector verts; std::vector> tris; std::pair box_minmax; - const double remove_duplicate_esp = 1e-5; std::vector modified_nonmanifold_v; - stl_to_manifold_wmtk_input( - input_path, - remove_duplicate_esp, - box_minmax, - verts, - tris, - modified_nonmanifold_v); + + box_minmax.first = V.colwise().minCoeff(); + box_minmax.second = V.colwise().maxCoeff(); + VF_to_vectors(V, F, verts, tris); + const double diag = (box_minmax.first - box_minmax.second).norm(); const double envelope_size = env_rel * diag; diff --git a/components/shortest_edge_collapse/wmtk/components/shortest_edge_collapse/shortest_edge_collapse.cpp b/components/shortest_edge_collapse/wmtk/components/shortest_edge_collapse/shortest_edge_collapse.cpp index 3b80137e2e..18c7015906 100644 --- a/components/shortest_edge_collapse/wmtk/components/shortest_edge_collapse/shortest_edge_collapse.cpp +++ b/components/shortest_edge_collapse/wmtk/components/shortest_edge_collapse/shortest_edge_collapse.cpp @@ -1,6 +1,3 @@ - -#include - #include #include @@ -91,11 +88,6 @@ void shortest_edge_collapse(nlohmann::json json_params) const double envelope_size = env_rel * diag; VectorXi dummy; std::vector modified_v; - // if (!igl::is_edge_manifold(F) || !igl::is_vertex_manifold(F, dummy)) { - // auto v1 = v; - // auto tri1 = tri; - // wmtk::separate_to_manifold(v1, tri1, v, tri, modified_v); - // } ShortestEdgeCollapse m(v, num_threads, !use_sample_envelope); m.create_mesh(v.size(), tri, modified_v, envelope_size); diff --git a/components/shortest_edge_collapse/wmtk/components/shortest_edge_collapse/tests/test_sec.cpp b/components/shortest_edge_collapse/wmtk/components/shortest_edge_collapse/tests/test_sec.cpp index 296ca2b2f1..3e576cdee7 100644 --- a/components/shortest_edge_collapse/wmtk/components/shortest_edge_collapse/tests/test_sec.cpp +++ b/components/shortest_edge_collapse/wmtk/components/shortest_edge_collapse/tests/test_sec.cpp @@ -1,5 +1,4 @@ #include -#include #include #include @@ -28,10 +27,9 @@ TEST_CASE("separate-manifold-patch", "[test_sec]") {{0, 1, 4}}, }}; - std::vector out_v; - std::vector> out_f; + std::vector out_v = v; + std::vector> out_f = tris; std::vector freeze_v; - wmtk::separate_to_manifold(v, tris, out_v, out_f, freeze_v); REQUIRE(out_v.size() == 9); REQUIRE(out_f.size() == 3); diff --git a/components/tetwild/wmtk/components/tetwild/EdgeSwapping.cpp b/components/tetwild/wmtk/components/tetwild/EdgeSwapping.cpp index 8e79c0efc3..e3f5a5418d 100644 --- a/components/tetwild/wmtk/components/tetwild/EdgeSwapping.cpp +++ b/components/tetwild/wmtk/components/tetwild/EdgeSwapping.cpp @@ -239,7 +239,7 @@ bool TetWildMesh::swap_face_before(const Tuple& t) const size_t v2 = tt.switch_edge().switch_vertex().vid(); const size_t v3 = tt.switch_face().switch_edge().switch_vertex().vid(); - std::array tri{v0, v1, v2}; + std::array tri{{v0, v1, v2}}; for (auto i = 0; i < 3; i++) { std::array new_tet = t1_vids; diff --git a/components/tetwild/wmtk/components/tetwild/TriangleInsertion.cpp b/components/tetwild/wmtk/components/tetwild/TriangleInsertion.cpp index 99a05b06b3..dcd94eb8e1 100644 --- a/components/tetwild/wmtk/components/tetwild/TriangleInsertion.cpp +++ b/components/tetwild/wmtk/components/tetwild/TriangleInsertion.cpp @@ -413,9 +413,9 @@ void TetWildMesh::finalize_triangle_insertion(const std::vector tri = { - m_vertex_attribute[faces[input_fid][0]].m_pos, - m_vertex_attribute[faces[input_fid][1]].m_pos, - m_vertex_attribute[faces[input_fid][2]].m_pos}; + {m_vertex_attribute[faces[input_fid][0]].m_pos, + m_vertex_attribute[faces[input_fid][1]].m_pos, + m_vertex_attribute[faces[input_fid][2]].m_pos}}; if (projected_point_in_triangle(c, tri)) { auto [_, global_tet_fid] = tuple_from_face(vids); m_face_attribute[global_tet_fid].m_is_surface_fs = 1; diff --git a/components/tetwild/wmtk/components/tetwild/VolumemesherInsertion.cpp b/components/tetwild/wmtk/components/tetwild/VolumemesherInsertion.cpp index 92a13ec30e..adb6f3a7cc 100644 --- a/components/tetwild/wmtk/components/tetwild/VolumemesherInsertion.cpp +++ b/components/tetwild/wmtk/components/tetwild/VolumemesherInsertion.cpp @@ -234,9 +234,7 @@ std::vector> TetWildMesh::triangulate_polygon_face( (b[0] * c[2] - b[2] * c[0]) != 0))) { no_colinear = false; std::array t = { - size_t(cur.second), - size_t(next.second), - size_t(nextnext.second)}; + {size_t(cur.second), size_t(next.second), size_t(nextnext.second)}}; triangulated_faces.push_back(t); points_vector.erase(points_vector.begin() + ((i + 1) % points_vector.size())); break; @@ -251,9 +249,9 @@ std::vector> TetWildMesh::triangulate_polygon_face( // cleanup convex polygon while (points_vector.size() >= 3) { std::array t = { - size_t(points_vector[0].second), - size_t(points_vector[1].second), - size_t(points_vector[points_vector.size() - 1].second)}; + {size_t(points_vector[0].second), + size_t(points_vector[1].second), + size_t(points_vector[points_vector.size() - 1].second)}}; triangulated_faces.push_back(t); points_vector.erase(points_vector.begin()); } @@ -601,9 +599,7 @@ void TetWildMesh::insertion_by_volumeremesher_old( if (polygon_face.size() == 3) { // already a triangle std::array triangle_face = { - polygon_face[0], - polygon_face[1], - polygon_face[2]}; + {polygon_face[0], polygon_face[1], polygon_face[2]}}; size_t idx = triangulated_faces.size(); triangulated_faces.push_back(triangle_face); if (polygon_faces_on_input_surface[i]) { @@ -632,9 +628,9 @@ void TetWildMesh::insertion_by_volumeremesher_old( for (int j = 0; j < clipped_indices.size(); j++) { // need to map oldface index to new face indices std::array triangle_face = { - polygon_face[clipped_indices[j][0]], - polygon_face[clipped_indices[j][1]], - polygon_face[clipped_indices[j][2]]}; + {polygon_face[clipped_indices[j][0]], + polygon_face[clipped_indices[j][1]], + polygon_face[clipped_indices[j][2]]}}; // std::cout< tetra = {v0, v1, v2, v3}; + std::array tetra = {{v0, v1, v2, v3}}; // if inverted then fix the orientation Vector3r v0v1 = v_rational[v1] - v_rational[v0]; Vector3r v0v2 = v_rational[v2] - v_rational[v0]; Vector3r v0v3 = v_rational[v3] - v_rational[v0]; if ((v0v1.cross(v0v2)).dot(v0v3) < 0) { - tetra = {v1, v0, v2, v3}; + tetra = {{v1, v0, v2, v3}}; } // push the tet to final queue; @@ -786,10 +782,10 @@ void TetWildMesh::insertion_by_volumeremesher_old( for (auto f : polygon_cell) { for (auto t : map_poly_to_tri_face[f]) { std::array tetra = { - triangulated_faces[t][0], - triangulated_faces[t][1], - triangulated_faces[t][2], - centroid_idx}; + {triangulated_faces[t][0], + triangulated_faces[t][1], + triangulated_faces[t][2], + centroid_idx}}; // std::sort(tetra.begin(), tetra.end()); // check inverted tet and fix Vector3r v0v1 = v_rational[tetra[1]] - v_rational[tetra[0]]; @@ -797,10 +793,10 @@ void TetWildMesh::insertion_by_volumeremesher_old( Vector3r v0v3 = v_rational[tetra[3]] - v_rational[tetra[0]]; if ((v0v1.cross(v0v2)).dot(v0v3) < 0) { tetra = { - triangulated_faces[t][1], - triangulated_faces[t][0], - triangulated_faces[t][2], - centroid_idx}; + {triangulated_faces[t][1], + triangulated_faces[t][0], + triangulated_faces[t][2], + centroid_idx}}; } tets_final.push_back(tetra); @@ -1582,7 +1578,7 @@ void TetWildMesh::init_from_Volumeremesher( init_vertex_order(); { - std::array vo{0, 0, 0, 0}; + std::array vo{{0, 0, 0, 0}}; const auto vs = get_vertices(); for (const Tuple& t : vs) { const size_t o = m_vertex_attribute.at(t.vid(*this)).m_order; diff --git a/components/tetwild/wmtk/components/tetwild/orig/EdgeCollapser.cpp b/components/tetwild/wmtk/components/tetwild/orig/EdgeCollapser.cpp index 3c10c922cc..cb0f918a8c 100644 --- a/components/tetwild/wmtk/components/tetwild/orig/EdgeCollapser.cpp +++ b/components/tetwild/wmtk/components/tetwild/orig/EdgeCollapser.cpp @@ -517,9 +517,9 @@ bool EdgeCollapser::isCollapsable_epsilon(int v1_id, int v2_id) auto jt = std::find(tri_ids[i].begin(), tri_ids[i].end(), v1_id); *jt = v2_id; // replace v1 with v2 std::array tri{ - tet_vertices[tri_ids[i][0]].posf, - tet_vertices[tri_ids[i][1]].posf, - tet_vertices[tri_ids[i][2]].posf}; + {tet_vertices[tri_ids[i][0]].posf, + tet_vertices[tri_ids[i][1]].posf, + tet_vertices[tri_ids[i][2]].posf}}; tris.push_back(tri); } diff --git a/components/tetwild/wmtk/components/tetwild/orig/VertexSmoother.cpp b/components/tetwild/wmtk/components/tetwild/orig/VertexSmoother.cpp index 039610a9be..0b2ea1cbb2 100644 --- a/components/tetwild/wmtk/components/tetwild/orig/VertexSmoother.cpp +++ b/components/tetwild/wmtk/components/tetwild/orig/VertexSmoother.cpp @@ -365,9 +365,9 @@ void VertexSmoother::smoothSurface() auto jt = std::find(tri_ids[i].begin(), tri_ids[i].end(), v_id); int k = jt - tri_ids[i].begin(); std::array tri{ - to_double(p), - tet_vertices[tri_ids[i][(k + 1) % 3]].posf, - tet_vertices[tri_ids[i][(k + 2) % 3]].posf}; + {to_double(p), + tet_vertices[tri_ids[i][(k + 1) % 3]].posf, + tet_vertices[tri_ids[i][(k + 2) % 3]].posf}}; trisf.push_back(tri); } diff --git a/components/tetwild/wmtk/components/tetwild/tetwild.cpp b/components/tetwild/wmtk/components/tetwild/tetwild.cpp index fdf0900f18..d985e9c691 100644 --- a/components/tetwild/wmtk/components/tetwild/tetwild.cpp +++ b/components/tetwild/wmtk/components/tetwild/tetwild.cpp @@ -6,13 +6,12 @@ #include #include #include -#include +#include #include #include #include #include -#include #include #include #include "wmtk/utils/InsertTriangleUtils.hpp" @@ -134,33 +133,16 @@ TetWildMesh::ExportStruct tetwild_with_export(nlohmann::json json_params) std::vector verts; std::vector> tris; std::pair box_minmax; - // double remove_duplicate_esp = params.epsr; - double remove_duplicate_esp = 2e-3; std::vector modified_nonmanifold_v; - wmtk::stl_to_manifold_wmtk_input( - input_paths, - remove_duplicate_esp, - box_minmax, - verts, - tris, - modified_nonmanifold_v); - - // rotate by an arbitrary angle - // double theta = M_PI * 0.2; - // Eigen::Matrix3d rotation_m; - // rotation_m << 1, 0, 0, 0, cos(theta), -sin(theta), 0, sin(theta), cos(theta); - - // box_minmax.first = Eigen::Vector3d(10000, 10000, 10000); - // box_minmax.second = Eigen::Vector3d(-10000, -10000, -10000); - // for (size_t i = 0; i < verts.size(); i++) { - // verts[i] = rotation_m * verts[i]; - // if (verts[i][0] < box_minmax.first[0]) box_minmax.first[0] = verts[i][0]; - // if (verts[i][1] < box_minmax.first[1]) box_minmax.first[1] = verts[i][1]; - // if (verts[i][2] < box_minmax.first[0]) box_minmax.first[2] = verts[i][2]; - // if (verts[i][0] > box_minmax.second[0]) box_minmax.second[0] = verts[i][0]; - // if (verts[i][1] > box_minmax.second[1]) box_minmax.second[1] = verts[i][1]; - // if (verts[i][2] > box_minmax.second[2]) box_minmax.second[2] = verts[i][2]; - // } + { + double remove_duplicate_eps = 2e-3; + MatrixXd V; + MatrixXi F; + io::read_triangle_mesh(input_paths, V, F, remove_duplicate_eps); + box_minmax.first = V.colwise().minCoeff(); + box_minmax.second = V.colwise().maxCoeff(); + VF_to_vectors(V, F, verts, tris); + } { Eigen::MatrixXi F(tris.size(), 3); diff --git a/components/triwild/wmtk/components/triwild/EdgeCollapsing.cpp b/components/triwild/wmtk/components/triwild/EdgeCollapsing.cpp index dfa1e818cd..25b72ff792 100644 --- a/components/triwild/wmtk/components/triwild/EdgeCollapsing.cpp +++ b/components/triwild/wmtk/components/triwild/EdgeCollapsing.cpp @@ -127,7 +127,7 @@ bool TriWildMesh::collapse_edge_before(const Tuple& loc) // input is an edge if (VA[v2_id].m_is_on_surface && !m_edge_attribute.at(eid).m_is_surface_fs) { const Vector2d& p1 = VA[v1_id].m_posf; const Vector2d& p2 = VA[v2_id].m_posf; - if (m_envelope->is_outside(std::array{p1, p2})) { + if (m_envelope->is_outside(std::array{{p1, p2}})) { return false; } } @@ -266,7 +266,7 @@ bool TriWildMesh::collapse_edge_after(const Tuple& loc) const Vector2d a = VA.at(vids[0]).m_posf; const Vector2d b = VA.at(vids[1]).m_posf; // surface envelope - bool is_out = m_envelope->is_outside(std::array{a, b}); + bool is_out = m_envelope->is_outside(std::array{{a, b}}); if (is_out) { return false; } diff --git a/components/triwild/wmtk/components/triwild/TriWildMesh.cpp b/components/triwild/wmtk/components/triwild/TriWildMesh.cpp index bb5eb91eeb..7e244b4b12 100644 --- a/components/triwild/wmtk/components/triwild/TriWildMesh.cpp +++ b/components/triwild/wmtk/components/triwild/TriWildMesh.cpp @@ -119,7 +119,7 @@ std::tuple TriWildMesh::local_operations( for (const auto& verts : faces) { const auto& p0 = m_vertex_attribute[verts[0]].m_posf; const auto& p1 = m_vertex_attribute[verts[1]].m_posf; - if (m_envelope->is_outside(std::array{p0, p1})) { + if (m_envelope->is_outside(std::array{{p0, p1}})) { logger().error("Edge {} is outside!", verts); } } @@ -238,7 +238,7 @@ void TriWildMesh::init_mesh(const MatrixXd& V, const MatrixXi& F, const MatrixXi // mark edges as on surface if they are in E for (int i = 0; i < E.rows(); i++) { - std::array vids = {(size_t)E(i, 0), (size_t)E(i, 1)}; + std::array vids = {{(size_t)E(i, 0), (size_t)E(i, 1)}}; const auto [e, eid] = tuple_from_edge(vids); if (!e.is_valid(*this)) { log_and_throw_error("Edge {} in E is not found in the mesh!", vids); @@ -272,8 +272,7 @@ void TriWildMesh::init_mesh(const MatrixXd& V, const MatrixXi& F, const MatrixXi const auto surf_edges = get_edges_by_condition([](auto& f) { return f.m_is_surface_fs; }); for (const auto& verts : surf_edges) { std::array pp = { - m_vertex_attribute[verts[0]].m_posf, - m_vertex_attribute[verts[1]].m_posf}; + {m_vertex_attribute[verts[0]].m_posf, m_vertex_attribute[verts[1]].m_posf}}; if (m_envelope->is_outside(pp)) { log_and_throw_error("Edge {} is outside!", verts); } diff --git a/src/wmtk/TetMesh.h b/src/wmtk/TetMesh.h index a43f4d0e15..c078c25633 100644 --- a/src/wmtk/TetMesh.h +++ b/src/wmtk/TetMesh.h @@ -198,8 +198,8 @@ class TetMesh */ class SmartTuple { - Tuple m_tuple; const TetMesh& m_mesh; + Tuple m_tuple; public: SmartTuple(const TetMesh& mesh, const Tuple& t) diff --git a/src/wmtk/TetMeshSubstructure.cpp b/src/wmtk/TetMeshSubstructure.cpp index 394cce499a..bf20ffcbd7 100644 --- a/src/wmtk/TetMeshSubstructure.cpp +++ b/src/wmtk/TetMeshSubstructure.cpp @@ -126,7 +126,7 @@ size_t TetMesh::compute_vertex_order(const size_t vid) const const auto vvs = get_one_ring_vids_for_vertex(vid); std::map edge_orders_count; for (const size_t v : vvs) { - const size_t nf = get_num_surface_faces_for_edge({v, vid}); + const size_t nf = get_num_surface_faces_for_edge({{v, vid}}); if (nf == 0 || nf == 2) { continue; } diff --git a/src/wmtk/TriMesh.cpp b/src/wmtk/TriMesh.cpp index e30ec65335..abc8ac7a0c 100644 --- a/src/wmtk/TriMesh.cpp +++ b/src/wmtk/TriMesh.cpp @@ -1324,12 +1324,12 @@ std::array TriMesh::oriented_tri_vids(const size_t fid) const std::array TriMesh::get_edge_vertices(const Tuple& t) const { - return std::array{t, t.switch_vertex(*this)}; + return std::array{{t, t.switch_vertex(*this)}}; } std::array TriMesh::get_edge_vids(const Tuple& t) const { - return std::array{t.vid(*this), t.switch_vertex(*this).vid(*this)}; + return std::array{{t.vid(*this), t.switch_vertex(*this).vid(*this)}}; } std::tuple TriMesh::tuple_from_edge(const std::array& vids) const @@ -1987,7 +1987,7 @@ void wmtk::TriMesh::for_each_face(const std::function #include #include +#include #include namespace wmtk::io { -void read_triangle_mesh( - const std::string& path, - Eigen::MatrixXd& V, - Eigen::MatrixXi& F, - double tol_rel, - double tol_abs) +/** + * @brief Clean the input triangle mesh by removing duplicated vertices, degenerate faces, and + * unreferenced vertices. + * + * @param V Input vertex positions. Will be modified in-place to remove duplicated and unreferenced + * vertices. + * @param F Input face indices. Will be modified in-place to remove degenerate faces and update + * vertex indices after removing duplicated vertices. + * @param tol_rel Relative tolerance for identifying duplicated vertices. If non-negative, tol_abs + * will be ignored and tol_rel * diag will be used as the absolute tolerance, where diag is the + * diagonal length of the bounding box of the input mesh. + * @param tol_abs Absolute tolerance for identifying duplicated vertices. If non-negative, vertices + * that are within this distance will be considered duplicates and merged. If negative, no vertex + * merging will be performed. + */ +void clean_triangle_mesh(MatrixXd& V, MatrixXi& F, double tol_rel = -1, double tol_abs = -1) { if (tol_abs >= 0 && tol_rel >= 0) { log_and_throw_error( @@ -23,10 +34,6 @@ void read_triangle_mesh( tol_rel); } - if (!igl::read_triangle_mesh(path, V, F)) { - log_and_throw_error("Could not read mesh {}", path); - } - if (tol_abs < 0 && tol_rel >= 0) { const MatrixXd box_min = V.colwise().minCoeff(); const MatrixXd box_max = V.colwise().maxCoeff(); @@ -84,4 +91,53 @@ void read_triangle_mesh( } } +void read_triangle_mesh( + const std::string& path, + Eigen::MatrixXd& V, + Eigen::MatrixXi& F, + double tol_rel, + double tol_abs) +{ + if (!igl::read_triangle_mesh(path, V, F)) { + log_and_throw_error("Could not read mesh {}", path); + } + + clean_triangle_mesh(V, F, tol_rel, tol_abs); +} + +void read_triangle_mesh( + const std::vector& paths, + Eigen::MatrixXd& V, + Eigen::MatrixXi& F, + double tol_rel, + double tol_abs) +{ + V.resize(0, 3); + F.resize(0, 3); + for (const std::string& p : paths) { + if (!std::filesystem::exists(p)) { + log_and_throw_error("File {} does not exist", p); + } + MatrixXd V_single; + MatrixXi F_single; + if (!igl::read_triangle_mesh(p, V_single, F_single)) { + log_and_throw_error("Could not read mesh {}", p); + } + assert(V_single.cols() == 3); + assert(F_single.cols() == 3); + + const int nV_old = V.rows(); + const int nF_old = F.rows(); + + V.conservativeResize(V.rows() + V_single.rows(), 3); + V.block(nV_old, 0, V_single.rows(), 3) = V_single; + + F_single.array() += nV_old; + F.conservativeResize(F.rows() + F_single.rows(), 3); + F.block(nF_old, 0, F_single.rows(), 3) = F_single; + } + + clean_triangle_mesh(V, F, tol_rel, tol_abs); +} + } // namespace wmtk::io \ No newline at end of file diff --git a/src/wmtk/io/read_triangle_mesh.hpp b/src/wmtk/io/read_triangle_mesh.hpp index 003a6d5420..9a7d94b041 100644 --- a/src/wmtk/io/read_triangle_mesh.hpp +++ b/src/wmtk/io/read_triangle_mesh.hpp @@ -27,4 +27,11 @@ void read_triangle_mesh( double tol_rel = 2e-4, double tol_abs = -1); +void read_triangle_mesh( + const std::vector& paths, + Eigen::MatrixXd& V, + Eigen::MatrixXi& F, + double tol_rel = 2e-4, + double tol_abs = -1); + } // namespace wmtk::io \ No newline at end of file diff --git a/src/wmtk/utils/InsertTriangleUtils.hpp b/src/wmtk/utils/InsertTriangleUtils.hpp index 9a43e19cf3..8c8ba4b042 100644 --- a/src/wmtk/utils/InsertTriangleUtils.hpp +++ b/src/wmtk/utils/InsertTriangleUtils.hpp @@ -61,9 +61,7 @@ auto triangle_insert_prepare_info( std::set visited; std::array tri = { - vertex_pos_r(face_v[0]), - vertex_pos_r(face_v[1]), - vertex_pos_r(face_v[2])}; + {vertex_pos_r(face_v[0]), vertex_pos_r(face_v[1]), vertex_pos_r(face_v[2])}}; // Vector3r tri_normal = (tri[1] - tri[0]).cross(tri[2] - tri[0]); // diff --git a/src/wmtk/utils/ManifoldUtils.cpp b/src/wmtk/utils/ManifoldUtils.cpp deleted file mode 100644 index 028d389613..0000000000 --- a/src/wmtk/utils/ManifoldUtils.cpp +++ /dev/null @@ -1,105 +0,0 @@ -#include "ManifoldUtils.hpp" -#include - -// clang-format off -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -// clang-format on - -#include - -namespace wmtk::manifold_internal { - -void resolve_nonmanifoldness(Vertices& V, Facets& F, std::vector& modified_vertices) -{ - using Scalar = Vertices::Scalar; - using Index = Facets::Scalar; - using Mesh = lagrange::Mesh; - using AttributeArray = Mesh::AttributeArray; - - constexpr Index Invalid = std::numeric_limits::max(); - - // For this, we assume that sizeof(double) == sizeof(uint64_t), which should be the case on all - // platforms... - static_assert( - sizeof(Scalar) == sizeof(Index), - "Vertex scalar type and facet index type should have the same size"); - auto mesh = lagrange::create_mesh(std::move(V), std::move(F)); - - // Create a vertex attribute to track vertex id - AttributeArray old_vids(mesh->get_num_vertices(), 1); - for (Index v = 0; v < mesh->get_num_vertices(); ++v) { - old_vids(v, 0) = static_cast(v); - } - mesh->add_vertex_attribute("old_vids"); - mesh->import_vertex_attribute("old_vids", std::move(old_vids)); - - const Index old_num_vertices = mesh->get_num_vertices(); - - // Resolve non-manifoldness - mesh = lagrange::resolve_nonmanifoldness(*mesh); - const Index new_num_vertices = mesh->get_num_vertices(); - - // Export vertices + facets + original ids - mesh->export_vertices(V); - mesh->export_facets(F); - mesh->export_vertex_attribute("old_vids", old_vids); - - // Check which vids has been duplicated - std::vector old_to_new(old_num_vertices, Invalid); - std::vector is_vertex_modified(new_num_vertices, false); - for (Index new_idx = 0; new_idx < new_num_vertices; ++new_idx) { - Index old_idx = static_cast(old_vids(new_idx, 0)); - assert(old_idx < old_num_vertices); - if (old_to_new[old_idx] != Invalid) { - is_vertex_modified[old_to_new[old_idx]] = true; - is_vertex_modified[new_idx] = true; - } else { - old_to_new[old_idx] = new_idx; - } - } - - // List all duplicated vertices - modified_vertices.clear(); - for (size_t v = 0; v < is_vertex_modified.size(); ++v) { - if (is_vertex_modified[v]) { - modified_vertices.push_back(v); - } - } -} - -} // namespace wmtk::manifold_internal - -bool wmtk::separate_to_manifold( - const std::vector& vertices, - const std::vector>& faces, - std::vector& out_v, - std::vector>& out_f, - std::vector& mod_v) -{ - using Vertices = wmtk::manifold_internal::Vertices; - using Facets = wmtk::manifold_internal::Facets; - - Vertices V(vertices.size(), 3); - for (auto i = 0; i < vertices.size(); i++) V.row(i) = vertices[i]; - Facets F(faces.size(), 3); - for (auto i = 0; i < faces.size(); i++) F.row(i) << faces[i][0], faces[i][1], faces[i][2]; - - wmtk::manifold_internal::resolve_nonmanifoldness(V, F, mod_v); - - out_v.resize(V.rows()); - out_f.resize(F.rows()); - for (auto i = 0; i < V.rows(); i++) out_v[i] = V.row(i); - for (auto i = 0; i < F.rows(); i++) - out_f[i] = std::array{{(size_t)F(i, 0), (size_t)F(i, 1), (size_t)F(i, 2)}}; - - return true; -} diff --git a/src/wmtk/utils/ManifoldUtils.hpp b/src/wmtk/utils/ManifoldUtils.hpp deleted file mode 100644 index ea87e86e38..0000000000 --- a/src/wmtk/utils/ManifoldUtils.hpp +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once - - -#include -#include -#include - -#include - -namespace wmtk { - -// convert triangle soup to manifold components for TriMesh. -bool separate_to_manifold( - const std::vector& vertices, - const std::vector>& faces, - std::vector& out_v, - std::vector>& out_f, - std::vector& modified_vertices); - -namespace manifold_internal { - -using Vertices = Eigen::Matrix; -using Facets = Eigen::Matrix; - -void resolve_nonmanifoldness(Vertices& V, Facets& F, std::vector& modified_vertices); - -} // namespace manifold_internal - -} // namespace wmtk diff --git a/src/wmtk/utils/Reader.cpp b/src/wmtk/utils/Reader.cpp deleted file mode 100644 index ac33cb3ec9..0000000000 --- a/src/wmtk/utils/Reader.cpp +++ /dev/null @@ -1,217 +0,0 @@ -#include "Reader.hpp" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "Logger.hpp" - -namespace wmtk { -void eigen_to_wmtk_input( - std::vector& verts, - std::vector>& tris, - const Eigen::MatrixXd& V, - const Eigen::MatrixXi& F) -{ - for (int i = 0; i < V.rows(); i++) { - verts[i] = V.row(i); - } - for (int i = 0; i < F.rows(); i++) { - for (int j = 0; j < 3; j++) tris[i][j] = (size_t)F(i, j); - } -} - -void resolve_duplicated_faces(const Eigen::MatrixXi& inF, Eigen::MatrixXi& outF, Eigen::VectorXi& J) -{ - std::map, int> unique; - std::vector newF; - newF.reserve(inF.rows()); - J.resize(inF.rows()); - - for (int i = 0; i < inF.rows(); i++) { - std::array tri; - for (int j = 0; j < 3; j++) { - tri[j] = inF(i, j); - } - - std::sort(tri.begin(), tri.end()); - auto [it, suc] = unique.try_emplace(tri, i); - if (suc) { - newF.emplace_back(inF.row(i)); - } - J[i] = it->second; - } - outF.resize(newF.size(), 3); - for (auto i = 0; i < newF.size(); i++) { - outF.row(i) = newF[i]; - } -} - -void stl_to_manifold_wmtk_input( - std::string input_path, - double remove_duplicate_esp, - std::pair& box_minmax, - std::vector& verts, - std::vector>& tris, - std::vector& modified_nonmanifold_v) -{ - Eigen::MatrixXd inV, V; - Eigen::MatrixXi inF, F; - if (!igl::read_triangle_mesh(input_path, inV, inF)) { - log_and_throw_error("Could not read {}", input_path); - } - Eigen::VectorXi _I; - - igl::remove_unreferenced(inV, inF, V, F, _I); - - if (V.rows() == 0 || F.rows() == 0) { - log_and_throw_error("== finish with Empty Input, stop."); - } - - box_minmax = std::pair(V.colwise().minCoeff(), V.colwise().maxCoeff()); - double diag = (box_minmax.first - box_minmax.second).norm(); - - // using the same error tolerance as in tetwild - Eigen::VectorXi SVI, SVJ, SVK; - Eigen::MatrixXd temp_V = V; // for STL file - igl::remove_duplicate_vertices( - temp_V, - std::min(1e-5, remove_duplicate_esp / 10 * diag), - V, - SVI, - SVJ); - for (int i = 0; i < F.rows(); ++i) { - for (int j = 0; j < 3; ++j) { - F(i, j) = SVJ[F(i, j)]; - } - } - - { - auto F1 = F; - VectorXi J; - resolve_duplicated_faces(F1, F, J); - } - - - verts.resize(V.rows()); - tris.resize(F.rows()); - wmtk::eigen_to_wmtk_input(verts, tris, V, F); - - wmtk::logger().info("after remove duplicate v#: {} f#: {}", V.rows(), F.rows()); - - - Eigen::VectorXi dummy; - - if (!igl::is_edge_manifold(F) || !igl::is_vertex_manifold(F, dummy)) { - auto v1 = verts; - auto tri1 = tris; - wmtk::separate_to_manifold(v1, tri1, verts, tris, modified_nonmanifold_v); - } -} - -void stl_to_manifold_wmtk_input( - std::vector input_paths, - double remove_duplicate_esp, - std::pair& box_minmax, - std::vector& verts, - std::vector>& tris, - std::vector& modified_nonmanifold_v) -{ - Eigen::MatrixXd V; - Eigen::MatrixXi F; - for (const std::string p : input_paths) { - if (!std::filesystem::exists(p)) { - log_and_throw_error("File {} does not exist", p); - } - Eigen::MatrixXd V_single; - Eigen::MatrixXi F_single; - { - Eigen::MatrixXd inV; - Eigen::MatrixXi inF; - if (!igl::read_triangle_mesh(p, inV, inF)) { - log_and_throw_error("Could not read {}", p); - } - Eigen::VectorXi _I; - igl::remove_unreferenced(inV, inF, V_single, F_single, _I); - } - assert(V_single.cols() == 3); - assert(F_single.cols() == 3); - - const int nV_old = V.rows(); - const int nF_old = F.rows(); - - V.conservativeResize(V.rows() + V_single.rows(), 3); - V.block(nV_old, 0, V_single.rows(), 3) = V_single; - - F_single.array() += nV_old; - F.conservativeResize(F.rows() + F_single.rows(), 3); - F.block(nF_old, 0, F_single.rows(), 3) = F_single; - } - - if (V.rows() == 0 || F.rows() == 0) { - log_and_throw_error("== finish with Empty Input, stop."); - } - - box_minmax = std::pair(V.colwise().minCoeff(), V.colwise().maxCoeff()); - double diag = (box_minmax.first - box_minmax.second).norm(); - - // using the same error tolerance as in tetwild - Eigen::VectorXi SVI, SVJ, SVK; - Eigen::MatrixXd temp_V = V; // for STL file - igl::remove_duplicate_vertices( - temp_V, - std::min(1e-5, remove_duplicate_esp / 10 * diag), - V, - SVI, - SVJ); - for (int i = 0; i < F.rows(); i++) { - for (int j : {0, 1, 2}) { - F(i, j) = SVJ[F(i, j)]; - } - } - - { - auto F1 = F; - VectorXi J; - resolve_duplicated_faces(F1, F, J); - } - - - verts.resize(V.rows()); - tris.resize(F.rows()); - wmtk::eigen_to_wmtk_input(verts, tris, V, F); - - wmtk::logger().info("after remove duplicate v#: {} f#: {}", V.rows(), F.rows()); - - Eigen::VectorXi dummy; - - if (!igl::is_edge_manifold(F) || !igl::is_vertex_manifold(F, dummy)) { - auto v1 = verts; - auto tri1 = tris; - wmtk::separate_to_manifold(v1, tri1, verts, tris, modified_nonmanifold_v); - } - - - // logger().info("In \"Read.cpp\": Check faces for collinearity..."); - for (int i = 0; i < F.rows(); ++i) { - Eigen::Vector3d v0 = V.row(F(i, 0)); - Eigen::Vector3d v1 = V.row(F(i, 1)); - Eigen::Vector3d v2 = V.row(F(i, 2)); - - if (utils::predicates::is_degenerate(v0, v1, v2)) { - logger().info( - "Face ({}, {}, {}) is collinear!", - v0.transpose(), - v1.transpose(), - v2.transpose()); - } - } - // logger().info("done"); -} - -} // namespace wmtk \ No newline at end of file diff --git a/src/wmtk/utils/Reader.hpp b/src/wmtk/utils/Reader.hpp deleted file mode 100644 index d7343b1b71..0000000000 --- a/src/wmtk/utils/Reader.hpp +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once - -#include - -namespace wmtk { -void eigen_to_wmtk_input( - std::vector& verts, - std::vector>& tris, - const Eigen::MatrixXd& V, - const Eigen::MatrixXi& F); -void stl_to_manifold_wmtk_input( - std::string input_path, - double remove_duplicate_esp, - std::pair& box_minmax, - std::vector& verts, - std::vector>& tris, - std::vector& modified_nonmanifold_v); -void stl_to_manifold_wmtk_input( - std::vector input_paths, - double remove_duplicate_esp, - std::pair& box_minmax, - std::vector& verts, - std::vector>& tris, - std::vector& modified_nonmanifold_v); -void resolve_duplicated_faces( - const Eigen::MatrixXi& inF, - Eigen::MatrixXi& outF, - Eigen::VectorXi& J); -} // namespace wmtk diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 58cc2c8557..87fc663180 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -11,7 +11,6 @@ set(TEST_SOURCES test_io.cpp test_knn.cpp test_link_condition.cpp - test_manifold.cpp test_operations.cpp test_raw_simplex_collection.cpp test_simplex_navigation.cpp diff --git a/tests/integration_tests.cpp b/tests/integration_tests.cpp index 03550fc18f..9c2cc99ef0 100644 --- a/tests/integration_tests.cpp +++ b/tests/integration_tests.cpp @@ -35,12 +35,15 @@ std::vector input_files{ "image_simulation_resolve_intersections_3d.json", "image_simulation_tag_priority_3d.json", "isotropic_remeshing_bunny.json", + "isotropic_remeshing_double_sphere.json", "isotropic_remeshing_piece.json", + "qslim_double_sphere.json", "qslim_octocat.json", "shortest_edge_collapse_101633.json", "shortest_edge_collapse_double_sphere.json", "shortest_edge_collapse_octocat.json", "shortest_edge_collapse_sphere_with_env.json", + "tetwild_double_sphere.json", "tetwild_octocat.json", "tetwild_sphere.json", "topological_offset_2d.json", diff --git a/tests/test_manifold.cpp b/tests/test_manifold.cpp deleted file mode 100644 index 06ecf19a73..0000000000 --- a/tests/test_manifold.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#include -#include -#include - -#include -#include "wmtk/utils/Logger.hpp" - -#include -#include -#include - -TEST_CASE("separate-manifold-patch", "[test_util]") -{ - std::vector vertices = { - {Eigen::Vector3d(0, 0, 0), - Eigen::Vector3d(1, 0, 0), - Eigen::Vector3d(0, 1, 0), - Eigen::Vector3d(0, 0, 1), - Eigen::Vector3d(0, -1, 0)}}; - std::vector> faces = {{ - {{0, 1, 2}}, - {{0, 1, 3}}, - {{0, 1, 4}}, - }}; - - std::vector out_v; - std::vector> out_f; - std::vector freeze_v; - wmtk::separate_to_manifold(vertices, faces, out_v, out_f, freeze_v); - REQUIRE(out_v.size() == 9); - REQUIRE(out_f.size() == 3); -} - -TEST_CASE("manifold-separate-test-37989", "[test_util]") -{ - std::string filename = WMTK_DATA_DIR "/models/37989_sf.obj"; - wmtk::manifold_internal::Vertices V; - wmtk::manifold_internal::Facets F; - igl::read_triangle_mesh(filename, V, F); - REQUIRE_FALSE(igl::is_edge_manifold(F)); - std::vector modified_vertices; - wmtk::manifold_internal::resolve_nonmanifoldness(V, F, modified_vertices); - REQUIRE(modified_vertices.size() > 0); - REQUIRE(igl::is_edge_manifold(F)); - Eigen::VectorXi VI; - REQUIRE(igl::is_vertex_manifold(F, VI)); -}