diff --git a/Point_set_processing_3/include/CGAL/grid_simplify_point_set.h b/Point_set_processing_3/include/CGAL/grid_simplify_point_set.h index 31accd06e80..4547bd8c6d3 100644 --- a/Point_set_processing_3/include/CGAL/grid_simplify_point_set.h +++ b/Point_set_processing_3/include/CGAL/grid_simplify_point_set.h @@ -123,7 +123,7 @@ public: /// Utility class for grid_simplify_point_set(): -/// 3D points set which allows at most 1 point per cell +/// 3D points set which allows at most 1 (or N) point per cell /// of a grid of cell size = epsilon. /// /// Warning: @@ -154,14 +154,14 @@ private: internal::Hash_epsilon_points_3, internal::Equal_epsilon_points_3 > >::type; - std::size_t min_points_per_cells; + std::size_t min_points_per_cell; public: - Epsilon_point_set_3 (double epsilon, PointMap point_map, std::size_t min_points_per_cells = 1) + Epsilon_point_set_3 (double epsilon, PointMap point_map, std::size_t min_points_per_cell = 1) : Base(10, internal::Hash_epsilon_points_3(epsilon, point_map), internal::Equal_epsilon_points_3(epsilon, point_map)) - , min_points_per_cells (min_points_per_cells) + , min_points_per_cell (min_points_per_cell) { CGAL_point_set_processing_precondition(epsilon > 0); } @@ -177,7 +177,7 @@ private: { auto iter = Base::insert(std::make_pair (p, 0)); iter.first->second ++; - return iter.first->second == min_points_per_cells; + return iter.first->second == min_points_per_cell; } bool insert (const Point_3& p, const Tag_false&) @@ -217,6 +217,16 @@ private: \cgalParamDefault{`CGAL::Identity_property_map`} \cgalParamNEnd + \cgalParamNBegin{min_points_per_cell} + \cgalParamDescription{minimum number of points in a cell such + that a point in this cell is kept after simplification} + \cgalParamType{unsigned int} + \cgalParamDefault{1} + \cgalParamExtra{If a value greater than 1 is used, the + algorithm also acts an outlier filtering algorithm, by removing + low-density areas.} + \cgalParamNEnd + \cgalParamNBegin{callback} \cgalParamDescription{a mechanism to get feedback on the advancement of the algorithm while it's running and to interrupt it if needed} diff --git a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_simplification_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_simplification_plugin.cpp index d75c2c67a12..4bbb40857b0 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_simplification_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_simplification_plugin.cpp @@ -49,17 +49,20 @@ struct Grid_simplify_functor { Point_set* points; double grid_size; + unsigned int min_points_per_cell; boost::shared_ptr result; - Grid_simplify_functor (Point_set* points, double grid_size) - : points (points), grid_size (grid_size), result (new Point_set::iterator) { } + Grid_simplify_functor (Point_set* points, double grid_size, unsigned min_points_per_cell) + : points (points), grid_size (grid_size), min_points_per_cell(min_points_per_cell) + , result (new Point_set::iterator) { } void operator()() { *result = CGAL::grid_simplify_point_set(*points, grid_size, points->parameters(). - callback (*(this->callback()))); + callback (*(this->callback())). + min_points_per_cell (min_points_per_cell)); } }; @@ -144,6 +147,7 @@ class Point_set_demo_point_set_simplification_dialog : public QDialog, private U } double randomSimplificationPercentage() const { return m_randomSimplificationPercentage->value(); } double gridCellSize() const { return m_gridCellSize->value(); } + unsigned int minPointsPerCell() const { return m_minPointsPerCell->value(); } unsigned int maximumClusterSize() const { return m_maximumClusterSize->value(); } double maximumSurfaceVariation() const { return m_maximumSurfaceVariation->value(); } @@ -153,6 +157,7 @@ public Q_SLOTS: { m_randomSimplificationPercentage->setEnabled (toggled); m_gridCellSize->setEnabled (!toggled); + m_minPointsPerCell->setEnabled (!toggled); m_maximumClusterSize->setEnabled (!toggled); m_maximumSurfaceVariation->setEnabled (!toggled); } @@ -160,6 +165,7 @@ public Q_SLOTS: { m_randomSimplificationPercentage->setEnabled (!toggled); m_gridCellSize->setEnabled (toggled); + m_minPointsPerCell->setEnabled (toggled); m_maximumClusterSize->setEnabled (!toggled); m_maximumSurfaceVariation->setEnabled (!toggled); } @@ -167,6 +173,7 @@ public Q_SLOTS: { m_randomSimplificationPercentage->setEnabled (!toggled); m_gridCellSize->setEnabled (!toggled); + m_minPointsPerCell->setEnabled (!toggled); m_maximumClusterSize->setEnabled (toggled); m_maximumSurfaceVariation->setEnabled (toggled); } @@ -211,7 +218,8 @@ void Polyhedron_demo_point_set_simplification_plugin::on_actionSimplify_triggere } else if (method == 1) { - std::cerr << "Point set grid simplification (cell size = " << dialog.gridCellSize() <<" * average spacing)...\n"; + std::cerr << "Point set grid simplification (cell size = " << dialog.gridCellSize() <<" * average spacing, " + << dialog.minPointsPerCell() << " minimum point(s) per cell)" << std::endl; // Computes average spacing Compute_average_spacing_functor functor_as (points, 6); @@ -219,7 +227,7 @@ void Polyhedron_demo_point_set_simplification_plugin::on_actionSimplify_triggere double average_spacing = *functor_as.result; - Grid_simplify_functor functor (points, dialog.gridCellSize() * average_spacing); + Grid_simplify_functor functor (points, dialog.gridCellSize() * average_spacing, dialog.minPointsPerCell()); run_with_qprogressdialog (functor, "Grid simplyfing...", mw); // Computes points to remove by Grid Clustering diff --git a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_simplification_plugin.ui b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_simplification_plugin.ui index 45b189faf13..11132e68fb4 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_simplification_plugin.ui +++ b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_simplification_plugin.ui @@ -6,73 +6,18 @@ 0 0 - 392 - 249 + 361 + 286 Simplification - - + + - Random - - - true - - - - - - - false - - - 1 - - - 2147483647 - - - 10 - - - - - - - Grid Cell Size - - - - - - - % - - - 2 - - - 0.100000000000000 - - - 100.000000000000000 - - - 0.100000000000000 - - - 50.000000000000000 - - - - - - - Maximum Surface Variation + 0.333333 @@ -101,7 +46,48 @@ - + + + + Grid + + + + + + + Random + + + true + + + + + + + Grid Cell Size + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + Hierarchy + + + + Qt::Vertical @@ -114,13 +100,36 @@ - + Maximum Cluster Size + + + + false + + + 1 + + + 2147483647 + + + 10 + + + + + + + Maximum Surface Variation + + + @@ -128,34 +137,45 @@ - - - - Grid + + + + % + + + 2 + + + 0.100000000000000 + + + 100.000000000000000 + + + 0.100000000000000 + + + 50.000000000000000 - + - Hierarchy + Minimum points per cell - - - - Qt::Horizontal + + + + false - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + 1 - - - - - - 0.333333 + + 400000000