40 #ifndef PCL_FILTERS_IMPL_CROP_BOX_H_
41 #define PCL_FILTERS_IMPL_CROP_BOX_H_
43 #include <pcl/filters/crop_box.h>
44 #include <pcl/common/io.h>
47 template<
typename Po
intT>
void
50 std::vector<int> indices;
53 bool temp = extract_removed_indices_;
54 extract_removed_indices_ =
true;
55 applyFilter (indices);
56 extract_removed_indices_ = temp;
59 for (
int rii = 0; rii < static_cast<int> (removed_indices_->size ()); ++rii)
60 output.
points[(*removed_indices_)[rii]].x = output.
points[(*removed_indices_)[rii]].y = output.
points[(*removed_indices_)[rii]].z = user_filter_value_;
61 if (!pcl_isfinite (user_filter_value_))
67 applyFilter (indices);
73 template<
typename Po
intT>
void
76 indices.resize (input_->points.size ());
77 removed_indices_->resize (input_->points.size ());
78 int indices_count = 0;
79 int removed_indices_count = 0;
81 Eigen::Affine3f transform = Eigen::Affine3f::Identity ();
82 Eigen::Affine3f inverse_transform = Eigen::Affine3f::Identity ();
84 if (rotation_ != Eigen::Vector3f::Zero ())
87 rotation_ (0), rotation_ (1), rotation_ (2),
89 inverse_transform = transform.inverse ();
92 for (
size_t index = 0; index < indices_->size (); ++index)
94 if (!input_->is_dense)
96 if (!
isFinite (input_->points[index]))
100 PointT local_pt = input_->points[(*indices_)[index]];
103 if (!(transform_.matrix ().isIdentity ()))
104 local_pt = pcl::transformPoint<PointT> (local_pt, transform_);
106 if (translation_ != Eigen::Vector3f::Zero ())
108 local_pt.x -= translation_ (0);
109 local_pt.y -= translation_ (1);
110 local_pt.z -= translation_ (2);
114 if (!(inverse_transform.matrix ().isIdentity ()))
115 local_pt = pcl::transformPoint<PointT> (local_pt, inverse_transform);
118 if ( (local_pt.x < min_pt_[0] || local_pt.y < min_pt_[1] || local_pt.z < min_pt_[2]) ||
119 (local_pt.x > max_pt_[0] || local_pt.y > max_pt_[1] || local_pt.z > max_pt_[2]))
122 indices[indices_count++] = (*indices_)[index];
123 else if (extract_removed_indices_)
124 (*removed_indices_)[removed_indices_count++] =
static_cast<int> (index);
129 if (negative_ && extract_removed_indices_)
130 (*removed_indices_)[removed_indices_count++] =
static_cast<int> (index);
132 indices[indices_count++] = (*indices_)[index];
135 indices.resize (indices_count);
136 removed_indices_->resize (removed_indices_count);
139 #define PCL_INSTANTIATE_CropBox(T) template class PCL_EXPORTS pcl::CropBox<T>;
141 #endif // PCL_FILTERS_IMPL_CROP_BOX_H_
bool isFinite(const PointT &pt)
Tests if the 3D components of a point are all finite param[in] pt point to be tested.
PCL_EXPORTS void copyPointCloud(const pcl::PCLPointCloud2 &cloud_in, const std::vector< int > &indices, pcl::PCLPointCloud2 &cloud_out)
Extract the indices of a given point cloud as a new point cloud.
void getTransformation(Scalar x, Scalar y, Scalar z, Scalar roll, Scalar pitch, Scalar yaw, Eigen::Transform< Scalar, 3, Eigen::Affine > &t)
Create a transformation from the given translation and Euler angles (XYZ-convention) ...
std::vector< PointT, Eigen::aligned_allocator< PointT > > points
The point data.
bool is_dense
True if no points are invalid (e.g., have NaN or Inf values).
void applyFilter(PointCloud &output)
Sample of point indices into a separate PointCloud.
A point structure representing Euclidean xyz coordinates, and the RGB color.