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 std::vector<int> indices;
54 bool temp = extract_removed_indices_;
55 extract_removed_indices_ =
true;
56 applyFilter (indices);
57 extract_removed_indices_ = temp;
60 for (
int rii = 0; rii < static_cast<int> (removed_indices_->size ()); ++rii)
61 output.
points[(*removed_indices_)[rii]].x = output.
points[(*removed_indices_)[rii]].y = output.
points[(*removed_indices_)[rii]].z = user_filter_value_;
62 if (!pcl_isfinite (user_filter_value_))
68 applyFilter (indices);
74 template<
typename Po
intT>
void 77 indices.resize (input_->points.size ());
78 removed_indices_->resize (input_->points.size ());
79 int indices_count = 0;
80 int removed_indices_count = 0;
82 Eigen::Affine3f transform = Eigen::Affine3f::Identity ();
83 Eigen::Affine3f inverse_transform = Eigen::Affine3f::Identity ();
85 if (rotation_ != Eigen::Vector3f::Zero ())
88 rotation_ (0), rotation_ (1), rotation_ (2),
90 inverse_transform = transform.inverse ();
93 bool transform_matrix_is_identity = transform_.matrix ().isIdentity ();
94 bool translation_is_zero = (translation_ == Eigen::Vector3f::Zero ());
95 bool inverse_transform_matrix_is_identity = inverse_transform.matrix ().isIdentity ();
97 for (
size_t index = 0; index < indices_->size (); ++index)
99 if (!input_->is_dense)
101 if (!
isFinite (input_->points[index]))
105 PointT local_pt = input_->points[(*indices_)[index]];
108 if (!transform_matrix_is_identity)
109 local_pt = pcl::transformPoint<PointT> (local_pt, transform_);
111 if (!translation_is_zero)
113 local_pt.x -= translation_ (0);
114 local_pt.y -= translation_ (1);
115 local_pt.z -= translation_ (2);
119 if (!inverse_transform_matrix_is_identity)
120 local_pt = pcl::transformPoint<PointT> (local_pt, inverse_transform);
123 if ( (local_pt.x < min_pt_[0] || local_pt.y < min_pt_[1] || local_pt.z < min_pt_[2]) ||
124 (local_pt.x > max_pt_[0] || local_pt.y > max_pt_[1] || local_pt.z > max_pt_[2]))
127 indices[indices_count++] = (*indices_)[index];
128 else if (extract_removed_indices_)
129 (*removed_indices_)[removed_indices_count++] =
static_cast<int> (index);
134 if (negative_ && extract_removed_indices_)
135 (*removed_indices_)[removed_indices_count++] =
static_cast<int> (index);
137 indices[indices_count++] = (*indices_)[index];
140 indices.resize (indices_count);
141 removed_indices_->resize (removed_indices_count);
144 #define PCL_INSTANTIATE_CropBox(T) template class PCL_EXPORTS pcl::CropBox<T>; 146 #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 return true if f...
std::vector< PointT, Eigen::aligned_allocator< PointT > > points
The point data.
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.
PointCloud represents the base class in PCL for storing collections of 3D points. ...
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 is_dense
True if no points are invalid (e.g., have NaN or Inf values).
A point structure representing Euclidean xyz coordinates, and the RGB color.
void applyFilter(PointCloud &output)
Sample of point indices into a separate PointCloud.