filter.h
Go to the documentation of this file.
00001 /*
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Point Cloud Library (PCL) - www.pointclouds.org
00005  *  Copyright (c) 2010-2011, 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$
00037  *
00038  */
00039 
00040 #ifndef PCL_FILTER_H_
00041 #define PCL_FILTER_H_
00042 
00043 #include <pcl/pcl_base.h>
00044 #include <pcl/conversions.h>
00045 #include <pcl/filters/boost.h>
00046 #include <cfloat>
00047 #include <pcl/PointIndices.h>
00048 
00049 namespace pcl
00050 {
00059   template<typename PointT> void
00060   removeNaNFromPointCloud (const pcl::PointCloud<PointT> &cloud_in, 
00061                            pcl::PointCloud<PointT> &cloud_out, 
00062                            std::vector<int> &index);
00063 
00072   template<typename PointT> void
00073   removeNaNNormalsFromPointCloud (const pcl::PointCloud<PointT> &cloud_in, 
00074                                   pcl::PointCloud<PointT> &cloud_out, 
00075                                   std::vector<int> &index);
00076 
00078 
00082   template<typename PointT>
00083   class Filter : public PCLBase<PointT>
00084   {
00085     public:
00086       using PCLBase<PointT>::indices_;
00087       using PCLBase<PointT>::input_;
00088 
00089       typedef boost::shared_ptr< Filter<PointT> > Ptr;
00090       typedef boost::shared_ptr< const Filter<PointT> > ConstPtr;
00091 
00092 
00093       typedef pcl::PointCloud<PointT> PointCloud;
00094       typedef typename PointCloud::Ptr PointCloudPtr;
00095       typedef typename PointCloud::ConstPtr PointCloudConstPtr;
00096 
00101       Filter (bool extract_removed_indices = false) : 
00102         removed_indices_ (new std::vector<int>),
00103         filter_name_ (),
00104         extract_removed_indices_ (extract_removed_indices)
00105       {
00106       }
00107 
00109       virtual ~Filter () {}
00110 
00112       inline IndicesConstPtr const
00113       getRemovedIndices ()
00114       {
00115         return (removed_indices_);
00116       }
00117 
00121       inline void
00122       getRemovedIndices (PointIndices &pi)
00123       {
00124         pi.indices = *removed_indices_;
00125       }
00126 
00130       inline void
00131       filter (PointCloud &output)
00132       {
00133         if (!initCompute ())
00134           return;
00135 
00136         // Resize the output dataset
00137         //if (output.points.size () != indices_->size ())
00138         //  output.points.resize (indices_->size ());
00139 
00140         // Copy header at a minimum
00141         output.header = input_->header;
00142         output.sensor_origin_ = input_->sensor_origin_;
00143         output.sensor_orientation_ = input_->sensor_orientation_;
00144 
00145         // Apply the actual filter
00146         applyFilter (output);
00147 
00148         deinitCompute ();
00149       }
00150 
00151     protected:
00152 
00153       using PCLBase<PointT>::initCompute;
00154       using PCLBase<PointT>::deinitCompute;
00155 
00157       IndicesPtr removed_indices_;
00158 
00160       std::string filter_name_;
00161 
00163       bool extract_removed_indices_;
00164 
00171       virtual void
00172       applyFilter (PointCloud &output) = 0;
00173 
00175       inline const std::string&
00176       getClassName () const
00177       {
00178         return (filter_name_);
00179       }
00180   };
00181 
00183 
00187   template<>
00188   class PCL_EXPORTS Filter<pcl::PCLPointCloud2> : public PCLBase<pcl::PCLPointCloud2>
00189   {
00190     public:
00191       typedef boost::shared_ptr< Filter<pcl::PCLPointCloud2> > Ptr;
00192       typedef boost::shared_ptr< const Filter<pcl::PCLPointCloud2> > ConstPtr;
00193 
00194       typedef pcl::PCLPointCloud2 PCLPointCloud2;
00195       typedef PCLPointCloud2::Ptr PCLPointCloud2Ptr;
00196       typedef PCLPointCloud2::ConstPtr PCLPointCloud2ConstPtr;
00197 
00202       Filter (bool extract_removed_indices = false) : 
00203         removed_indices_ (new std::vector<int>),
00204         extract_removed_indices_ (extract_removed_indices),
00205         filter_name_ ()
00206       {
00207       }
00208       
00210       virtual ~Filter () {}
00211 
00213       inline IndicesConstPtr const
00214       getRemovedIndices ()
00215       {
00216         return (removed_indices_);
00217       }
00218 
00222       inline void
00223       getRemovedIndices (PointIndices &pi)
00224       {
00225         pi.indices = *removed_indices_;
00226       }
00227 
00231       void
00232       filter (PCLPointCloud2 &output);
00233 
00234     protected:
00235 
00237       IndicesPtr removed_indices_;
00238 
00240       bool extract_removed_indices_;
00241 
00243       std::string filter_name_;
00244 
00251       virtual void
00252       applyFilter (PCLPointCloud2 &output) = 0;
00253 
00255       inline const std::string&
00256       getClassName () const
00257       {
00258         return (filter_name_);
00259       }
00260   };
00261 }
00262 
00263 #ifdef PCL_NO_PRECOMPILE
00264 #include <pcl/filters/impl/filter.hpp>
00265 #endif
00266 
00267 #endif  //#ifndef PCL_FILTER_H_


pcl
Author(s): Open Perception
autogenerated on Wed Aug 26 2015 15:24:08