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 #ifndef PCL_FILTERS_IMPL_SHADOW_POINTS_FILTER_H_
00039 #define PCL_FILTERS_IMPL_SHADOW_POINTS_FILTER_H_
00040
00041 #include <pcl/filters/shadowpoints.h>
00042
00043 #include <vector>
00044
00046 template<typename PointT, typename NormalT> void
00047 pcl::ShadowPoints<PointT, NormalT>::applyFilter (PointCloud &output)
00048 {
00049 assert (input_normals_ != NULL);
00050 output.points.resize (input_->points.size ());
00051 if (extract_removed_indices_)
00052 removed_indices_->resize (input_->points.size ());
00053
00054 unsigned int cp = 0;
00055 unsigned int ri = 0;
00056 for (unsigned int i = 0; i < input_->points.size (); i++)
00057 {
00058 const NormalT &normal = input_normals_->points[i];
00059 const PointT &pt = input_->points[i];
00060 float val = fabsf (normal.normal_x * pt.x + normal.normal_y * pt.y + normal.normal_z * pt.z);
00061
00062 if ( (val >= threshold_) ^ negative_)
00063 output.points[cp++] = pt;
00064 else
00065 {
00066 if (extract_removed_indices_)
00067 (*removed_indices_)[ri++] = i;
00068 if (keep_organized_)
00069 {
00070 PointT &pt_new = output.points[cp++] = pt;
00071 pt_new.x = pt_new.y = pt_new.z = user_filter_value_;
00072 }
00073
00074 }
00075 }
00076 output.points.resize (cp);
00077 removed_indices_->resize (ri);
00078 output.width = 1;
00079 output.height = static_cast<uint32_t> (output.points.size ());
00080 }
00081
00083 template<typename PointT, typename NormalT> void
00084 pcl::ShadowPoints<PointT, NormalT>::applyFilter (std::vector<int> &indices)
00085 {
00086 assert (input_normals_ != NULL);
00087 indices.resize (input_->points.size ());
00088 if (extract_removed_indices_)
00089 removed_indices_->resize (indices_->size ());
00090
00091 unsigned int k = 0;
00092 unsigned int z = 0;
00093 for (std::vector<int>::const_iterator idx = indices_->begin (); idx != indices_->end (); ++idx)
00094 {
00095 const NormalT &normal = input_normals_->points[*idx];
00096 const PointT &pt = input_->points[*idx];
00097
00098 float val = fabsf (normal.normal_x * pt.x + normal.normal_y * pt.y + normal.normal_z * pt.z);
00099
00100 if ( (val >= threshold_) ^ negative_)
00101 indices[k++] = *idx;
00102 else if (extract_removed_indices_)
00103 (*removed_indices_)[z++] = *idx;
00104 }
00105 indices.resize (k);
00106 removed_indices_->resize (z);
00107 }
00108
00109 #define PCL_INSTANTIATE_ShadowPoints(T,NT) template class PCL_EXPORTS pcl::ShadowPoints<T,NT>;
00110
00111 #endif // PCL_FILTERS_IMPL_NORMAL_SPACE_SAMPLE_H_