diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_selection_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_selection_plugin.cpp index 31a1554e3ec..0195666dec1 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_selection_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_selection_plugin.cpp @@ -98,6 +98,8 @@ public: connect(ui_widget.Keep_connected_components_button, SIGNAL(clicked()), this, SLOT(on_Keep_connected_components_button_clicked())); connect(ui_widget.Dilate_erode_button, SIGNAL(clicked()), this, SLOT(on_Dilate_erode_button_clicked())); connect(ui_widget.Create_polyhedron_item_button, SIGNAL(clicked()), this, SLOT(on_Create_polyhedron_item_button_clicked())); + connect(ui_widget.Select_sharp_edges_button, SIGNAL(clicked()), this, SLOT(on_Select_sharp_edges_button_clicked())); + QObject* scene = dynamic_cast(scene_interface); if(scene) { connect(scene, SIGNAL(itemAboutToBeDestroyed(Scene_item*)), this, SLOT(item_about_to_be_destroyed(Scene_item*))); @@ -298,6 +300,18 @@ public Q_SLOTS: print_message("Error: polyhedron item is not created!"); } } + + void on_Select_sharp_edges_button_clicked() { + Scene_polyhedron_selection_item* selection_item = get_selected_item(); + if (!selection_item) { + print_message("Error: there is no selected polyhedron selection item!"); + return; + } + + double angle = ui_widget.Sharp_angle_spinbox->value(); + selection_item->select_sharp_edges(angle); + } + void on_Dilate_erode_button_clicked() { Scene_polyhedron_selection_item* selection_item = get_selected_item(); if(!selection_item) { diff --git a/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.h b/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.h index 5d281d3b18d..c48c85df38f 100644 --- a/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.h +++ b/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.h @@ -13,6 +13,7 @@ #include #include #include +#include "Polyhedron_demo_detect_sharp_edges.h" #include #include @@ -20,6 +21,7 @@ #include #include +#include namespace PMP = CGAL::Polygon_mesh_processing; @@ -705,6 +707,34 @@ public: return out->size_of_vertices() > 0; } + struct Is_sharp_edge_property_map + { + friend bool get(Is_sharp_edge_property_map, + Polyhedron::Halfedge_handle h) + { + return h->is_feature_edge(); + } + friend void put(Is_sharp_edge_property_map, + Polyhedron::Halfedge_handle h, + bool b) + { + h->set_feature_edge(b); + } + }; + + void select_sharp_edges(const double angle) + { + CGAL::detect_sharp_edges(polyhedron(), angle); + + Is_sharp_edge_property_map is_sharp; + BOOST_FOREACH(edge_descriptor e, edges(*polyhedron())) + { + Polyhedron::Halfedge_handle h = halfedge(e, *polyhedron()); + if (get(is_sharp, h)) + selected_edges.insert(e); + } + } + void changed_with_poly_item() { // no need to update indices poly_item->changed(); diff --git a/Polyhedron/demo/Polyhedron/Selection_widget.ui b/Polyhedron/demo/Polyhedron/Selection_widget.ui index d178b56ad88..fce61d9f557 100644 --- a/Polyhedron/demo/Polyhedron/Selection_widget.ui +++ b/Polyhedron/demo/Polyhedron/Selection_widget.ui @@ -180,6 +180,93 @@ + + + + + + + + + 10 + 10 + 291 + 80 + + + + + + + true + + + + + 0 + 0 + 287 + 76 + + + + + + 210 + 30 + 75 + 23 + + + + Select + + + + + + 121 + 30 + 81 + 22 + + + + + 0 + 0 + + + + 180 + + + 60 + + + + + + 5 + 30 + 111 + 20 + + + + Sharp edges angle: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + @@ -277,19 +364,6 @@ - - - - Qt::Vertical - - - - 20 - 40 - - - -