From 8f2cba74d810801deabb1f1cfd48c8f9cb8ea829 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Tue, 25 Apr 2017 09:17:57 +0200 Subject: [PATCH 1/3] Add an Alpha_shape_plugin - Add a specific alpha_shape item and an alpha_shape_plugin. - Add a creation of polygon_soup from alpha_shape_item --- .../demo/Alpha_shapes_3/MainWindow.cpp | 2 +- .../Plugins/Point_set/Alpha_shape_plugin.cpp | 478 ++++++++++++++++++ .../Plugins/Point_set/Alpha_shape_widget.ui | 103 ++++ .../Plugins/Point_set/CMakeLists.txt | 4 + 4 files changed, 586 insertions(+), 1 deletion(-) create mode 100644 Polyhedron/demo/Polyhedron/Plugins/Point_set/Alpha_shape_plugin.cpp create mode 100644 Polyhedron/demo/Polyhedron/Plugins/Point_set/Alpha_shape_widget.ui diff --git a/Alpha_shapes_3/demo/Alpha_shapes_3/MainWindow.cpp b/Alpha_shapes_3/demo/Alpha_shapes_3/MainWindow.cpp index a189679344f..9de26cdd7db 100644 --- a/Alpha_shapes_3/demo/Alpha_shapes_3/MainWindow.cpp +++ b/Alpha_shapes_3/demo/Alpha_shapes_3/MainWindow.cpp @@ -51,7 +51,7 @@ MainWindow::open_file() QString fileName = QFileDialog::getOpenFileName(this, tr("Open Points File"), "./data", - tr("pts files (*.pts)")); + tr("pts files (*.pts)")); if(! fileName.isEmpty()){ open(fileName); diff --git a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Alpha_shape_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Alpha_shape_plugin.cpp new file mode 100644 index 00000000000..c283f95f378 --- /dev/null +++ b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Alpha_shape_plugin.cpp @@ -0,0 +1,478 @@ +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "Scene_points_with_normal_item.h" +#include "Scene_polygon_soup_item.h" +#include "Scene.h" + +#include "ui_Alpha_shape_widget.h" + + +typedef double coord_type; + + +typedef Kernel K; + +typedef K::Point_3 Point_3; +typedef K::Vector_3 Vector_3; +typedef K::Segment_3 Segment_3; +typedef K::Ray_3 Ray_3; +typedef K::Line_3 Line; +typedef K::Triangle_3 Triangle_3; +typedef K::Iso_cuboid_3 Iso_cuboid_3; + +typedef CGAL::Triangulation_vertex_base_with_info_3 Vb1; +typedef CGAL::Alpha_shape_vertex_base_3 Vb; +typedef CGAL::Alpha_shape_cell_base_3 Fb; + +typedef CGAL::Triangulation_data_structure_3 Tds; +typedef CGAL::Delaunay_triangulation_3 Triangulation_3; + +typedef CGAL::Alpha_shape_3 Alpha_shape_3; + +typedef Alpha_shape_3::Cell Cell; +typedef Alpha_shape_3::Vertex Vertex; +typedef Alpha_shape_3::Edge Edge; +typedef Alpha_shape_3::Facet Facet; +typedef Alpha_shape_3::Cell_handle Cell_handle; +typedef Alpha_shape_3::Vertex_handle Vertex_handle; + +typedef Alpha_shape_3::Cell_circulator Cell_circulator; + +typedef Alpha_shape_3::Locate_type Locate_type; + +typedef Alpha_shape_3::Cell_iterator Cell_iterator; +typedef Alpha_shape_3::Vertex_iterator Vertex_iterator; +typedef Alpha_shape_3::Edge_iterator Edge_iterator; + + +typedef Alpha_shape_3::Coord_type Coord_type; +typedef Alpha_shape_3::Alpha_iterator Alpha_iterator; + + +class Scene_alpha_shape_item : public CGAL::Three::Scene_item +{ + Q_OBJECT +public : + Scene_alpha_shape_item(Scene_points_with_normal_item* , int alpha); + bool supportsRenderingMode(RenderingMode m) const { + return (m == Flat); + } + void draw(CGAL::Three::Viewer_interface* viewer) const Q_DECL_OVERRIDE; + void drawPoints(CGAL::Three::Viewer_interface* viewer) const Q_DECL_OVERRIDE; + void invalidateOpenGLBuffers()Q_DECL_OVERRIDE; + void computeElements() const; + Scene_item* clone() const Q_DECL_OVERRIDE{return 0;} + QString toolTip() const Q_DECL_OVERRIDE{return QString();} + bool isEmpty() const Q_DECL_OVERRIDE{ return false;} + bool isFinite() const Q_DECL_OVERRIDE{ return true;} + Alpha_shape_3 alpha_shape; + void createPolygonSoup(std::vector& points, + std::vector >& polys) const; +public Q_SLOTS: + void alpha_changed(int); +private: + mutable std::vector vertices; + mutable std::vector indices; + mutable QOpenGLShaderProgram *program; + mutable QOpenGLShaderProgram facet_program; + using CGAL::Three::Scene_item::initializeBuffers; + void initializeBuffers(CGAL::Three::Viewer_interface *viewer)const; + Point_set point_set; +}; //end of class Scene_alpha_shape_item + + + +///////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////// + + + +#include +class DockWidget : + public QDockWidget, + public Ui::AlphaShapesWidget +{ +public: + DockWidget(QString name, QWidget *parent) + :QDockWidget(name,parent) + { + setupUi(this); + } +}; + +using namespace CGAL::Three; +class Q_DECL_EXPORT Alpha_shape_plugin : + public QObject, + public Polyhedron_demo_plugin_helper +{ + Q_OBJECT + Q_INTERFACES(CGAL::Three::Polyhedron_demo_plugin_interface) + Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.PluginInterface/1.0") +public : + + void init(QMainWindow* mainWindow, CGAL::Three::Scene_interface* scene_interface, Messages_interface*) { + this->scene = scene_interface; + this->mw = mainWindow; + QAction* actionAlphaShapes= new QAction("Alpha Shapes", mw); + if(actionAlphaShapes) { + connect(actionAlphaShapes, &QAction::triggered, + this, &Alpha_shape_plugin::on_actionAlphaShapes_triggered); + _actions << actionAlphaShapes; + } + + dock_widget = new DockWidget("Alpha Shapes", mw); + dock_widget->setVisible(false); // do not show at the beginning + dock_widget->as_itemPushButton->setEnabled(false); + dock_widget->poly_itemPushButton->setEnabled(false); + addDockWidget(dock_widget); + as_item = NULL; + + connect(dock_widget->as_itemPushButton, &QPushButton::clicked, + this, &Alpha_shape_plugin::on_as_itemPushButton_clicked); + connect(dock_widget->poly_itemPushButton, &QPushButton::clicked, + this, &Alpha_shape_plugin::on_poly_itemPushButton_clicked); + + connect(dock_widget->horizontalSlider, SIGNAL(valueChanged(int)), + dock_widget->spinBox, SLOT(setValue(int))); + + connect(dock_widget->spinBox, SIGNAL(valueChanged(int)), + dock_widget->horizontalSlider, SLOT(setValue(int))); + + connect(static_cast(scene), SIGNAL(itemIndexSelected(int)), + this,SLOT(on_scene_selection_changed(int))); + + + } + bool applicable(QAction*) const + { + return qobject_cast( scene->item( scene->mainSelectionIndex() ) ); + } + QList actions() const { + return _actions; + } +public Q_SLOTS: + + void on_itemDestroyed() + { + as_item = NULL; + } + void on_actionAlphaShapes_triggered() + { + if(dock_widget->isVisible()) { dock_widget->hide(); } + else { dock_widget->show(); } + } + + void on_as_itemPushButton_clicked() + { + Scene_points_with_normal_item* ps_item = + qobject_cast(scene->item(scene->mainSelectionIndex())); + if(!ps_item) + return; + //Only one alpha_shape item at the same time + if(as_item) + { + scene->erase(scene->item_id(as_item)); + as_item = NULL; + } + ps_item->setVisible(false); + as_item = new Scene_alpha_shape_item(ps_item, dock_widget->spinBox->value()); + + as_item->setName(QString("%1 (alpha shape)").arg(ps_item->name())); + as_item->setFlatMode(); + + connect(dock_widget->horizontalSlider, &QSlider::valueChanged, + as_item, &Scene_alpha_shape_item::alpha_changed); + connect(as_item, &Scene_alpha_shape_item::aboutToBeDestroyed, + this, &Alpha_shape_plugin::on_itemDestroyed); + scene->setSelectedItem(scene->addItem(as_item)); + } + + void on_poly_itemPushButton_clicked() + { + Scene_alpha_shape_item* as_item = + qobject_cast(scene->item(scene->mainSelectionIndex())); + if(!as_item) + return; + + std::vector points; + std::vector > polys; + as_item->createPolygonSoup(points, polys); + Scene_polygon_soup_item* new_item = new Scene_polygon_soup_item(); + new_item->init_polygon_soup(points.size(), polys.size()); + BOOST_FOREACH(const Kernel::Point_3& p, points) + { + new_item->new_vertex(p.x(), p.y(), p.z()); + } + BOOST_FOREACH(const std::vector& poly, polys) + { + new_item->new_triangle(poly[0], poly[1], poly[2]); + } + new_item->setName(as_item->name()); + as_item->setVisible(false); + scene->addItem(new_item); + } + + void on_scene_selection_changed(int i) + { + dock_widget->as_itemPushButton->setEnabled(false); + dock_widget->poly_itemPushButton->setEnabled(false); + + if( qobject_cast( scene->item(i) ) && + !as_item) + dock_widget->as_itemPushButton->setEnabled(true); + else if( qobject_cast( scene->item(i) ) ) + dock_widget->poly_itemPushButton->setEnabled(true); + } + void closure() Q_DECL_OVERRIDE + { + dock_widget->hide(); + } +private: + CGAL::Three::Scene_item* triangle; + QList _actions; + DockWidget* dock_widget; + Scene_alpha_shape_item* as_item; +}; //end of class Alpha_shape_plugin + + + + +/*********************************** + *********************************** + ** Item's functions declarations ** + *********************************** + ***********************************/ +#include +Scene_alpha_shape_item::Scene_alpha_shape_item(Scene_points_with_normal_item *point_set_item, int alpha) + : Scene_item(1, 1), point_set(*point_set_item->point_set()) +{ + QApplication::setOverrideCursor(Qt::WaitCursor); + _bbox = point_set_item->bbox(); + const qglviewer::Vec offset = static_cast(QGLViewer::QGLViewerPool().first())->offset(); + vertices.reserve(point_set.size() * 3); + CGAL::Timer timer; + timer.start(); + alpha_shape.make_alpha_shape(point_set.points().begin(), point_set.points().end()); + double res = timer.time(); + timer.stop(); + qDebug()<<"Alpha shape done : "<info() = i++; + vertices.push_back(it->point().x()+offset.x); + vertices.push_back(it->point().y()+offset.y); + vertices.push_back(it->point().z()+offset.z); + } + + const char vertex_source[] = + { + "#version 120 \n" + "attribute highp vec4 vertex;\n" + "attribute highp vec3 colors;\n" + "uniform highp mat4 mvp_matrix;\n" + "uniform highp mat4 mv_matrix; \n" + "varying highp vec4 fP; \n" + "varying highp vec4 color;; \n" + "void main(void)\n" + "{\n" + " color = vec4(colors, 1.0); \n" + " fP = mv_matrix * vertex; \n" + " gl_Position = mvp_matrix * vertex;\n" + "}" + }; + + facet_program.addShaderFromSourceCode(QOpenGLShader::Vertex, vertex_source); + facet_program.addShaderFromSourceFile(QOpenGLShader::Fragment, ":/cgal/Polyhedron_3/resources/shader_flat.f"); + facet_program.link(); + facet_program.bind(); + invalidateOpenGLBuffers(); + alpha_changed(alpha); + QApplication::restoreOverrideCursor(); +} +void Scene_alpha_shape_item::draw(CGAL::Three::Viewer_interface* viewer) const +{ + if(!are_buffers_filled) + { + computeElements(); + initializeBuffers(viewer); + } + QMatrix4x4 mvp_mat; + QMatrix4x4 mv_mat; + GLdouble d_mat[16]; + viewer->camera()->getModelViewMatrix(d_mat); + for (int i=0; i<16; ++i) + mv_mat.data()[i] = GLfloat(d_mat[i]); + viewer->camera()->getModelViewProjectionMatrix(d_mat); + for (int i=0; i<16; ++i) + mvp_mat.data()[i] = GLfloat(d_mat[i]); + QVector4D position(0.0f,0.0f,1.0f, 1.0f ); + QVector4D ambient(0.4f, 0.4f, 0.4f, 0.4f); + // Diffuse + QVector4D diffuse(1.0f, 1.0f, 1.0f, 1.0f); + // Specular + QVector4D specular(0.0f, 0.0f, 0.0f, 1.0f); + int is_both_sides; + viewer->glGetIntegerv(GL_LIGHT_MODEL_TWO_SIDE, + &is_both_sides); + program = &facet_program; + program->bind(); + program->setUniformValue("mvp_matrix", mvp_mat); + program->setUniformValue("mv_matrix", mv_mat); + program->setUniformValue("light_pos", position); + program->setUniformValue("light_diff",diffuse); + program->setUniformValue("light_spec", specular); + program->setUniformValue("light_amb", ambient); + program->setUniformValue("spec_power", 51.8f); + program->setUniformValue("is_two_side", is_both_sides); + program->setUniformValue("is_selected", false); + + vaos[0]->bind(); + + program->setAttributeValue("colors", this->color()); + glDrawElements(GL_TRIANGLES, static_cast(indices.size()), + GL_UNSIGNED_INT, indices.data()); + program->release(); + vaos[0]->release(); + + drawPoints(viewer); +} + +void Scene_alpha_shape_item::drawPoints(CGAL::Three::Viewer_interface* viewer) const +{ + if(!are_buffers_filled) + { + computeElements(); + initializeBuffers(viewer); + } + + vaos[0]->bind(); + attribBuffers(viewer, PROGRAM_NO_SELECTION); + program = getShaderProgram(PROGRAM_NO_SELECTION); + program->bind(); + program->setAttributeValue("colors", QColor(255,0,0)); + viewer->glDrawArrays(GL_POINTS, 0, static_cast(point_set.size())); + program->release(); + vaos[0]->release(); +} + +void Scene_alpha_shape_item::invalidateOpenGLBuffers() +{ + are_buffers_filled = false; +} + +void Scene_alpha_shape_item::computeElements() const +{ + QApplication::setOverrideCursor(Qt::WaitCursor); + indices.resize(0); + + std::list facets; + alpha_shape.get_alpha_shape_facets(std::back_inserter(facets), Alpha_shape_3::REGULAR); + + for(std::list::iterator fit = facets.begin(); + fit != facets.end(); + ++fit) { + const Cell_handle& ch = fit->first; + const int index = fit->second; + + const unsigned int& a = ch->vertex((index+1)&3)->info(); + const unsigned int& b = ch->vertex((index+2)&3)->info(); + const unsigned int& c = ch->vertex((index+3)&3)->info(); + + indices.push_back(a); indices.push_back(b); indices.push_back(c); + } + QApplication::restoreOverrideCursor(); +} + +void Scene_alpha_shape_item::initializeBuffers(CGAL::Three::Viewer_interface *viewer)const +{ + program = &facet_program; + program->bind(); + vaos[0]->bind(); + buffers[0].bind(); + buffers[0].allocate(vertices.data(), + static_cast(vertices.size()*sizeof(float))); + program->enableAttributeArray("vertex"); + program->setAttributeBuffer("vertex",GL_FLOAT,0,3); + buffers[0].release(); + vaos[0]->release(); + program->release(); + + program = viewer->getShaderProgram(PROGRAM_NO_SELECTION); + program->bind(); + vaos[0]->bind(); + buffers[0].bind(); + program->enableAttributeArray("vertex"); + program->setAttributeBuffer("vertex",GL_FLOAT,0,3); + buffers[0].release(); + vaos[0]->release(); + program->release(); + are_buffers_filled = true; +} + +void Scene_alpha_shape_item::alpha_changed(int i) +{ + if (alpha_shape.number_of_alphas() > 0){ + if(i < 100){ + int n = static_cast((i * alpha_shape.number_of_alphas())/ 100); + if(n == 0) n++; + alpha_shape.set_alpha(alpha_shape.get_nth_alpha(n)); + } else { + Alpha_iterator alpha_end_it = alpha_shape.alpha_end(); + alpha_shape.set_alpha((*(--alpha_end_it))+1); + } + } else { + alpha_shape.set_alpha(0); + } + invalidateOpenGLBuffers(); + itemChanged(); +} +void Scene_alpha_shape_item::createPolygonSoup(std::vector&points, + std::vector > &polys)const +{ + //fill points + bool is_first = true; + for(Alpha_shape_3::Vertex_iterator it = alpha_shape.all_vertices_begin(); + it != alpha_shape.all_vertices_end(); + ++it) + { + if(is_first) + is_first = false; + else + points.push_back(it->point()); + } + //fill polygons + + for(std::size_t i=0; i poly; + poly.resize(3); + for(int j=0; j<3; ++j) + { + poly[j] = indices[i+j] - 1; + } + polys.push_back(poly); + } +} +#include "Alpha_shape_plugin.moc" diff --git a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Alpha_shape_widget.ui b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Alpha_shape_widget.ui new file mode 100644 index 00000000000..4dfaf666ba7 --- /dev/null +++ b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Alpha_shape_widget.ui @@ -0,0 +1,103 @@ + + + AlphaShapesWidget + + + + 0 + 0 + 400 + 141 + + + + Alpha Shapes + + + + + + + + + + + Alpha: + + + + + + + % + + + 100 + + + + + + + Qt::Horizontal + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Create Alpha Shape Item + + + + + + + Create Polygon Soup + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + diff --git a/Polyhedron/demo/Polyhedron/Plugins/Point_set/CMakeLists.txt b/Polyhedron/demo/Polyhedron/Plugins/Point_set/CMakeLists.txt index ffe94219b0b..c5bab05f73f 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Point_set/CMakeLists.txt +++ b/Polyhedron/demo/Polyhedron/Plugins/Point_set/CMakeLists.txt @@ -61,3 +61,7 @@ endif() polyhedron_demo_plugin(point_set_interference_plugin Point_set_interference_plugin) target_link_libraries(point_set_interference_plugin scene_points_with_normal_item) + + qt5_wrap_ui( alpha_shapeUI_FILES Alpha_shape_widget.ui ) + polyhedron_demo_plugin(alpha_shape_plugin Alpha_shape_plugin ${alpha_shapeUI_FILES}) + target_link_libraries(alpha_shape_plugin scene_points_with_normal_item scene_c3t3_item) From 551446d098e0d654801d3374a0f3ba201c3abef1 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Thu, 18 May 2017 15:59:21 +0200 Subject: [PATCH 2/3] changes : - don't ++ if alpha = 0 - don't use a percentage of the alpha max value - automatically create the item if the selected item for the plugin is a points_with_normals_item --- .../Plugins/Point_set/Alpha_shape_plugin.cpp | 21 ++++++++++++++----- .../Plugins/Point_set/Alpha_shape_widget.ui | 5 ++++- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Alpha_shape_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Alpha_shape_plugin.cpp index c283f95f378..42c58cc2a4b 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Alpha_shape_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Alpha_shape_plugin.cpp @@ -85,6 +85,7 @@ public : Alpha_shape_3 alpha_shape; void createPolygonSoup(std::vector& points, std::vector >& polys) const; + std::size_t getNbofAlphas()const { return alpha_shape.number_of_alphas(); } public Q_SLOTS: void alpha_changed(int); private: @@ -177,7 +178,13 @@ public Q_SLOTS: void on_actionAlphaShapes_triggered() { if(dock_widget->isVisible()) { dock_widget->hide(); } - else { dock_widget->show(); } + else { + dock_widget->show(); + Scene_points_with_normal_item* sel_item = + qobject_cast(scene->item(scene->mainSelectionIndex())); + if(sel_item) + on_as_itemPushButton_clicked(); + } } void on_as_itemPushButton_clicked() @@ -239,7 +246,11 @@ public Q_SLOTS: !as_item) dock_widget->as_itemPushButton->setEnabled(true); else if( qobject_cast( scene->item(i) ) ) + { + dock_widget->horizontalSlider->setMaximum(qobject_cast( scene->item(i) )->getNbofAlphas()); + dock_widget->spinBox->setMaximum(qobject_cast( scene->item(i) )->getNbofAlphas()); dock_widget->poly_itemPushButton->setEnabled(true); + } } void closure() Q_DECL_OVERRIDE { @@ -433,10 +444,10 @@ void Scene_alpha_shape_item::initializeBuffers(CGAL::Three::Viewer_interface *vi void Scene_alpha_shape_item::alpha_changed(int i) { - if (alpha_shape.number_of_alphas() > 0){ - if(i < 100){ - int n = static_cast((i * alpha_shape.number_of_alphas())/ 100); - if(n == 0) n++; + std::size_t n = i; + if (alpha_shape.number_of_alphas() > 0 + && n > 0){ + if(n < alpha_shape.number_of_alphas()){ alpha_shape.set_alpha(alpha_shape.get_nth_alpha(n)); } else { Alpha_iterator alpha_end_it = alpha_shape.alpha_end(); diff --git a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Alpha_shape_widget.ui b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Alpha_shape_widget.ui index 4dfaf666ba7..9acd6301056 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Alpha_shape_widget.ui +++ b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Alpha_shape_widget.ui @@ -29,7 +29,7 @@ - % + 100 @@ -38,6 +38,9 @@ + + 100 + Qt::Horizontal From 73007cc17c16321777b5fd36c60881e043eb71f8 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Mon, 22 May 2017 09:55:11 +0200 Subject: [PATCH 3/3] silent warnings and change name of generated polygon_soup --- .../Plugins/Point_set/Alpha_shape_plugin.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Alpha_shape_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Alpha_shape_plugin.cpp index 42c58cc2a4b..47666ccf10f 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Alpha_shape_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Alpha_shape_plugin.cpp @@ -71,7 +71,7 @@ class Scene_alpha_shape_item : public CGAL::Three::Scene_item Q_OBJECT public : Scene_alpha_shape_item(Scene_points_with_normal_item* , int alpha); - bool supportsRenderingMode(RenderingMode m) const { + bool supportsRenderingMode(RenderingMode m) const Q_DECL_OVERRIDE { return (m == Flat); } void draw(CGAL::Three::Viewer_interface* viewer) const Q_DECL_OVERRIDE; @@ -129,7 +129,7 @@ class Q_DECL_EXPORT Alpha_shape_plugin : Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.PluginInterface/1.0") public : - void init(QMainWindow* mainWindow, CGAL::Three::Scene_interface* scene_interface, Messages_interface*) { + void init(QMainWindow* mainWindow, CGAL::Three::Scene_interface* scene_interface, Messages_interface*)Q_DECL_OVERRIDE { this->scene = scene_interface; this->mw = mainWindow; QAction* actionAlphaShapes= new QAction("Alpha Shapes", mw); @@ -162,11 +162,11 @@ public : } - bool applicable(QAction*) const + bool applicable(QAction*) const Q_DECL_OVERRIDE { return qobject_cast( scene->item( scene->mainSelectionIndex() ) ); } - QList actions() const { + QList actions() const Q_DECL_OVERRIDE { return _actions; } public Q_SLOTS: @@ -232,7 +232,9 @@ public Q_SLOTS: { new_item->new_triangle(poly[0], poly[1], poly[2]); } - new_item->setName(as_item->name()); + QString name = as_item->name().left(as_item->name().size() - QString("(alpha shape)").size()); + name.append("(polygon soup)"); + new_item->setName(name); as_item->setVisible(false); scene->addItem(new_item); } @@ -247,8 +249,8 @@ public Q_SLOTS: dock_widget->as_itemPushButton->setEnabled(true); else if( qobject_cast( scene->item(i) ) ) { - dock_widget->horizontalSlider->setMaximum(qobject_cast( scene->item(i) )->getNbofAlphas()); - dock_widget->spinBox->setMaximum(qobject_cast( scene->item(i) )->getNbofAlphas()); + dock_widget->horizontalSlider->setMaximum(static_cast(qobject_cast( scene->item(i) )->getNbofAlphas())); + dock_widget->spinBox->setMaximum(static_cast(qobject_cast( scene->item(i) )->getNbofAlphas())); dock_widget->poly_itemPushButton->setEnabled(true); } } @@ -257,7 +259,6 @@ public Q_SLOTS: dock_widget->hide(); } private: - CGAL::Three::Scene_item* triangle; QList _actions; DockWidget* dock_widget; Scene_alpha_shape_item* as_item; @@ -448,7 +449,7 @@ void Scene_alpha_shape_item::alpha_changed(int i) if (alpha_shape.number_of_alphas() > 0 && n > 0){ if(n < alpha_shape.number_of_alphas()){ - alpha_shape.set_alpha(alpha_shape.get_nth_alpha(n)); + alpha_shape.set_alpha(alpha_shape.get_nth_alpha(static_cast(n))); } else { Alpha_iterator alpha_end_it = alpha_shape.alpha_end(); alpha_shape.set_alpha((*(--alpha_end_it))+1);