Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 #ifndef PCL_FILTERS_IMPL_CROP_BOX_H_
00041 #define PCL_FILTERS_IMPL_CROP_BOX_H_
00042
00043 #include <pcl/filters/crop_box.h>
00044 #include <pcl/common/io.h>
00045
00047 template<typename PointT> void
00048 pcl::CropBox<PointT>::applyFilter (PointCloud &output)
00049 {
00050 std::vector<int> indices;
00051 if (keep_organized_)
00052 {
00053 bool temp = extract_removed_indices_;
00054 extract_removed_indices_ = true;
00055 applyFilter (indices);
00056 extract_removed_indices_ = temp;
00057
00058 output = *input_;
00059 for (int rii = 0; rii < static_cast<int> (removed_indices_->size ()); ++rii)
00060 output.points[(*removed_indices_)[rii]].x = output.points[(*removed_indices_)[rii]].y = output.points[(*removed_indices_)[rii]].z = user_filter_value_;
00061 if (!pcl_isfinite (user_filter_value_))
00062 output.is_dense = false;
00063 }
00064 else
00065 {
00066 output.is_dense = true;
00067 applyFilter (indices);
00068 pcl::copyPointCloud (*input_, indices, output);
00069 }
00070 }
00071
00073 template<typename PointT> void
00074 pcl::CropBox<PointT>::applyFilter (std::vector<int> &indices)
00075 {
00076 indices.resize (input_->points.size ());
00077 removed_indices_->resize (input_->points.size ());
00078 int indices_count = 0;
00079 int removed_indices_count = 0;
00080
00081 Eigen::Affine3f transform = Eigen::Affine3f::Identity ();
00082 Eigen::Affine3f inverse_transform = Eigen::Affine3f::Identity ();
00083
00084 if (rotation_ != Eigen::Vector3f::Zero ())
00085 {
00086 pcl::getTransformation (0, 0, 0,
00087 rotation_ (0), rotation_ (1), rotation_ (2),
00088 transform);
00089 inverse_transform = transform.inverse ();
00090 }
00091
00092 for (size_t index = 0; index < indices_->size (); ++index)
00093 {
00094 if (!input_->is_dense)
00095
00096 if (!isFinite (input_->points[index]))
00097 continue;
00098
00099
00100 PointT local_pt = input_->points[(*indices_)[index]];
00101
00102
00103 if (!(transform_.matrix ().isIdentity ()))
00104 local_pt = pcl::transformPoint<PointT> (local_pt, transform_);
00105
00106 if (translation_ != Eigen::Vector3f::Zero ())
00107 {
00108 local_pt.x -= translation_ (0);
00109 local_pt.y -= translation_ (1);
00110 local_pt.z -= translation_ (2);
00111 }
00112
00113
00114 if (!(inverse_transform.matrix ().isIdentity ()))
00115 local_pt = pcl::transformPoint<PointT> (local_pt, inverse_transform);
00116
00117
00118 if ( (local_pt.x < min_pt_[0] || local_pt.y < min_pt_[1] || local_pt.z < min_pt_[2]) ||
00119 (local_pt.x > max_pt_[0] || local_pt.y > max_pt_[1] || local_pt.z > max_pt_[2]))
00120 {
00121 if (negative_)
00122 indices[indices_count++] = (*indices_)[index];
00123 else if (extract_removed_indices_)
00124 (*removed_indices_)[removed_indices_count++] = static_cast<int> (index);
00125 }
00126
00127 else
00128 {
00129 if (negative_ && extract_removed_indices_)
00130 (*removed_indices_)[removed_indices_count++] = static_cast<int> (index);
00131 else if (!negative_)
00132 indices[indices_count++] = (*indices_)[index];
00133 }
00134 }
00135 indices.resize (indices_count);
00136 removed_indices_->resize (removed_indices_count);
00137 }
00138
00139 #define PCL_INSTANTIATE_CropBox(T) template class PCL_EXPORTS pcl::CropBox<T>;
00140
00141 #endif // PCL_FILTERS_IMPL_CROP_BOX_H_