crop_hull.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) 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 Willow Garage, Inc. 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   */
00037 
00038 #ifndef PCL_FILTERS_CROP_HULL_H_
00039 #define PCL_FILTERS_CROP_HULL_H_
00040 
00041 #include <pcl/point_types.h>
00042 #include <pcl/Vertices.h>
00043 #include <pcl/filters/filter_indices.h>
00044 
00045 namespace pcl
00046 {
00052   template<typename PointT>
00053   class CropHull: public FilterIndices<PointT>
00054   {
00055     using Filter<PointT>::filter_name_;
00056     using Filter<PointT>::indices_;
00057     using Filter<PointT>::input_;
00058     
00059     typedef typename Filter<PointT>::PointCloud PointCloud;
00060     typedef typename PointCloud::Ptr PointCloudPtr;
00061     typedef typename PointCloud::ConstPtr PointCloudConstPtr;
00062 
00063     public:
00065       CropHull () :
00066         hull_polygons_(),
00067         hull_cloud_(),
00068         dim_(3),
00069         crop_outside_(true)
00070       {
00071         filter_name_ = "CropHull";
00072       }
00073 
00078       inline void
00079       setHullIndices (const std::vector<Vertices>& polygons)
00080       {
00081         hull_polygons_ = polygons;
00082       }
00083 
00086       std::vector<Vertices>
00087       getHullIndices () const
00088       {
00089         return (hull_polygons_);
00090       }
00091       
00095       inline void
00096       setHullCloud (PointCloudPtr points)
00097       {
00098         hull_cloud_ = points;
00099       }
00100 
00102       PointCloudPtr
00103       getHullCloud () const
00104       {
00105         return (hull_cloud_);
00106       }
00107     
00114       inline void
00115       setDim (int dim)
00116       {
00117         dim_ = dim;
00118       }
00119       
00124       inline void
00125       setCropOutside(bool crop_outside)
00126       {
00127         crop_outside_ = crop_outside;
00128       }
00129 
00130     protected:
00134       void
00135       applyFilter (PointCloud &output);
00136 
00140       void        
00141       applyFilter (std::vector<int> &indices);
00142 
00143     private:  
00148       Eigen::Vector3f
00149       getHullCloudRange ();
00150       
00157       template<unsigned PlaneDim1, unsigned PlaneDim2> void
00158       applyFilter2D (PointCloud &output); 
00159 
00167       template<unsigned PlaneDim1, unsigned PlaneDim2> void
00168       applyFilter2D (std::vector<int> &indices);
00169 
00178       void
00179       applyFilter3D (PointCloud &output);
00180 
00189       void
00190       applyFilter3D (std::vector<int> &indices);
00191 
00198       template<unsigned PlaneDim1, unsigned PlaneDim2> inline static bool
00199       isPointIn2DPolyWithVertIndices (const PointT& point,
00200                                       const Vertices& verts,
00201                                       const PointCloud& cloud);
00202 
00211       inline static bool
00212       rayTriangleIntersect (const PointT& point,
00213                             const Eigen::Vector3f& ray,
00214                             const Vertices& verts,
00215                             const PointCloud& cloud);
00216 
00217 
00219       std::vector<pcl::Vertices> hull_polygons_;
00220 
00222       PointCloudPtr hull_cloud_;
00223 
00225       int dim_;
00226 
00230       bool crop_outside_;
00231   };
00232 
00233 } // namespace pcl
00234 
00235 #endif // ndef PCL_FILTERS_CROP_HULL_H_


pcl
Author(s): Open Perception
autogenerated on Mon Oct 6 2014 03:14:48