Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes remove_indices in UniformSampling #1902

Merged
merged 1 commit into from
Sep 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) :
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will break the ABI, which pushes things to 1.9.0

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we just have two constructors? One parameterless, one with compulsory bool.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will need to remember to delete it after ^^.

Let's think the other way around, maybe 1.8.1 simply doesn't make sense anymore, it's been more than year. Let's just adopt the new 1.8.0-dev designation and start working on a release with new features, etc... Under that context it's no problem to have the ABI break.

Copy link
Member

@taketwo taketwo Jun 26, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On one hand, I like this idea. On the other hand, it pushes the next release (whichever number it will have) quite far in the future. What about releasing the current state as 1.8.1 (or 1.9.0) ASAP, and then moving on with merging this PR and other "1.9.0 milestone" features?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM 👍 Let me have a look at that change log and cry a little :D

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha :) Ok, and I'll work on "-dev".

Filter<PointT>(extract_removed_indices),
leaves_ (),
leaf_size_ (Eigen::Vector4f::Zero ()),
inverse_leaf_size_ (Eigen::Vector4f::Zero ()),
Expand Down