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_FILTER_H_
00039 #define PCL_FILTER_H_
00040
00041 #include "pcl/pcl_base.h"
00042 #include "pcl/ros/conversions.h"
00043 #include <cfloat>
00044
00045 namespace pcl
00046 {
00054 template <typename PointT> void removeNaNFromPointCloud (const pcl::PointCloud<PointT> &cloud_in, pcl::PointCloud<PointT> &cloud_out, std::vector<int> &index);
00055
00057
00061 template <typename PointT>
00062 class Filter : public PCLBase<PointT>
00063 {
00064 using PCLBase<PointT>::initCompute;
00065 using PCLBase<PointT>::deinitCompute;
00066
00067 public:
00068 using PCLBase<PointT>::indices_;
00069 using PCLBase<PointT>::input_;
00070
00071 typedef pcl::PointCloud<PointT> PointCloud;
00072 typedef typename PointCloud::Ptr PointCloudPtr;
00073 typedef typename PointCloud::ConstPtr PointCloudConstPtr;
00074
00076 Filter () : filter_field_name_ (""),
00077 filter_limit_min_ (-FLT_MAX), filter_limit_max_ (FLT_MAX),
00078 filter_limit_negative_ (false)
00079 {};
00080
00081
00086 inline void setFilterFieldName (const std::string &field_name) { filter_field_name_ = field_name; }
00087
00089 inline std::string const getFilterFieldName () { return (filter_field_name_); }
00090
00095 inline void
00096 setFilterLimits (const double &limit_min, const double &limit_max)
00097 {
00098 filter_limit_min_ = limit_min;
00099 filter_limit_max_ = limit_max;
00100 }
00101
00103 inline void
00104 getFilterLimits (double &limit_min, double &limit_max)
00105 {
00106 limit_min = filter_limit_min_;
00107 limit_max = filter_limit_max_;
00108 }
00109
00114 inline void setFilterLimitsNegative (const bool limit_negative) { filter_limit_negative_ = limit_negative; }
00115
00117 inline void getFilterLimitsNegative (bool &limit_negative) { limit_negative = filter_limit_negative_; }
00118 inline bool getFilterLimitsNegative () { return (filter_limit_negative_); }
00119
00123 inline void
00124 filter (PointCloud &output)
00125 {
00126 if (!initCompute ()) return;
00127
00128
00129
00130
00131
00132
00133 output.header = input_->header;
00134 output.sensor_origin_ = input_->sensor_origin_;
00135 output.sensor_orientation_ = input_->sensor_orientation_;
00136
00137
00138 applyFilter (output);
00139
00140 deinitCompute ();
00141 }
00142
00143 protected:
00145 std::string filter_name_;
00146
00148 std::string filter_field_name_;
00149
00151 double filter_limit_min_;
00152
00154 double filter_limit_max_;
00155
00157 bool filter_limit_negative_;
00158
00163 virtual void applyFilter (PointCloud &output) = 0;
00164
00166 inline const std::string& getClassName () const { return (filter_name_); }
00167 };
00168
00170
00174 template <>
00175 class Filter<sensor_msgs::PointCloud2> : public PCLBase<sensor_msgs::PointCloud2>
00176 {
00177 public:
00178 typedef sensor_msgs::PointCloud2 PointCloud2;
00179 typedef PointCloud2::Ptr PointCloud2Ptr;
00180 typedef PointCloud2::ConstPtr PointCloud2ConstPtr;
00181
00183 Filter () : filter_field_name_ (""),
00184 filter_limit_min_ (-FLT_MAX), filter_limit_max_ (FLT_MAX),
00185 filter_limit_negative_ (false)
00186 {};
00187
00192 inline void setFilterFieldName (const std::string &field_name) { filter_field_name_ = field_name; }
00193
00195 inline std::string const getFilterFieldName () { return (filter_field_name_); }
00196
00201 inline void
00202 setFilterLimits (const double &limit_min, const double &limit_max)
00203 {
00204 filter_limit_min_ = limit_min;
00205 filter_limit_max_ = limit_max;
00206 }
00207
00209 inline void
00210 getFilterLimits (double &limit_min, double &limit_max)
00211 {
00212 limit_min = filter_limit_min_;
00213 limit_max = filter_limit_max_;
00214 }
00215
00220 inline void setFilterLimitsNegative (const bool limit_negative) { filter_limit_negative_ = limit_negative; }
00221
00223 inline void getFilterLimitsNegative (bool &limit_negative) { limit_negative = filter_limit_negative_; }
00224 inline bool getFilterLimitsNegative () { return (filter_limit_negative_); }
00225
00229 void filter (PointCloud2 &output);
00230
00231 protected:
00233 std::string filter_name_;
00234
00236 std::string filter_field_name_;
00237
00239 double filter_limit_min_;
00240
00242 double filter_limit_max_;
00243
00245 bool filter_limit_negative_;
00246
00251 virtual void applyFilter (PointCloud2 &output) = 0;
00252
00254 inline const std::string& getClassName () const { return (filter_name_); }
00255 };
00256 }
00257
00258 #endif //#ifndef PCL_FILTER_H_