diff --git a/Polyhedron/demo/Polyhedron/CMakeLists.txt b/Polyhedron/demo/Polyhedron/CMakeLists.txt index d4ef554305e..82410e0fa0f 100644 --- a/Polyhedron/demo/Polyhedron/CMakeLists.txt +++ b/Polyhedron/demo/Polyhedron/CMakeLists.txt @@ -336,7 +336,8 @@ if(CGAL_Qt4_FOUND AND QT4_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND) target_link_libraries(pca_plugin scene_polyhedron_item scene_basic_objects) if(EIGEN3_FOUND) - polyhedron_demo_plugin(scale_space_reconstruction_plugin Polyhedron_demo_scale_space_reconstruction_plugin) + qt4_wrap_ui( scale_spaceUI_FILES Polyhedron_demo_scale_space_reconstruction_plugin.ui) + polyhedron_demo_plugin(scale_space_reconstruction_plugin Polyhedron_demo_scale_space_reconstruction_plugin ${scale_spaceUI_FILES}) target_link_libraries(scale_space_reconstruction_plugin scene_polygon_soup_item scene_polyhedron_item scene_points_with_normal_item) endif() diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_scale_space_reconstruction_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_scale_space_reconstruction_plugin.cpp index 83865251710..8e91998dfbf 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_scale_space_reconstruction_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_scale_space_reconstruction_plugin.cpp @@ -12,6 +12,24 @@ #include "Polyhedron_demo_plugin_helper.h" #include "Polyhedron_demo_plugin_interface.h" +#include "ui_Polyhedron_demo_scale_space_reconstruction_plugin.h" + + +class Polyhedron_demo_scale_space_reconstruction_plugin_dialog : public QDialog, private Ui::ScaleSpaceOptionsDialog +{ + Q_OBJECT + public: + Polyhedron_demo_scale_space_reconstruction_plugin_dialog(QWidget* /*parent*/ = 0) + { + setupUi(this); + } + + double neighbors() const { return m_neighbors->value(); } + double iterations() const { return m_iterations->value(); } + double samples() const { return m_samples->value(); } + bool generate_smoothed() const { return m_genSmooth->isChecked(); } +}; + #include class Polyhedron_demo_scale_space_reconstruction_plugin : @@ -54,6 +72,11 @@ void Polyhedron_demo_scale_space_reconstruction_plugin::on_actionScaleSpaceRecon if(pts_item) { + //generate the dialog box to set the options + Polyhedron_demo_scale_space_reconstruction_plugin_dialog dialog; + if(!dialog.exec()) + return; + // wait cursor QApplication::setOverrideCursor(Qt::WaitCursor); @@ -61,62 +84,69 @@ void Polyhedron_demo_scale_space_reconstruction_plugin::on_actionScaleSpaceRecon time.start(); std::cout << "Scale scape surface reconstruction..."; - // TODO add dialog box for the parameters - unsigned int neighbors = 30; - unsigned int iterations = 4; - unsigned int samples = 200; - typedef CGAL::Scale_space_surface_reconstructer_3 Recontructor; - Recontructor reconstruct( neighbors, samples ); + Recontructor reconstruct( dialog.neighbors(), dialog.samples() ); reconstruct.reconstruct_surface( pts_item->point_set()->begin(), pts_item->point_set()->end(), - iterations + dialog.iterations() ); std::cout << "ok (" << time.elapsed() << " ms)" << std::endl; - //create the non-smoothed and the smoothed polygon soup items - Scene_polygon_soup_item *new_item = new Scene_polygon_soup_item(); - Scene_polygon_soup_item *new_item_smoothed = new Scene_polygon_soup_item(); + //create item for the reconstruction output with input point set + Scene_polygon_soup_item* new_item = new Scene_polygon_soup_item(); new_item->init_polygon_soup(pts_item->point_set()->size(), - reconstruct.get_surface_size() ); - new_item_smoothed->init_polygon_soup(pts_item->point_set()->size(), - reconstruct.get_surface_size() ); + reconstruct.get_surface_size() ); typedef Point_set::iterator Point_iterator; + for(Point_iterator it = pts_item->point_set()->begin(), end = pts_item->point_set()->end(); it!=end; ++it) { new_item->new_vertex(it->x(), it->y(), it->z()); } - typedef Recontructor::Point_iterator SS_point_iterator; - for(SS_point_iterator it = reconstruct.scale_space_begin(), - end = reconstruct.scale_space_end(); it!=end; ++it) - { - new_item_smoothed->new_vertex(it->x(), it->y(), it->z()); - } - for (Recontructor::Triple_iterator it=reconstruct.surface_begin(), end=reconstruct.surface_end();it!=end;++it) { new_item->new_triangle(it->first, it->second, it->third); - new_item_smoothed->new_triangle(it->first, it->second, it->third); } new_item->finalize_polygon_soup(); - new_item_smoothed->finalize_polygon_soup(); new_item->setName(tr("%1 (ss reconstruction)").arg(scene->item(index)->name())); new_item->setColor(Qt::magenta); new_item->setRenderingMode(FlatPlusEdges); scene->addItem(new_item); - new_item_smoothed->setName(tr("%1 (ss smoothed reconstruction)").arg(scene->item(index)->name())); - new_item_smoothed->setColor(Qt::magenta); - new_item_smoothed->setRenderingMode(FlatPlusEdges); - scene->addItem(new_item_smoothed); + if ( dialog.generate_smoothed() ){ + //create item for the reconstruction output with input point set smoothed + Scene_polygon_soup_item *new_item_smoothed = new Scene_polygon_soup_item(); + + new_item_smoothed->init_polygon_soup(pts_item->point_set()->size(), + reconstruct.get_surface_size() ); + + typedef Recontructor::Point_iterator SS_point_iterator; + for(SS_point_iterator it = reconstruct.scale_space_begin(), + end = reconstruct.scale_space_end(); it!=end; ++it) + { + new_item_smoothed->new_vertex(it->x(), it->y(), it->z()); + } + + for (Recontructor::Triple_iterator it=reconstruct.surface_begin(), + end=reconstruct.surface_end();it!=end;++it) + { + new_item_smoothed->new_triangle(it->first, it->second, it->third); + } + + new_item_smoothed->finalize_polygon_soup(); + + new_item_smoothed->setName(tr("%1 (ss smoothed reconstruction)").arg(scene->item(index)->name())); + new_item_smoothed->setColor(Qt::magenta); + new_item_smoothed->setRenderingMode(FlatPlusEdges); + scene->addItem(new_item_smoothed); + } // default cursor QApplication::restoreOverrideCursor(); diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_scale_space_reconstruction_plugin.ui b/Polyhedron/demo/Polyhedron/Polyhedron_demo_scale_space_reconstruction_plugin.ui new file mode 100644 index 00000000000..61a9c332ad4 --- /dev/null +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_scale_space_reconstruction_plugin.ui @@ -0,0 +1,128 @@ + + + ScaleSpaceOptionsDialog + + + + 0 + 0 + 476 + 272 + + + + Scale-Space Surface Reconstruction + + + + + + Also generate the smoothed version + + + true + + + + + + + Iterations + + + + + + + Size of sample to estimate neighborhood + + + + + + + Average neighborhood size + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + 1000000 + + + 200 + + + + + + + 1 + + + 1000000 + + + 4 + + + + + + + 0 + + + 100000 + + + 30 + + + + + + + + + buttonBox + accepted() + ScaleSpaceOptionsDialog + accept() + + + 177 + 123 + + + 53 + 125 + + + + + buttonBox + rejected() + ScaleSpaceOptionsDialog + reject() + + + 257 + 119 + + + 257 + 143 + + + + +