41 #ifndef PCL_FILTERS_IMPL_CROP_BOX_H_
42 #define PCL_FILTERS_IMPL_CROP_BOX_H_
44 #include <pcl/filters/crop_box.h>
45 #include <pcl/common/eigen.h>
46 #include <pcl/common/point_tests.h>
47 #include <pcl/common/transforms.h>
50 template<
typename Po
intT>
void
53 indices.resize (input_->size ());
54 removed_indices_->resize (input_->size ());
55 int indices_count = 0;
56 int removed_indices_count = 0;
58 Eigen::Affine3f transform = Eigen::Affine3f::Identity ();
59 Eigen::Affine3f inverse_transform = Eigen::Affine3f::Identity ();
61 if (rotation_ != Eigen::Vector3f::Zero ())
64 rotation_ (0), rotation_ (1), rotation_ (2),
66 inverse_transform = transform.inverse ();
69 bool transform_matrix_is_identity = transform_.matrix ().isIdentity ();
70 bool translation_is_zero = (translation_ == Eigen::Vector3f::Zero ());
71 bool inverse_transform_matrix_is_identity = inverse_transform.matrix ().isIdentity ();
73 for (
const auto index : *indices_)
75 if (!input_->is_dense)
81 PointT local_pt = (*input_)[index];
84 if (!transform_matrix_is_identity)
85 local_pt = pcl::transformPoint<PointT> (local_pt, transform_);
87 if (!translation_is_zero)
89 local_pt.x -= translation_ (0);
90 local_pt.y -= translation_ (1);
91 local_pt.z -= translation_ (2);
95 if (!inverse_transform_matrix_is_identity)
96 local_pt = pcl::transformPoint<PointT> (local_pt, inverse_transform);
99 if ( (local_pt.x < min_pt_[0] || local_pt.y < min_pt_[1] || local_pt.z < min_pt_[2]) ||
100 (local_pt.x > max_pt_[0] || local_pt.y > max_pt_[1] || local_pt.z > max_pt_[2]))
103 indices[indices_count++] = index;
104 else if (extract_removed_indices_)
105 (*removed_indices_)[removed_indices_count++] = index;
110 if (negative_ && extract_removed_indices_)
111 (*removed_indices_)[removed_indices_count++] = index;
113 indices[indices_count++] = index;
116 indices.resize (indices_count);
117 removed_indices_->resize (removed_indices_count);
120 #define PCL_INSTANTIATE_CropBox(T) template class PCL_EXPORTS pcl::CropBox<T>;
void applyFilter(Indices &indices) override
Sample of point indices.
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 (intrinsic rotations,...
bool isFinite(const PointT &pt)
Tests if the 3D components of a point are all finite param[in] pt point to be tested return true if f...
IndicesAllocator<> Indices
Type used for indices in PCL.
A point structure representing Euclidean xyz coordinates, and the RGB color.