00001 /* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Point Cloud Library (PCL) - www.pointclouds.org 00005 * Copyright (c) 2010-2012, Willow Garage, Inc. 00006 * 00007 * All rights reserved. 00008 * 00009 * Redistribution and use in source and binary forms, with or without 00010 * modification, are permitted provided that the following conditions 00011 * are met: 00012 * 00013 * * Redistributions of source code must retain the above copyright 00014 * notice, this list of conditions and the following disclaimer. 00015 * * Redistributions in binary form must reproduce the above 00016 * copyright notice, this list of conditions and the following 00017 * disclaimer in the documentation and/or other materials provided 00018 * with the distribution. 00019 * * Neither the name of the copyright holder(s) nor the names of its 00020 * contributors may be used to endorse or promote products derived 00021 * from this software without specific prior written permission. 00022 * 00023 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00024 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00025 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00026 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00027 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00028 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00029 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00030 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00031 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00032 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00033 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00034 * POSSIBILITY OF SUCH DAMAGE. 00035 * 00036 * $Id: filter_indices.h 4707 2012-02-23 10:34:17Z florentinus $ 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 { 00047 /** \brief Removes points with x, y, or z equal to NaN (dry run). 00048 * 00049 * This function only computes the mapping between the points in the input 00050 * cloud and the cloud that would result from filtering. It does not 00051 * actually construct and output the filtered cloud. 00052 * 00053 * \note This function does not modify the input point cloud! 00054 * 00055 * \param cloud_in the input point cloud 00056 * \param index the mapping (ordered): filtered_cloud.points[i] = cloud_in.points[index[i]] 00057 * 00058 * \see removeNaNFromPointCloud 00059 * \ingroup filters 00060 */ 00061 template<typename PointT> void 00062 removeNaNFromPointCloud (const pcl::PointCloud<PointT> &cloud_in, std::vector<int> &index); 00063 00064 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00065 /** \brief @b FilterIndices represents the base class for filters that are about binary point removal. 00066 * <br> 00067 * All derived classes have to implement the \a filter (PointCloud &output) and the \a filter (std::vector<int> &indices) methods. 00068 * Ideally they also make use of the \a negative_, \a keep_organized_ and \a extract_removed_indices_ systems. 00069 * The distinguishment between the \a negative_ and \a extract_removed_indices_ systems only makes sense if the class automatically 00070 * filters non-finite entries in the filtering methods (recommended). 00071 * \author Justin Rosen 00072 * \ingroup filters 00073 */ 00074 template<typename PointT> 00075 class FilterIndices : public Filter<PointT> 00076 { 00077 public: 00078 using Filter<PointT>::extract_removed_indices_; 00079 typedef pcl::PointCloud<PointT> PointCloud; 00080 00081 typedef boost::shared_ptr< FilterIndices<PointT> > Ptr; 00082 typedef boost::shared_ptr< const FilterIndices<PointT> > ConstPtr; 00083 00084 00085 /** \brief Constructor. 00086 * \param[in] extract_removed_indices Set to true if you want to be able to extract the indices of points being removed (default = false). 00087 */ 00088 FilterIndices (bool extract_removed_indices = false) : 00089 negative_ (false), 00090 keep_organized_ (false), 00091 user_filter_value_ (std::numeric_limits<float>::quiet_NaN ()) 00092 { 00093 extract_removed_indices_ = extract_removed_indices; 00094 } 00095 00096 /** \brief Empty virtual destructor. */ 00097 virtual 00098 ~FilterIndices () 00099 { 00100 } 00101 00102 inline void 00103 filter (PointCloud &output) 00104 { 00105 pcl::Filter<PointT>::filter (output); 00106 } 00107 00108 /** \brief Calls the filtering method and returns the filtered point cloud indices. 00109 * \param[out] indices the resultant filtered point cloud indices 00110 */ 00111 inline void 00112 filter (std::vector<int> &indices) 00113 { 00114 if (!initCompute ()) 00115 return; 00116 00117 // Apply the actual filter 00118 applyFilter (indices); 00119 00120 deinitCompute (); 00121 } 00122 00123 /** \brief Set whether the regular conditions for points filtering should apply, or the inverted conditions. 00124 * \param[in] negative false = normal filter behavior (default), true = inverted behavior. 00125 */ 00126 inline void 00127 setNegative (bool negative) 00128 { 00129 negative_ = negative; 00130 } 00131 00132 /** \brief Get whether the regular conditions for points filtering should apply, or the inverted conditions. 00133 * \return The value of the internal \a negative_ parameter; false = normal filter behavior (default), true = inverted behavior. 00134 */ 00135 inline bool 00136 getNegative () 00137 { 00138 return (negative_); 00139 } 00140 00141 /** \brief Set whether the filtered points should be kept and set to the value given through \a setUserFilterValue (default: NaN), 00142 * or removed from the PointCloud, thus potentially breaking its organized structure. 00143 * \param[in] keep_organized false = remove points (default), true = redefine points, keep structure. 00144 */ 00145 inline void 00146 setKeepOrganized (bool keep_organized) 00147 { 00148 keep_organized_ = keep_organized; 00149 } 00150 00151 /** \brief Get whether the filtered points should be kept and set to the value given through \a setUserFilterValue (default = NaN), 00152 * or removed from the PointCloud, thus potentially breaking its organized structure. 00153 * \return The value of the internal \a keep_organized_ parameter; false = remove points (default), true = redefine points, keep structure. 00154 */ 00155 inline bool 00156 getKeepOrganized () 00157 { 00158 return (keep_organized_); 00159 } 00160 00161 /** \brief Provide a value that the filtered points should be set to instead of removing them. 00162 * Used in conjunction with \a setKeepOrganized (). 00163 * \param[in] value the user given value that the filtered point dimensions should be set to (default = NaN). 00164 */ 00165 inline void 00166 setUserFilterValue (float value) 00167 { 00168 user_filter_value_ = value; 00169 } 00170 00171 protected: 00172 using Filter<PointT>::initCompute; 00173 using Filter<PointT>::deinitCompute; 00174 00175 /** \brief False = normal filter behavior (default), true = inverted behavior. */ 00176 bool negative_; 00177 00178 /** \brief False = remove points (default), true = redefine points, keep structure. */ 00179 bool keep_organized_; 00180 00181 /** \brief The user given value that the filtered point dimensions should be set to (default = NaN). */ 00182 float user_filter_value_; 00183 00184 /** \brief Abstract filter method for point cloud indices. */ 00185 virtual void 00186 applyFilter (std::vector<int> &indices) = 0; 00187 }; 00188 00189 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00190 /** \brief @b FilterIndices represents the base class for filters that are about binary point removal. 00191 * <br> 00192 * All derived classes have to implement the \a filter (PointCloud &output) and the \a filter (std::vector<int> &indices) methods. 00193 * Ideally they also make use of the \a negative_, \a keep_organized_ and \a extract_removed_indices_ systems. 00194 * The distinguishment between the \a negative_ and \a extract_removed_indices_ systems only makes sense if the class automatically 00195 * filters non-finite entries in the filtering methods (recommended). 00196 * \author Justin Rosen 00197 * \ingroup filters 00198 */ 00199 template<> 00200 class PCL_EXPORTS FilterIndices<pcl::PCLPointCloud2> : public Filter<pcl::PCLPointCloud2> 00201 { 00202 public: 00203 typedef pcl::PCLPointCloud2 PCLPointCloud2; 00204 00205 /** \brief Constructor. 00206 * \param[in] extract_removed_indices Set to true if you want to extract the indices of points being removed (default = false). 00207 */ 00208 FilterIndices (bool extract_removed_indices = false) : 00209 negative_ (false), 00210 keep_organized_ (false), 00211 user_filter_value_ (std::numeric_limits<float>::quiet_NaN ()) 00212 { 00213 extract_removed_indices_ = extract_removed_indices; 00214 } 00215 00216 /** \brief Empty virtual destructor. */ 00217 virtual 00218 ~FilterIndices () 00219 { 00220 } 00221 00222 virtual void 00223 filter (PCLPointCloud2 &output) 00224 { 00225 pcl::Filter<PCLPointCloud2>::filter (output); 00226 } 00227 00228 /** \brief Calls the filtering method and returns the filtered point cloud indices. 00229 * \param[out] indices the resultant filtered point cloud indices 00230 */ 00231 void 00232 filter (std::vector<int> &indices); 00233 00234 /** \brief Set whether the regular conditions for points filtering should apply, or the inverted conditions. 00235 * \param[in] negative false = normal filter behavior (default), true = inverted behavior. 00236 */ 00237 inline void 00238 setNegative (bool negative) 00239 { 00240 negative_ = negative; 00241 } 00242 00243 /** \brief Get whether the regular conditions for points filtering should apply, or the inverted conditions. 00244 * \return The value of the internal \a negative_ parameter; false = normal filter behavior (default), true = inverted behavior. 00245 */ 00246 inline bool 00247 getNegative () 00248 { 00249 return (negative_); 00250 } 00251 00252 /** \brief Set whether the filtered points should be kept and set to the value given through \a setUserFilterValue (default: NaN), 00253 * or removed from the PointCloud, thus potentially breaking its organized structure. 00254 * \param[in] keep_organized false = remove points (default), true = redefine points, keep structure. 00255 */ 00256 inline void 00257 setKeepOrganized (bool keep_organized) 00258 { 00259 keep_organized_ = keep_organized; 00260 } 00261 00262 /** \brief Get whether the filtered points should be kept and set to the value given through \a setUserFilterValue (default = NaN), 00263 * or removed from the PointCloud, thus potentially breaking its organized structure. 00264 * \return The value of the internal \a keep_organized_ parameter; false = remove points (default), true = redefine points, keep structure. 00265 */ 00266 inline bool 00267 getKeepOrganized () 00268 { 00269 return (keep_organized_); 00270 } 00271 00272 /** \brief Provide a value that the filtered points should be set to instead of removing them. 00273 * Used in conjunction with \a setKeepOrganized (). 00274 * \param[in] value the user given value that the filtered point dimensions should be set to (default = NaN). 00275 */ 00276 inline void 00277 setUserFilterValue (float value) 00278 { 00279 user_filter_value_ = value; 00280 } 00281 00282 protected: 00283 /** \brief False = normal filter behavior (default), true = inverted behavior. */ 00284 bool negative_; 00285 00286 /** \brief False = remove points (default), true = redefine points, keep structure. */ 00287 bool keep_organized_; 00288 00289 /** \brief The user given value that the filtered point dimensions should be set to (default = NaN). */ 00290 float user_filter_value_; 00291 00292 /** \brief Abstract filter method for point cloud indices. */ 00293 virtual void 00294 applyFilter (std::vector<int> &indices) = 0; 00295 }; 00296 } 00297 00298 #ifdef PCL_NO_PRECOMPILE 00299 #include <pcl/filters/impl/filter_indices.hpp> 00300 #endif 00301 00302 #endif //#ifndef PCL_FILTERS_FILTER_INDICES_H_ 00303
Except where otherwise noted, the PointClouds.org web pages are licensed under Creative Commons Attribution 3.0.
Pages generated on Wed Mar 25 00:24:00 2015