filter.h
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_FILTER_H_
00041 #define PCL_FILTER_H_
00042
00043 #include <pcl/pcl_base.h>
00044 #include <pcl/ros/conversions.h>
00045 #include <boost/make_shared.hpp>
00046 #include <cfloat>
00047
00048 namespace pcl
00049 {
00058 template<typename PointT> void
00059 removeNaNFromPointCloud (const pcl::PointCloud<PointT> &cloud_in,
00060 pcl::PointCloud<PointT> &cloud_out,
00061 std::vector<int> &index);
00062
00064
00068 template<typename PointT>
00069 class Filter : public PCLBase<PointT>
00070 {
00071 public:
00072 using PCLBase<PointT>::indices_;
00073 using PCLBase<PointT>::input_;
00074
00075 typedef boost::shared_ptr< Filter<PointT> > Ptr;
00076 typedef boost::shared_ptr< const Filter<PointT> > ConstPtr;
00077
00078 typedef pcl::PointCloud<PointT> PointCloud;
00079 typedef typename PointCloud::Ptr PointCloudPtr;
00080 typedef typename PointCloud::ConstPtr PointCloudConstPtr;
00081
00086 Filter (bool extract_removed_indices = false) :
00087 removed_indices_ (new std::vector<int>),
00088 filter_name_ (),
00089 extract_removed_indices_ (extract_removed_indices)
00090 {
00091 }
00092
00094 inline IndicesConstPtr const
00095 getRemovedIndices ()
00096 {
00097 return (removed_indices_);
00098 }
00099
00103 inline void
00104 filter (PointCloud &output)
00105 {
00106 if (!initCompute ())
00107 return;
00108
00109
00110
00111
00112
00113
00114 output.header = input_->header;
00115 output.sensor_origin_ = input_->sensor_origin_;
00116 output.sensor_orientation_ = input_->sensor_orientation_;
00117
00118
00119 applyFilter (output);
00120
00121 deinitCompute ();
00122 }
00123
00124 protected:
00125
00126 using PCLBase<PointT>::initCompute;
00127 using PCLBase<PointT>::deinitCompute;
00128
00130 IndicesPtr removed_indices_;
00131
00133 std::string filter_name_;
00134
00136 bool extract_removed_indices_;
00137
00144 virtual void
00145 applyFilter (PointCloud &output) = 0;
00146
00148 inline const std::string&
00149 getClassName () const
00150 {
00151 return (filter_name_);
00152 }
00153 };
00154
00156
00160 template<>
00161 class PCL_EXPORTS Filter<sensor_msgs::PointCloud2> : public PCLBase<sensor_msgs::PointCloud2>
00162 {
00163 public:
00164 typedef sensor_msgs::PointCloud2 PointCloud2;
00165 typedef PointCloud2::Ptr PointCloud2Ptr;
00166 typedef PointCloud2::ConstPtr PointCloud2ConstPtr;
00167
00172 Filter (bool extract_removed_indices = false) :
00173 removed_indices_ (new std::vector<int>),
00174 extract_removed_indices_ (extract_removed_indices),
00175 filter_name_ ()
00176 {
00177 }
00178
00180 inline IndicesConstPtr const
00181 getRemovedIndices ()
00182 {
00183 return (removed_indices_);
00184 }
00185
00189 void
00190 filter (PointCloud2 &output);
00191
00192 protected:
00193
00195 IndicesPtr removed_indices_;
00196
00198 bool extract_removed_indices_;
00199
00201 std::string filter_name_;
00202
00209 virtual void
00210 applyFilter (PointCloud2 &output) = 0;
00211
00213 inline const std::string&
00214 getClassName () const
00215 {
00216 return (filter_name_);
00217 }
00218 };
00219 }
00220
00221 #endif //#ifndef PCL_FILTER_H_