Skip to content

Commit

Permalink
fix bugs in CropHull: not resize input, not cropping inside (PointClo…
Browse files Browse the repository at this point in the history
…udLibrary#1657)

* funciton applyFilter didn't clear output data before start adding new
point or indices

* issue PointCloudLibrary#1657: CropHull 3d not cropping inside.
[decision](piaggiofastforward@b8a8a2b)
  • Loading branch information
Daniil Nikulin committed Apr 7, 2020
1 parent 2610ed7 commit e1064c7
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions filters/include/pcl/filters/impl/crop_hull.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
template<typename PointT> void
pcl::CropHull<PointT>::applyFilter (PointCloud &output)
{
output.resize(0);
if (dim_ == 2)
{
// in this case we are assuming all the points lie in the same plane as the
Expand All @@ -69,6 +70,8 @@ pcl::CropHull<PointT>::applyFilter (PointCloud &output)
template<typename PointT> void
pcl::CropHull<PointT>::applyFilter (std::vector<int> &indices)
{
indices.resize(0);
indices.reserve(indices_->size());
if (dim_ == 2)
{
// in this case we are assuming all the points lie in the same plane as the
Expand Down Expand Up @@ -113,7 +116,7 @@ pcl::CropHull<PointT>::getHullCloudRange ()
if (pt[i] > cloud_max[i]) cloud_max[i] = pt[i];
}
}

return (cloud_max - cloud_min);
}

Expand Down Expand Up @@ -199,10 +202,10 @@ pcl::CropHull<PointT>::applyFilter3D (PointCloud &output)
crossings[ray] += rayTriangleIntersect
(input_->points[(*indices_)[index]], rays[ray], hull_polygons_[poly], *hull_cloud_);

if (crop_outside_ && (crossings[0]&1) + (crossings[1]&1) + (crossings[2]&1) > 1)
output.push_back (input_->points[(*indices_)[index]]);
else if (!crop_outside_)
bool isPointInsideHull = (crossings[0]&1) + (crossings[1]&1) + (crossings[2]&1) > 1;
if ((crop_outside_ && isPointInsideHull) || (!crop_outside_ && !isPointInsideHull)) {
output.push_back (input_->points[(*indices_)[index]]);
}
}
}

Expand All @@ -226,10 +229,10 @@ pcl::CropHull<PointT>::applyFilter3D (std::vector<int> &indices)
crossings[ray] += rayTriangleIntersect
(input_->points[(*indices_)[index]], rays[ray], hull_polygons_[poly], *hull_cloud_);

if (crop_outside_ && (crossings[0]&1) + (crossings[1]&1) + (crossings[2]&1) > 1)
indices.push_back ((*indices_)[index]);
else if (!crop_outside_)
bool isPointInsideHull = (crossings[0]&1) + (crossings[1]&1) + (crossings[2]&1) > 1;
if ((crop_outside_ && isPointInsideHull) || (!crop_outside_ && !isPointInsideHull)) {
indices.push_back ((*indices_)[index]);
}
}
}

Expand Down

0 comments on commit e1064c7

Please sign in to comment.