From 4136f5b2e8bac8ee4cc0c5e57f77c5014ed15ecf Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Thu, 17 Mar 2016 14:40:34 +0100 Subject: [PATCH] Fixes --- .../Plugins/PMP/Selection_plugin.cpp | 2 + .../Scene_polyhedron_selection_item.cpp | 62 +++++++++++++++---- .../Scene_polyhedron_selection_item.h | 5 +- 3 files changed, 53 insertions(+), 16 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_plugin.cpp index 88244010dc4..5a935a3c5d0 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_plugin.cpp @@ -133,6 +133,7 @@ public Q_SLOTS: if (scene_ptr) connect(new_item,SIGNAL(simplicesSelected(CGAL::Three::Scene_item*)), scene_ptr, SLOT(setSelectedItem(CGAL::Three::Scene_item*))); scene->setSelectedItem(item_id); + on_ModeBox_changed(ui_widget.modeBox->currentIndex()); } } // Select all @@ -217,6 +218,7 @@ public Q_SLOTS: if (scene_ptr) connect(new_item,SIGNAL(simplicesSelected(CGAL::Three::Scene_item*)), scene_ptr, SLOT(setSelectedItem(CGAL::Three::Scene_item*))); scene->setSelectedItem(item_id); + on_ModeBox_changed(ui_widget.modeBox->currentIndex()); } void on_Selection_type_combo_box_changed(int index) { typedef Scene_polyhedron_selection_item::Active_handle Active_handle; diff --git a/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.cpp b/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.cpp index 94cf2ae235c..0ec042c48fb 100644 --- a/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.cpp @@ -562,6 +562,35 @@ bool Scene_polyhedron_selection_item::treat_selection(const std::setvertex() == vh) + belong = true; + if(halfedge(to_join_ed, *polyhedron())->opposite()->vertex() == vh) + { + belong = true; + target = halfedge(to_join_ed, *polyhedron())->opposite(); + } + if(!belong) + { + tempInstructions("Vertices not joined : the vertex must belong to the selected edge.", + "Select the vertex that will remain."); + } + else + { + + CGAL::Euler::join_vertex(target, *polyhedron()); + selected_edges.erase(to_join_ed); + //set to select vertex + set_active_handle_type(static_cast(0)); + tempInstructions("Vertices joined.", + "Select the edge with extremities you want to join."); } + } + break; //Split vertex case 1: { @@ -657,7 +686,7 @@ bool Scene_polyhedron_selection_item::treat_selection(const std::sethalfedge(),*poly); + CGAL::Euler::remove_center_vertex(vh->halfedge(),*polyhedron()); else { tempInstructions("Vertex not selected : There must be no hole incident to the selection.", @@ -753,23 +782,32 @@ bool Scene_polyhedron_selection_item:: treat_selection(const std::setfacet()->facet_degree()<4 + if((!halfedge(ed, *polyhedron())->is_border() && + halfedge(ed, *polyhedron())->facet()->facet_degree()<4) || - opposite(halfedge(ed, *polyhedron()), *polyhedron())->facet()->facet_degree()<4) + (!opposite(halfedge(ed, *polyhedron()), *polyhedron())->is_border() && + opposite(halfedge(ed, *polyhedron()), *polyhedron())->facet()->facet_degree()<4) + ) { - tempInstructions("Vertices not joined : the incident facets must have a degree of at least 4.", + tempInstructions("Edge not selected: the incident facets must have a degree of at least 4.", "Select the edge with extremities you want to join."); } else - polyhedron()->join_vertex(halfedge(ed, *polyhedron())); + { + to_join_ed = ed; + selected_edges.insert(to_join_ed); + //set to select vertex + set_active_handle_type(static_cast(0)); + Q_EMIT updateInstructions("Select the vertex that will remain."); + } } break; //Split edge case 2: BOOST_FOREACH(edge_descriptor ed, selection) { - Polyhedron::Point_3 a(halfedge(ed, *poly)->vertex()->point()),b(halfedge(ed, *poly)->opposite()->vertex()->point()); - Polyhedron::Halfedge_handle hhandle = polyhedron()->split_edge(halfedge(ed, *poly)); + Polyhedron::Point_3 a(halfedge(ed, *polyhedron())->vertex()->point()),b(halfedge(ed, *polyhedron())->opposite()->vertex()->point()); + Polyhedron::Halfedge_handle hhandle = polyhedron()->split_edge(halfedge(ed, *polyhedron())); Polyhedron::Point_3 p((b.x()+a.x())/2.0, (b.y()+a.y())/2.0,(b.z()+a.z())/2.0); hhandle->vertex()->point() = p; @@ -803,7 +841,7 @@ bool Scene_polyhedron_selection_item:: treat_selection(const std::setvertex()->point().x(); y+=hafc->vertex()->point().y(); z+=hafc->vertex()->point().z(); total++; } - Polyhedron::Halfedge_handle hhandle = CGAL::Euler::add_center_vertex(fh->facet_begin(), *poly); + Polyhedron::Halfedge_handle hhandle = CGAL::Euler::add_center_vertex(fh->facet_begin(), *polyhedron()); if(total !=0) hhandle->vertex()->point() = Polyhedron::Point_3(x/(double)total, y/(double)total, z/(double)total); diff --git a/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.h b/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.h index 3325d948cf1..01817c40d81 100644 --- a/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.h +++ b/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.h @@ -972,10 +972,7 @@ private: bool is_treated; Vertex_handle to_split_vh; Facet_handle to_split_fh; - edge_descriptor ed_for_add_1; - edge_descriptor ed_for_add_2; - Vertex_handle vh_for_add_1; - Vertex_handle vh_for_add_2; + edge_descriptor to_join_ed; Active_handle::Type original_sel_mode; //Only needed for the triangulation Polyhedron* poly;