filter_indices.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_FILTERS_FILTER_INDICES_H_
00041 #define PCL_FILTERS_FILTER_INDICES_H_
00042
00043 #include <pcl/filters/filter.h>
00044
00045 namespace pcl
00046 {
00054 template<typename PointT> void
00055 removeNaNFromPointCloud (const pcl::PointCloud<PointT> &cloud_in, std::vector<int> &index);
00056
00058
00067 template<typename PointT>
00068 class FilterIndices : public Filter<PointT>
00069 {
00070 public:
00071 typedef pcl::PointCloud<PointT> PointCloud;
00072
00076 FilterIndices (bool extract_removed_indices = false) :
00077 negative_ (false),
00078 keep_organized_ (false),
00079 extract_removed_indices_ (extract_removed_indices),
00080 user_filter_value_ (std::numeric_limits<float>::quiet_NaN ()),
00081 removed_indices_ (new std::vector<int> ())
00082 {
00083 }
00084
00086 virtual
00087 ~FilterIndices ()
00088 {
00089 }
00090
00091 inline void
00092 filter (PointCloud &output)
00093 {
00094 pcl::Filter<PointT>::filter (output);
00095 }
00096
00100 inline void
00101 filter (std::vector<int> &indices)
00102 {
00103 if (!initCompute ())
00104 return;
00105
00106
00107 applyFilter (indices);
00108
00109 deinitCompute ();
00110 }
00111
00115 inline void
00116 setNegative (bool negative)
00117 {
00118 negative_ = negative;
00119 }
00120
00124 inline bool
00125 getNegative ()
00126 {
00127 return (negative_);
00128 }
00129
00134 inline void
00135 setKeepOrganized (bool keep_organized)
00136 {
00137 keep_organized_ = keep_organized;
00138 }
00139
00144 inline bool
00145 getKeepOrganized ()
00146 {
00147 return (keep_organized_);
00148 }
00149
00154 inline void
00155 setUserFilterValue (float value)
00156 {
00157 user_filter_value_ = value;
00158 }
00159
00163 inline IndicesConstPtr const
00164 getRemovedIndices ()
00165 {
00166 return (removed_indices_);
00167 }
00168
00169 protected:
00170 using Filter<PointT>::initCompute;
00171 using Filter<PointT>::deinitCompute;
00172
00174 bool negative_;
00175
00177 bool keep_organized_;
00178
00180 bool extract_removed_indices_;
00181
00183 float user_filter_value_;
00184
00186 IndicesPtr removed_indices_;
00187
00189 virtual void
00190 applyFilter (std::vector<int> &indices) = 0;
00191 };
00192
00194
00203 template<>
00204 class PCL_EXPORTS FilterIndices<sensor_msgs::PointCloud2> : public Filter<sensor_msgs::PointCloud2>
00205 {
00206 public:
00207 typedef sensor_msgs::PointCloud2 PointCloud2;
00208
00212 FilterIndices (bool extract_removed_indices = false) :
00213 negative_ (false),
00214 keep_organized_ (false),
00215 extract_removed_indices_ (extract_removed_indices),
00216 user_filter_value_ (std::numeric_limits<float>::quiet_NaN ()),
00217 removed_indices_ (new std::vector<int>)
00218 {
00219 }
00220
00222 virtual
00223 ~FilterIndices ()
00224 {
00225 }
00226
00227 virtual void
00228 filter (PointCloud2 &output)
00229 {
00230 pcl::Filter<PointCloud2>::filter (output);
00231 }
00232
00236 void
00237 filter (std::vector<int> &indices);
00238
00242 inline void
00243 setNegative (bool negative)
00244 {
00245 negative_ = negative;
00246 }
00247
00251 inline bool
00252 getNegative ()
00253 {
00254 return (negative_);
00255 }
00256
00261 inline void
00262 setKeepOrganized (bool keep_organized)
00263 {
00264 keep_organized_ = keep_organized;
00265 }
00266
00271 inline bool
00272 getKeepOrganized ()
00273 {
00274 return (keep_organized_);
00275 }
00276
00281 inline void
00282 setUserFilterValue (float value)
00283 {
00284 user_filter_value_ = value;
00285 }
00286
00290 inline IndicesConstPtr const
00291 getRemovedIndices ()
00292 {
00293 return (removed_indices_);
00294 }
00295
00296 protected:
00298 bool negative_;
00299
00301 bool keep_organized_;
00302
00304 bool extract_removed_indices_;
00305
00307 float user_filter_value_;
00308
00310 IndicesPtr removed_indices_;
00311
00313 virtual void
00314 applyFilter (std::vector<int> &indices) = 0;
00315 };
00316 }
00317
00318 #endif //#ifndef PCL_FILTERS_FILTER_INDICES_H_
00319