diff --git a/Advancing_front_surface_reconstruction/include/CGAL/Advancing_front_surface_reconstruction.h b/Advancing_front_surface_reconstruction/include/CGAL/Advancing_front_surface_reconstruction.h index 89dc328bc51..c8a27921dab 100644 --- a/Advancing_front_surface_reconstruction/include/CGAL/Advancing_front_surface_reconstruction.h +++ b/Advancing_front_surface_reconstruction/include/CGAL/Advancing_front_surface_reconstruction.h @@ -2359,13 +2359,14 @@ advancing_front_surface_reconstruction(PointIterator b, } -template + template void -advancing_front_surface_reconstruction(PointIterator b, - PointIterator e, - Polyhedron_3& polyhedron, - double radius_ratio_bound = 5, - double beta = 0.52) +advancing_front_surface_reconstructionP(PointIterator b, + PointIterator e, + Polyhedron_3& polyhedron, + Filter filter, + double radius_ratio_bound = 5, + double beta = 0.52) { typedef Advancing_front_surface_reconstruction_vertex_base_3 LVb; typedef Advancing_front_surface_reconstruction_cell_base_3 LCb; @@ -2373,7 +2374,7 @@ advancing_front_surface_reconstruction(PointIterator b, typedef Triangulation_data_structure_3 Tds; typedef Delaunay_triangulation_3 Triangulation_3; - typedef Advancing_front_surface_reconstruction Reconstruction; + typedef Advancing_front_surface_reconstruction Reconstruction; typedef typename Kernel::Point_3 Point_3; Triangulation_3 dt( boost::make_transform_iterator(b, AFSR::Auto_count()), @@ -2382,7 +2383,7 @@ advancing_front_surface_reconstruction(PointIterator b, AFSR_options opt; opt.K = radius_ratio_bound; // TODO: What to do with beta??? - Reconstruction R(dt, opt); + Reconstruction R(dt, opt,filter); R.run(opt); AFSR::construct_polyhedron(polyhedron, R); } diff --git a/Polyhedron/demo/Polyhedron/CMakeLists.txt b/Polyhedron/demo/Polyhedron/CMakeLists.txt index e038522e1ab..dc8e2493dfc 100644 --- a/Polyhedron/demo/Polyhedron/CMakeLists.txt +++ b/Polyhedron/demo/Polyhedron/CMakeLists.txt @@ -355,7 +355,7 @@ if(CGAL_Qt4_FOUND AND QT4_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND) target_link_libraries(pca_plugin scene_polyhedron_item scene_basic_objects) qt4_wrap_ui( advancing_frontUI_FILES Polyhedron_demo_advancing_front_plugin.ui) - polyhedron_demo_plugin(advancing_front_plugin Polyhedron_demo_advancing_front_plugin Polyhedron_demo_advancing_front_plugin_impl ${advancing_frontUI_FILES}) + polyhedron_demo_plugin(advancing_front_plugin Polyhedron_demo_advancing_front_plugin ${advancing_frontUI_FILES}) target_link_libraries(advancing_front_plugin scene_polygon_soup_item scene_points_with_normal_item) if(EIGEN3_FOUND) diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_advancing_front_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_advancing_front_plugin.cpp index 837e1598425..350a8148368 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_advancing_front_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_advancing_front_plugin.cpp @@ -3,7 +3,9 @@ #include "Polyhedron_demo_plugin_helper.h" #include "Polyhedron_demo_plugin_interface.h" #include - +#include "Kernel_type.h" +#include "Polyhedron_type.h" +#include #include #include @@ -14,10 +16,28 @@ #include "ui_Polyhedron_demo_advancing_front_plugin.h" -// Reconstructs a surface mesh from a point set and writes facet indices into polygon soup. -Polyhedron* advancing_front_reconstruct(const Point_set& points, - double sm_perimeter, - double sm_area); +struct Perimeter { + + double bound; + + Perimeter(double bound) + : bound(bound) + {} + + bool operator()(const Kernel::Point_3& p, const Kernel::Point_3& q, const Kernel::Point_3& r) const + { + if(bound == 0){ + return true; + } + double d = sqrt(squared_distance(p,q)); + if(d>bound) return true; + d += sqrt(squared_distance(p,r)) ; + if(d>bound) return true; + d+= sqrt(squared_distance(q,r)); + return d>bound; + } +}; + class Polyhedron_demo_advancing_front_plugin : public QObject, @@ -61,7 +81,6 @@ class Polyhedron_demo_advancing_front_plugin_dialog : public QDialog, private Ui } double trianglePerimeter() const { return m_inputPerimeter->value(); } - double triangleArea() const { return m_inputArea->value(); } }; void Polyhedron_demo_advancing_front_plugin::on_actionAdvancingFrontReconstruction_triggered() @@ -82,7 +101,6 @@ void Polyhedron_demo_advancing_front_plugin::on_actionAdvancingFrontReconstructi if(!dialog.exec()) return; const double sm_perimeter = dialog.trianglePerimeter(); - const double sm_area = dialog.triangleArea(); QApplication::setOverrideCursor(Qt::WaitCursor); @@ -90,15 +108,15 @@ void Polyhedron_demo_advancing_front_plugin::on_actionAdvancingFrontReconstructi // Add polyhedron to scene // Reconstruct point set as a polyhedron - Polyhedron *poly = advancing_front_reconstruct(*points, sm_perimeter, sm_area); - - Scene_polyhedron_item* new_item = new Scene_polyhedron_item(poly); + Scene_polyhedron_item* new_item = new Scene_polyhedron_item(Polyhedron()); + Polyhedron& P = * const_cast(new_item->polyhedron()); + Perimeter filter(sm_perimeter); + CGAL::advancing_front_surface_reconstructionP((points)->begin(), points->end(), P, filter); new_item->setName(tr("%1 Advancing Front (%2 %3)") .arg(point_set_item->name()) - .arg(sm_perimeter) - .arg(sm_area)); + .arg(sm_perimeter)); new_item->setColor(Qt::lightGray); scene->addItem(new_item); diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_advancing_front_plugin.ui b/Polyhedron/demo/Polyhedron/Polyhedron_demo_advancing_front_plugin.ui index b66834514ab..a699faed2b8 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_advancing_front_plugin.ui +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_advancing_front_plugin.ui @@ -17,14 +17,14 @@ - Min triangle perimeter: + Max triangle perimeter: - * average spacing + 0.000000000000000 @@ -37,36 +37,7 @@ - - - - Max triangle area: - - - - - - - * average spacing^2 - - - 0 - - - 0.000000000000000 - - - 20.000000000000000 - - - 1.000000000000000 - - - 0.000000000000000 - - - - + QDialogButtonBox::Cancel|QDialogButtonBox::Ok