From 1ef82e471b52ef872e5d46b145012155644c24c7 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Fri, 2 Feb 2018 08:48:04 +0100 Subject: [PATCH 1/3] check if the edge is NOT a border edge before calling its opposite. --- Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_plugin.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_plugin.cpp index 9a5c2687cdb..73b9bd9ffc0 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_plugin.cpp @@ -573,7 +573,8 @@ public Q_SLOTS: BOOST_FOREACH(Scene_polyhedron_selection_item::fg_edge_descriptor ed, selection_item->selected_edges) { selection_item->selected_facets.insert(face(halfedge(ed, poly), poly)); - selection_item->selected_facets.insert(face(opposite(halfedge(ed, poly), poly), poly)); + if(!is_border_edge(halfedge(ed,poly), poly)) + selection_item->selected_facets.insert(face(opposite(halfedge(ed, poly), poly), poly)); } selection_item->invalidateOpenGLBuffers(); selection_item->itemChanged(); From e7ebbd731dc064932a76a2a845d9ba257df8e5a5 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Fri, 2 Feb 2018 09:27:41 +0100 Subject: [PATCH 2/3] Add a butotn in edge selection mode that allows to select the whole boundary. --- .../Plugins/PMP/Selection_plugin.cpp | 27 ++++++++++++++++++- .../Plugins/PMP/Selection_widget.ui | 23 +++++++++++----- .../Scene_polyhedron_selection_item.cpp | 14 ++++++++++ .../Scene_polyhedron_selection_item.h | 2 ++ 4 files changed, 59 insertions(+), 7 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_plugin.cpp index 73b9bd9ffc0..5e282606521 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_plugin.cpp @@ -121,6 +121,7 @@ public: connect(ui_widget.Select_all_button, SIGNAL(clicked()), this, SLOT(on_Select_all_button_clicked())); connect(ui_widget.Select_all_NTButton, SIGNAL(clicked()), this, SLOT(on_Select_all_NTButton_clicked())); + connect(ui_widget.Select_boundaryButton, SIGNAL(clicked()), this, SLOT(on_Select_boundaryButton_clicked())); connect(ui_widget.Add_to_selection_button, SIGNAL(clicked()), this, SLOT(on_Add_to_selection_button_clicked())); connect(ui_widget.Clear_button, SIGNAL(clicked()), this, SLOT(on_Clear_button_clicked())); connect(ui_widget.Clear_all_button, SIGNAL(clicked()), this, SLOT(on_Clear_all_button_clicked())); @@ -242,6 +243,20 @@ public Q_SLOTS: selection_item->select_all_NT(); } + // Select Boundary + void on_Select_boundaryButton_clicked() { + Scene_polyhedron_selection_item* selection_item = getSelectedItem(); + if(!selection_item) + selection_item = onTheFlyItem(); + if(!selection_item) + { + print_message("Error: there is no selected polyhedron selection item!"); + return; + } + + selection_item->select_boundary(); + } + void on_Add_to_selection_button_clicked() { @@ -359,19 +374,29 @@ public Q_SLOTS: { ui_widget.Select_all_NTButton->show(); ui_widget.Add_to_selection_button->hide(); + ui_widget.Select_boundaryButton->hide(); + Q_EMIT set_operation_mode(-1); + } + else if(index == 2) + { + ui_widget.Select_all_NTButton->hide(); + ui_widget.Add_to_selection_button->hide(); + ui_widget.Select_boundaryButton->show(); Q_EMIT set_operation_mode(-1); } else if(index == 4) { it->second->setPathSelection(true); - ui_widget.Add_to_selection_button->show(); ui_widget.Select_all_NTButton->hide(); + ui_widget.Add_to_selection_button->show(); + ui_widget.Select_boundaryButton->show(); Q_EMIT set_operation_mode(-2); } else { ui_widget.Add_to_selection_button->hide(); ui_widget.Select_all_NTButton->hide(); + ui_widget.Select_boundaryButton->hide(); it->second->setPathSelection(false); Q_EMIT set_operation_mode(-1); } diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_widget.ui b/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_widget.ui index 081d48573ea..e46381727ba 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_widget.ui +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_widget.ui @@ -7,7 +7,7 @@ 0 0 613 - 334 + 342 @@ -153,11 +153,22 @@ - - - Select All Non Triangle - - + + + + + Select All Non Triangle + + + + + + + Select Boundary Edges + + + + diff --git a/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.cpp b/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.cpp index a82f1face6d..3f91e00f6ec 100644 --- a/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.cpp @@ -2249,3 +2249,17 @@ bool Scene_polyhedron_selection_item::shouldDisplayIds(CGAL::Three::Scene_item * return d->item->polyhedron_item() == current_item; return false; } + +void Scene_polyhedron_selection_item::select_boundary() +{ + Face_graph* fg = polyhedron_item()->face_graph(); + BOOST_FOREACH(halfedge_descriptor hd, halfedges(*fg)) + { + if(is_border_edge(hd, *fg)) + { + selected_edges.insert(edge(hd, *fg)); + } + } + invalidateOpenGLBuffers(); + redraw(); +} diff --git a/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.h b/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.h index c46ed15b943..b4979aedfff 100644 --- a/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.h +++ b/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.h @@ -440,6 +440,8 @@ public: break; } } + + void select_boundary(); void select_all_NT(); // select all of vertex, facet or edge (use fg_vertex_descriptor, fg_face_descriptor, fg_edge_descriptor as template argument) template From 7a5e92d30740a940e9f8fda07202ab90e4e9522c Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Mon, 5 Feb 2018 08:03:08 +0100 Subject: [PATCH 3/3] replace halfedge by fg_halfedge --- Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.cpp b/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.cpp index 3f91e00f6ec..4502157e1c9 100644 --- a/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.cpp @@ -2253,7 +2253,7 @@ bool Scene_polyhedron_selection_item::shouldDisplayIds(CGAL::Three::Scene_item * void Scene_polyhedron_selection_item::select_boundary() { Face_graph* fg = polyhedron_item()->face_graph(); - BOOST_FOREACH(halfedge_descriptor hd, halfedges(*fg)) + BOOST_FOREACH(fg_halfedge_descriptor hd, halfedges(*fg)) { if(is_border_edge(hd, *fg)) {