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/io.h>
48 template<
typename Po
intT>
void
51 indices.resize (input_->points.size ());
52 removed_indices_->resize (input_->points.size ());
53 int indices_count = 0;
54 int removed_indices_count = 0;
56 Eigen::Affine3f transform = Eigen::Affine3f::Identity ();
57 Eigen::Affine3f inverse_transform = Eigen::Affine3f::Identity ();
59 if (rotation_ != Eigen::Vector3f::Zero ())
62 rotation_ (0), rotation_ (1), rotation_ (2),
64 inverse_transform = transform.inverse ();
67 bool transform_matrix_is_identity = transform_.matrix ().isIdentity ();
68 bool translation_is_zero = (translation_ == Eigen::Vector3f::Zero ());
69 bool inverse_transform_matrix_is_identity = inverse_transform.matrix ().isIdentity ();
71 for (
const auto index : *indices_)
73 if (!input_->is_dense)
75 if (!
isFinite (input_->points[index]))
79 PointT local_pt = input_->points[index];
82 if (!transform_matrix_is_identity)
83 local_pt = pcl::transformPoint<PointT> (local_pt, transform_);
85 if (!translation_is_zero)
87 local_pt.x -= translation_ (0);
88 local_pt.y -= translation_ (1);
89 local_pt.z -= translation_ (2);
93 if (!inverse_transform_matrix_is_identity)
94 local_pt = pcl::transformPoint<PointT> (local_pt, inverse_transform);
97 if ( (local_pt.x < min_pt_[0] || local_pt.y < min_pt_[1] || local_pt.z < min_pt_[2]) ||
98 (local_pt.x > max_pt_[0] || local_pt.y > max_pt_[1] || local_pt.z > max_pt_[2]))
101 indices[indices_count++] = index;
102 else if (extract_removed_indices_)
103 (*removed_indices_)[removed_indices_count++] =
static_cast<int> (index);
108 if (negative_ && extract_removed_indices_)
109 (*removed_indices_)[removed_indices_count++] =
static_cast<int> (index);
111 indices[indices_count++] = index;
114 indices.resize (indices_count);
115 removed_indices_->resize (removed_indices_count);
118 #define PCL_INSTANTIATE_CropBox(T) template class PCL_EXPORTS pcl::CropBox<T>;
void applyFilter(std::vector< int > &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 (XYZ-convention)
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...
A point structure representing Euclidean xyz coordinates, and the RGB color.