From 1ec6d7b058c346f1cc649e27d43f6f73e3c8bd8c Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Fri, 10 Mar 2017 13:25:59 +0100 Subject: [PATCH] Make repair_plugin work for Surface_mesh --- .../CGAL/Polygon_mesh_processing/repair.h | 6 +-- .../Polyhedron/Plugins/PMP/CMakeLists.txt | 2 +- .../Plugins/PMP/Repair_polyhedron_plugin.cpp | 53 +++++++++++++------ 3 files changed, 42 insertions(+), 19 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair.h index 15797ae2b15..411197ec05d 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/repair.h @@ -1126,7 +1126,7 @@ bool remove_self_intersections(TriangleMesh& tm, const int max_steps = 7, bool v boundary_hedges.resize(boundary_hedges_initial_size); BOOST_FOREACH(face_descriptor fh, faces_to_remove) { - halfedge_descriptor h = fh->halfedge(); + halfedge_descriptor h = halfedge(fh,tm); for (int i=0;i<3; ++i) { if ( is_border( opposite(h, tm), tm) ){ @@ -1154,7 +1154,7 @@ bool remove_self_intersections(TriangleMesh& tm, const int max_steps = 7, bool v std::set border_vertices; BOOST_FOREACH(halfedge_descriptor h, boundary_hedges) { - if (!border_vertices.insert(h->vertex()).second){ + if (!border_vertices.insert(target(h,tm)).second){ BOOST_FOREACH(halfedge_descriptor hh, halfedges_around_target(h,tm)){ if (!is_border(hh, tm)) faces_to_remove.insert(face(hh, tm)); @@ -1176,7 +1176,7 @@ bool remove_self_intersections(TriangleMesh& tm, const int max_steps = 7, bool v std::set edges_to_remove; BOOST_FOREACH(face_descriptor fh, faces_to_remove) { - BOOST_FOREACH(halfedge_descriptor h, halfedges_around_face(fh->halfedge(),tm)) + BOOST_FOREACH(halfedge_descriptor h, halfedges_around_face(halfedge(fh,tm),tm)) { if (halfedge(target(h, tm), tm)==h) // limit the number of insertions vertices_to_remove.insert(target(h, tm)); diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/CMakeLists.txt b/Polyhedron/demo/Polyhedron/Plugins/PMP/CMakeLists.txt index 3a0d593d950..2cf56fecfdf 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/CMakeLists.txt +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/CMakeLists.txt @@ -88,7 +88,7 @@ polyhedron_demo_plugin(surface_intersection_plugin Surface_intersection_plugin) target_link_libraries(surface_intersection_plugin scene_polyhedron_item scene_polylines_item) polyhedron_demo_plugin(repair_polyhedron_plugin Repair_polyhedron_plugin) -target_link_libraries(repair_polyhedron_plugin scene_polyhedron_item) +target_link_libraries(repair_polyhedron_plugin scene_surface_mesh_item scene_polyhedron_item) qt5_wrap_ui( isotropicRemeshingUI_FILES Isotropic_remeshing_dialog.ui) polyhedron_demo_plugin(isotropic_remeshing_plugin Isotropic_remeshing_plugin ${isotropicRemeshingUI_FILES}) diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Repair_polyhedron_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Repair_polyhedron_plugin.cpp index 8ac16f6a353..bfa71e7dc8e 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Repair_polyhedron_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Repair_polyhedron_plugin.cpp @@ -1,6 +1,7 @@ #include #include "Scene_polyhedron_item.h" +#include "Scene_surface_mesh_item.h" #include #include "Polyhedron_type.h" #include @@ -13,7 +14,6 @@ #include #include -#include using namespace CGAL::Three; class Polyhedron_demo_repair_polyhedron_plugin : @@ -58,9 +58,15 @@ public: bool applicable(QAction*) const { int item_id = scene->mainSelectionIndex(); - return qobject_cast( - scene->item(item_id)); + return qobject_cast(scene->item(item_id)) || + qobject_cast(scene->item(item_id)); } + template + void on_actionRemoveIsolatedVertices_triggered(Scene_interface::Item_id index); + template + void on_actionRemoveDegenerateFaces_triggered(Scene_interface::Item_id index); + template + void on_actionRemoveSelfIntersections_triggered(Scene_interface::Item_id index); public Q_SLOTS: void on_actionRemoveIsolatedVertices_triggered(); @@ -75,13 +81,11 @@ private: Messages_interface* messages; }; // end Polyhedron_demo_repair_polyhedron_plugin - -void Polyhedron_demo_repair_polyhedron_plugin::on_actionRemoveIsolatedVertices_triggered() +template +void Polyhedron_demo_repair_polyhedron_plugin::on_actionRemoveIsolatedVertices_triggered(Scene_interface::Item_id index) { - const Scene_interface::Item_id index = scene->mainSelectionIndex(); - - Scene_polyhedron_item* poly_item = - qobject_cast(scene->item(index)); + Item* poly_item = + qobject_cast(scene->item(index)); if (poly_item) { std::size_t nbv = @@ -94,12 +98,18 @@ void Polyhedron_demo_repair_polyhedron_plugin::on_actionRemoveIsolatedVertices_t } } -void Polyhedron_demo_repair_polyhedron_plugin::on_actionRemoveDegenerateFaces_triggered() +void Polyhedron_demo_repair_polyhedron_plugin::on_actionRemoveIsolatedVertices_triggered() { const Scene_interface::Item_id index = scene->mainSelectionIndex(); + on_actionRemoveIsolatedVertices_triggered(index); + on_actionRemoveIsolatedVertices_triggered(index); +} - Scene_polyhedron_item* poly_item = - qobject_cast(scene->item(index)); +template +void Polyhedron_demo_repair_polyhedron_plugin::on_actionRemoveDegenerateFaces_triggered(Scene_interface::Item_id index) +{ + Item* poly_item = + qobject_cast(scene->item(index)); if (poly_item) { std::size_t nbv = @@ -112,12 +122,18 @@ void Polyhedron_demo_repair_polyhedron_plugin::on_actionRemoveDegenerateFaces_tr } } -void Polyhedron_demo_repair_polyhedron_plugin::on_actionRemoveSelfIntersections_triggered() +void Polyhedron_demo_repair_polyhedron_plugin::on_actionRemoveDegenerateFaces_triggered() { const Scene_interface::Item_id index = scene->mainSelectionIndex(); + on_actionRemoveDegenerateFaces_triggered(index); + on_actionRemoveDegenerateFaces_triggered(index); +} - Scene_polyhedron_item* poly_item = - qobject_cast(scene->item(index)); +template +void Polyhedron_demo_repair_polyhedron_plugin::on_actionRemoveSelfIntersections_triggered(Scene_interface::Item_id index) +{ + Item* poly_item = + qobject_cast(scene->item(index)); if (poly_item) { bool solved = @@ -130,4 +146,11 @@ void Polyhedron_demo_repair_polyhedron_plugin::on_actionRemoveSelfIntersections_ } } +void Polyhedron_demo_repair_polyhedron_plugin::on_actionRemoveSelfIntersections_triggered() +{ + const Scene_interface::Item_id index = scene->mainSelectionIndex(); + on_actionRemoveSelfIntersections_triggered(index); + on_actionRemoveSelfIntersections_triggered(index); +} + #include "Repair_polyhedron_plugin.moc"