Documentation and plugin

This commit is contained in:
Simon Giraudot 2021-05-06 15:43:28 +02:00
parent 26d9014334
commit ae885f539c
3 changed files with 128 additions and 90 deletions

View File

@ -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<Point_3, PointMap>,
internal::Equal_epsilon_points_3<Point_3, PointMap> > >::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<Point_3, PointMap>(epsilon, point_map),
internal::Equal_epsilon_points_3<Point_3, PointMap>(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<geom_traits::Point_3>`}
\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}

View File

@ -49,17 +49,20 @@ struct Grid_simplify_functor
{
Point_set* points;
double grid_size;
unsigned int min_points_per_cell;
boost::shared_ptr<Point_set::iterator> 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<CGAL::Sequential_tag> (functor, "Grid simplyfing...", mw);
// Computes points to remove by Grid Clustering

View File

@ -6,73 +6,18 @@
<rect>
<x>0</x>
<y>0</y>
<width>392</width>
<height>249</height>
<width>361</width>
<height>286</height>
</rect>
</property>
<property name="windowTitle">
<string>Simplification</string>
</property>
<layout class="QGridLayout" columnstretch="0,1" columnminimumwidth="0,1">
<item row="2" column="0">
<widget class="QRadioButton" name="Random">
<item row="9" column="1">
<widget class="DoubleEdit" name="m_maximumSurfaceVariation">
<property name="text">
<string>Random</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QSpinBox" name="m_maximumClusterSize">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>2147483647</number>
</property>
<property name="value">
<number>10</number>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Grid Cell Size</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QDoubleSpinBox" name="m_randomSimplificationPercentage">
<property name="suffix">
<string> %</string>
</property>
<property name="decimals">
<number>2</number>
</property>
<property name="minimum">
<double>0.100000000000000</double>
</property>
<property name="maximum">
<double>100.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>50.000000000000000</double>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Maximum Surface Variation</string>
<string>0.333333</string>
</property>
</widget>
</item>
@ -101,7 +46,48 @@
</property>
</widget>
</item>
<item row="9" column="0">
<item row="4" column="0">
<widget class="QRadioButton" name="Grid">
<property name="text">
<string>Grid</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QRadioButton" name="Random">
<property name="text">
<string>Random</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Grid Cell Size</string>
</property>
</widget>
</item>
<item row="11" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QRadioButton" name="Hierarchy">
<property name="text">
<string>Hierarchy</string>
</property>
</widget>
</item>
<item row="10" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
@ -114,13 +100,36 @@
</property>
</spacer>
</item>
<item row="7" column="0">
<item row="8" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Maximum Cluster Size</string>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QSpinBox" name="m_maximumClusterSize">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>2147483647</number>
</property>
<property name="value">
<number>10</number>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Maximum Surface Variation</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
@ -128,34 +137,45 @@
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QRadioButton" name="Grid">
<property name="text">
<string>Grid</string>
<item row="3" column="1">
<widget class="QDoubleSpinBox" name="m_randomSimplificationPercentage">
<property name="suffix">
<string> %</string>
</property>
<property name="decimals">
<number>2</number>
</property>
<property name="minimum">
<double>0.100000000000000</double>
</property>
<property name="maximum">
<double>100.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>50.000000000000000</double>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QRadioButton" name="Hierarchy">
<widget class="QLabel" name="label">
<property name="text">
<string>Hierarchy</string>
<string>Minimum points per cell</string>
</property>
</widget>
</item>
<item row="10" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<item row="6" column="1">
<widget class="QSpinBox" name="m_minPointsPerCell">
<property name="enabled">
<bool>false</bool>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
<property name="minimum">
<number>1</number>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="DoubleEdit" name="m_maximumSurfaceVariation">
<property name="text">
<string>0.333333</string>
<property name="maximum">
<number>400000000</number>
</property>
</widget>
</item>