Skip to content

Commit

Permalink
Fixes remove_indices in UniformSampling
Browse files Browse the repository at this point in the history
  • Loading branch information
Francisco Facioni committed Jun 27, 2017
1 parent 1b005ff commit 49ddef0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
16 changes: 16 additions & 0 deletions filters/include/pcl/filters/impl/uniform_sampling.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,24 @@ pcl::UniformSampling<PointT>::applyFilter (PointCloud &output)
// Set up the division multiplier
divb_mul_ = Eigen::Vector4i (1, div_b_[0], div_b_[0] * div_b_[1], 0);

Filter<PointT>::removed_indices_->clear();
// 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)
{
if (!input_->is_dense)
{
// Check if the point is invalid
if (!pcl_isfinite (input_->points[(*indices_)[cp]].x) ||
!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;
}
}

Eigen::Vector4i ijk = Eigen::Vector4i::Zero ();
ijk[0] = static_cast<int> (floor (input_->points[(*indices_)[cp]].x * inverse_leaf_size_[0]));
Expand All @@ -110,7 +119,14 @@ pcl::UniformSampling<PointT>::applyFilter (PointCloud &output)

// If current point is closer, copy its index instead
if (diff_cur < diff_prev)
{
if (Filter<PointT>::extract_removed_indices_)
{
Filter<PointT>::removed_indices_->push_back (leaf.idx);
}

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

// Second pass: go over all leaves and copy data
Expand Down
3 changes: 2 additions & 1 deletion filters/include/pcl/filters/uniform_sampling.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ namespace pcl
typedef boost::shared_ptr<const UniformSampling<PointT> > ConstPtr;

/** \brief Empty constructor. */
UniformSampling () :
UniformSampling (bool extract_removed_indices = false) :
Filter<PointT>(extract_removed_indices),
leaves_ (),
leaf_size_ (Eigen::Vector4f::Zero ()),
inverse_leaf_size_ (Eigen::Vector4f::Zero ()),
Expand Down

0 comments on commit 49ddef0

Please sign in to comment.