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
00045
00047 template<typename PointT>
00048 void
00049 pcl::CropBox<PointT>::applyFilter (PointCloud &output)
00050 {
00051 output.resize (input_->points.size ());
00052 int indice_count = 0;
00053
00054
00055 output.is_dense = true;
00056
00057 Eigen::Affine3f transform = Eigen::Affine3f::Identity();
00058 Eigen::Affine3f inverse_transform = Eigen::Affine3f::Identity();
00059
00060 if (rotation_ != Eigen::Vector3f::Zero ())
00061 {
00062 pcl::getTransformation (0, 0, 0,
00063 rotation_ (0), rotation_ (1), rotation_ (2),
00064 transform);
00065 inverse_transform = transform.inverse ();
00066 }
00067
00068 for (size_t index = 0; index < indices_->size (); ++index)
00069 {
00070 if (!input_->is_dense)
00071
00072 if (!isFinite (input_->points[index]))
00073 continue;
00074
00075
00076 PointT local_pt = input_->points[(*indices_)[index]];
00077
00078
00079 if (!(transform_.matrix ().isIdentity ()))
00080 local_pt = pcl::transformPoint<PointT> (local_pt, transform_);
00081
00082 if (translation_ != Eigen::Vector3f::Zero ())
00083 {
00084 local_pt.x -= translation_ (0);
00085 local_pt.y -= translation_ (1);
00086 local_pt.z -= translation_ (2);
00087 }
00088
00089
00090 if (!(inverse_transform.matrix ().isIdentity ()))
00091 local_pt = pcl::transformPoint<PointT> (local_pt, inverse_transform);
00092
00093 if (local_pt.x < min_pt_[0] || local_pt.y < min_pt_[1] || local_pt.z < min_pt_[2])
00094 continue;
00095 if (local_pt.x > max_pt_[0] || local_pt.y > max_pt_[1] || local_pt.z > max_pt_[2])
00096 continue;
00097
00098 output.points[indice_count++] = input_->points[(*indices_)[index]];
00099 }
00100 output.width = indice_count;
00101 output.height = 1;
00102 output.resize (output.width * output.height);
00103 }
00104
00106 template<typename PointT> void
00107 pcl::CropBox<PointT>::applyFilter (std::vector<int> &indices)
00108 {
00109 indices.resize (input_->points.size ());
00110 int indice_count = 0;
00111
00112 Eigen::Affine3f transform = Eigen::Affine3f::Identity ();
00113 Eigen::Affine3f inverse_transform = Eigen::Affine3f::Identity ();
00114
00115 if (rotation_ != Eigen::Vector3f::Zero ())
00116 {
00117 pcl::getTransformation (0, 0, 0,
00118 rotation_ (0), rotation_ (1), rotation_ (2),
00119 transform);
00120 inverse_transform = transform.inverse ();
00121 }
00122
00123 for (size_t index = 0; index < indices_->size (); ++index)
00124 {
00125 if (!input_->is_dense)
00126
00127 if (!isFinite (input_->points[index]))
00128 continue;
00129
00130
00131 PointT local_pt = input_->points[(*indices_)[index]];
00132
00133
00134 if (!(transform_.matrix ().isIdentity ()))
00135 local_pt = pcl::transformPoint<PointT> (local_pt, transform_);
00136
00137 if (translation_ != Eigen::Vector3f::Zero ())
00138 {
00139 local_pt.x -= translation_ (0);
00140 local_pt.y -= translation_ (1);
00141 local_pt.z -= translation_ (2);
00142 }
00143
00144
00145 if (!(inverse_transform.matrix ().isIdentity ()))
00146 local_pt = pcl::transformPoint<PointT> (local_pt, inverse_transform);
00147
00148 if (local_pt.x < min_pt_[0] || local_pt.y < min_pt_[1] || local_pt.z < min_pt_[2])
00149 continue;
00150 if (local_pt.x > max_pt_[0] || local_pt.y > max_pt_[1] || local_pt.z > max_pt_[2])
00151 continue;
00152
00153 indices[indice_count++] = (*indices_)[index];
00154 }
00155 indices.resize (indice_count);
00156 }
00157
00158 #define PCL_INSTANTIATE_CropBox(T) template class PCL_EXPORTS pcl::CropBox<T>;
00159
00160 #endif // PCL_FILTERS_IMPL_CROP_BOX_H_