diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/CMakeLists.txt b/Polyhedron/demo/Polyhedron/Plugins/PMP/CMakeLists.txt index 56d43cccef3..852e4fa954e 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/CMakeLists.txt +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/CMakeLists.txt @@ -95,7 +95,7 @@ target_link_libraries(surface_intersection_plugin PUBLIC scene_surface_mesh_item qt5_wrap_ui( repairUI_FILES RemoveNeedlesDialog.ui) polyhedron_demo_plugin(repair_polyhedron_plugin Repair_polyhedron_plugin ${repairUI_FILES} KEYWORDS PMP) -target_link_libraries(repair_polyhedron_plugin PUBLIC scene_surface_mesh_item) +target_link_libraries(repair_polyhedron_plugin PUBLIC scene_points_with_normal_item scene_surface_mesh_item) qt5_wrap_ui( isotropicRemeshingUI_FILES Isotropic_remeshing_dialog.ui) polyhedron_demo_plugin(isotropic_remeshing_plugin Isotropic_remeshing_plugin ${isotropicRemeshingUI_FILES} KEYWORDS PMP) diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Repair_polyhedron_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Repair_polyhedron_plugin.cpp index 59365eb0d0e..69296cd01cb 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_surface_mesh_item.h" +#include "Scene_points_with_normal_item.h" #include #include #include @@ -47,6 +48,7 @@ public: actionRemoveSelfIntersections = new QAction(tr("Remove Self-Intersections"), mw); actionStitchCloseBorderHalfedges = new QAction(tr("Stitch Close Border Halfedges"), mw); actionDuplicateNMVertices = new QAction(tr("Duplicate Non-Manifold Vertices"), mw); + actionExtractNMVertices = new QAction(tr("Extract Non-Manifold Vertices"), mw); actionMergeDuplicatedVerticesOnBoundaryCycles = new QAction(tr("Merge Duplicated Vertices on Boundary Cycles"), mw); actionAutorefine = new QAction(tr("Autorefine Mesh"), mw); actionAutorefineAndRMSelfIntersections = new QAction(tr("Autorefine and Remove Self-Intersections"), mw); @@ -57,6 +59,7 @@ public: actionRemoveSelfIntersections->setObjectName("actionRemoveSelfIntersections"); actionStitchCloseBorderHalfedges->setObjectName("actionStitchCloseBorderHalfedges"); actionDuplicateNMVertices->setObjectName("actionDuplicateNMVertices"); + actionExtractNMVertices->setObjectName("actionExtractNMVertices"); actionMergeDuplicatedVerticesOnBoundaryCycles->setObjectName("actionMergeDuplicatedVerticesOnBoundaryCycles"); actionAutorefine->setObjectName("actionAutorefine"); actionAutorefineAndRMSelfIntersections->setObjectName("actionAutorefineAndRMSelfIntersections"); @@ -67,6 +70,7 @@ public: actionRemoveSelfIntersections->setProperty("subMenuName", "Polygon Mesh Processing/Repair/Experimental"); actionRemoveIsolatedVertices->setProperty("subMenuName", "Polygon Mesh Processing/Repair"); actionDuplicateNMVertices->setProperty("subMenuName", "Polygon Mesh Processing/Repair"); + actionExtractNMVertices->setProperty("subMenuName", "Polygon Mesh Processing/Repair"); actionMergeDuplicatedVerticesOnBoundaryCycles->setProperty("subMenuName", "Polygon Mesh Processing/Repair"); actionAutorefine->setProperty("subMenuName", "Polygon Mesh Processing/Repair/Experimental"); actionAutorefineAndRMSelfIntersections->setProperty("subMenuName", "Polygon Mesh Processing/Repair/Experimental"); @@ -82,6 +86,7 @@ public: << actionRemoveSelfIntersections << actionStitchCloseBorderHalfedges << actionDuplicateNMVertices + << actionExtractNMVertices << actionMergeDuplicatedVerticesOnBoundaryCycles << actionAutorefine << actionAutorefineAndRMSelfIntersections @@ -104,6 +109,8 @@ public: template void on_actionDuplicateNMVertices_triggered(Scene_interface::Item_id index); template + void on_actionExtractNMVertices_triggered(Scene_interface::Item_id index); + template void on_actionMergeDuplicatedVerticesOnBoundaryCycles_triggered(Scene_interface::Item_id index); template void on_actionAutorefine_triggered(Scene_interface::Item_id index); @@ -116,6 +123,7 @@ public Q_SLOTS: void on_actionRemoveSelfIntersections_triggered(); void on_actionStitchCloseBorderHalfedges_triggered(); void on_actionDuplicateNMVertices_triggered(); + void on_actionExtractNMVertices_triggered(); void on_actionMergeDuplicatedVerticesOnBoundaryCycles_triggered(); void on_actionAutorefine_triggered(); void on_actionAutorefineAndRMSelfIntersections_triggered(); @@ -127,6 +135,7 @@ private: QAction* actionRemoveSelfIntersections; QAction* actionStitchCloseBorderHalfedges; QAction* actionDuplicateNMVertices; + QAction* actionExtractNMVertices; QAction* actionMergeDuplicatedVerticesOnBoundaryCycles; QAction* actionAutorefine; QAction* actionAutorefineAndRMSelfIntersections; @@ -346,6 +355,32 @@ void Polyhedron_demo_repair_polyhedron_plugin::on_actionDuplicateNMVertices_trig } } +template +void Polyhedron_demo_repair_polyhedron_plugin::on_actionExtractNMVertices_triggered(Scene_interface::Item_id index) +{ + namespace PMP = CGAL::Polygon_mesh_processing; + typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; + + if (Item* poly_item = qobject_cast(scene->item(index))) + { + std::vector hds; + PMP::non_manifold_vertices(*poly_item->face_graph(), std::back_inserter(hds)); + if(hds.empty()) + { + CGAL::Three::Three::information(tr(" No NM vertex found.")); + return; + } + Scene_points_with_normal_item* pitem = new Scene_points_with_normal_item(); + pitem->setColor(Qt::red); + pitem->setName(QString("%1 nm vertices").arg(poly_item->name())); + for(const auto& h : hds) + { + pitem->point_set()->insert(poly_item->face_graph()->point(target(h, *poly_item->face_graph()))); + } + scene->addItem (pitem); + } +} + void Polyhedron_demo_repair_polyhedron_plugin::on_actionDuplicateNMVertices_triggered() { QApplication::setOverrideCursor(Qt::WaitCursor); @@ -354,6 +389,14 @@ void Polyhedron_demo_repair_polyhedron_plugin::on_actionDuplicateNMVertices_trig QApplication::restoreOverrideCursor(); } +void Polyhedron_demo_repair_polyhedron_plugin::on_actionExtractNMVertices_triggered() +{ + QApplication::setOverrideCursor(Qt::WaitCursor); + const Scene_interface::Item_id index = scene->mainSelectionIndex(); + on_actionExtractNMVertices_triggered(index); + QApplication::restoreOverrideCursor(); +} + template void Polyhedron_demo_repair_polyhedron_plugin::on_actionMergeDuplicatedVerticesOnBoundaryCycles_triggered(Scene_interface::Item_id index) {