Merge pull request #6130 from cjamin/patch-1

Bug fix: `remove_outliers` was removing ALL points when no outliers were found
This commit is contained in:
Laurent Rineau 2021-11-25 17:28:39 +01:00
commit 17a7d8cfbc
1 changed files with 26 additions and 22 deletions

View File

@ -247,11 +247,15 @@ remove_outliers(
if (threshold_distance != FT(0))
f2r = std::partition (sorted_points.begin(), sorted_points.end(),
[&threshold_distance](const std::pair<FT, value_type>& p) -> bool
[sq_threshold_distance = CGAL::square(threshold_distance)](const std::pair<FT, value_type>& p) -> bool
{
return p.first < threshold_distance * threshold_distance;
return p.first < sq_threshold_distance;
});
iterator out = points.end();
if (f2r != sorted_points.end())
{
if (static_cast<std::size_t>(std::distance (sorted_points.begin(), f2r)) < first_index_to_remove)
{
std::nth_element (f2r,
@ -266,7 +270,6 @@ remove_outliers(
// Replaces [points.begin(), points.end()) range by the sorted content.
iterator pit = points.begin();
iterator out = points.begin();
for (auto sit = sorted_points.begin(); sit != sorted_points.end(); ++ sit)
{
@ -275,6 +278,7 @@ remove_outliers(
out = pit;
++ pit;
}
}
callback_wrapper.join();