select sharp edges

button and code added

Conflicts:
	Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.h
This commit is contained in:
Jane Tournois 2015-05-19 15:10:52 +02:00 committed by Sébastien Loriot
parent 6fd3b99f77
commit 00b50b3e3e
3 changed files with 131 additions and 13 deletions

View File

@ -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.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.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.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<QObject*>(scene_interface); QObject* scene = dynamic_cast<QObject*>(scene_interface);
if(scene) { if(scene) {
connect(scene, SIGNAL(itemAboutToBeDestroyed(Scene_item*)), this, SLOT(item_about_to_be_destroyed(Scene_item*))); 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!"); print_message("Error: polyhedron item is not created!");
} }
} }
void on_Select_sharp_edges_button_clicked() {
Scene_polyhedron_selection_item* selection_item = get_selected_item<Scene_polyhedron_selection_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() { void on_Dilate_erode_button_clicked() {
Scene_polyhedron_selection_item* selection_item = get_selected_item<Scene_polyhedron_selection_item>(); Scene_polyhedron_selection_item* selection_item = get_selected_item<Scene_polyhedron_selection_item>();
if(!selection_item) { if(!selection_item) {

View File

@ -13,6 +13,7 @@
#include <CGAL/Polygon_mesh_processing/orient_polygon_soup.h> #include <CGAL/Polygon_mesh_processing/orient_polygon_soup.h>
#include <CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h> #include <CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h>
#include <CGAL/Polygon_mesh_processing/connected_components.h> #include <CGAL/Polygon_mesh_processing/connected_components.h>
#include "Polyhedron_demo_detect_sharp_edges.h"
#include <fstream> #include <fstream>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
@ -20,6 +21,7 @@
#include <boost/property_map/vector_property_map.hpp> #include <boost/property_map/vector_property_map.hpp>
#include <CGAL/boost/graph/selection.h> #include <CGAL/boost/graph/selection.h>
#include <CGAL/boost/graph/graph_traits_Polyhedron_3.h>
namespace PMP = CGAL::Polygon_mesh_processing; namespace PMP = CGAL::Polygon_mesh_processing;
@ -705,6 +707,34 @@ public:
return out->size_of_vertices() > 0; 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() { void changed_with_poly_item() {
// no need to update indices // no need to update indices
poly_item->changed(); poly_item->changed();

View File

@ -180,6 +180,93 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string/>
</property>
<widget class="QWidget" name="horizontalLayoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>291</width>
<height>80</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QScrollArea" name="scrollArea">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>287</width>
<height>76</height>
</rect>
</property>
<widget class="QPushButton" name="Select_sharp_edges_button">
<property name="geometry">
<rect>
<x>210</x>
<y>30</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Select</string>
</property>
</widget>
<widget class="QSpinBox" name="Sharp_angle_spinbox">
<property name="geometry">
<rect>
<x>121</x>
<y>30</y>
<width>81</width>
<height>22</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximum">
<number>180</number>
</property>
<property name="value">
<number>60</number>
</property>
</widget>
<widget class="QLabel" name="label_4">
<property name="geometry">
<rect>
<x>5</x>
<y>30</y>
<width>111</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>Sharp edges angle:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</widget>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item> <item>
<widget class="QGroupBox" name="groupBox_4"> <widget class="QGroupBox" name="groupBox_4">
<property name="title"> <property name="title">
@ -277,19 +364,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout> </layout>
</widget> </widget>
</widget> </widget>