Skip to content

Commit

Permalink
Fix the removed indices of UniformSampling
Browse files Browse the repository at this point in the history
This ensures that all removed indices are set and not only those
of the indices that are visited.
  • Loading branch information
Wannes Van Loock committed Oct 12, 2017
1 parent 2880ea1 commit bc6c2b7
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions filters/include/pcl/filters/impl/uniform_sampling.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ pcl::UniformSampling<PointT>::applyFilter (PointCloud &output)
divb_mul_ = Eigen::Vector4i (1, div_b_[0], div_b_[0] * div_b_[1], 0);

Filter<PointT>::removed_indices_->clear();
std::vector<bool> visited_indices (indices_->size (), false);
// First pass: build a set of leaves with the point index closest to the leaf center
for (size_t cp = 0; cp < indices_->size (); ++cp)
{
Expand All @@ -90,10 +91,6 @@ pcl::UniformSampling<PointT>::applyFilter (PointCloud &output)
!pcl_isfinite (input_->points[(*indices_)[cp]].y) ||
!pcl_isfinite (input_->points[(*indices_)[cp]].z))
{
if (Filter<PointT>::extract_removed_indices_)
{
Filter<PointT>::removed_indices_->push_back ((*indices_)[cp]);
}
continue;
}
}
Expand All @@ -110,6 +107,7 @@ pcl::UniformSampling<PointT>::applyFilter (PointCloud &output)
if (leaf.idx == -1)
{
leaf.idx = (*indices_)[cp];
visited_indices[leaf.idx] = true;
continue;
}

Expand All @@ -126,6 +124,19 @@ pcl::UniformSampling<PointT>::applyFilter (PointCloud &output)
}

leaf.idx = (*indices_)[cp];
visited_indices[leaf.idx] = true;
}
}

// All not visited indices should be removed
if (Filter<PointT>::extract_removed_indices_)
{
for (size_t cp = 0; cp < indices_->size (); ++cp)
{
if (!visited_indices[cp])
{
Filter<PointT>::removed_indices_->push_back (cp);
}
}
}

Expand Down

0 comments on commit bc6c2b7

Please sign in to comment.