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 (
const auto ri : *removed_indices_)
62 if (!std::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 (
const auto index : *indices_)
99 if (!input_->is_dense)
101 if (!
isFinite (input_->points[index]))
105 PointT local_pt = input_->points[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++] = 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++] = 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_