Point Cloud Library (PCL)  1.7.1
clipper3D.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2010-2011, Willow Garage, Inc.
6  *
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * * Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  * * Redistributions in binary form must reproduce the above
16  * copyright notice, this list of conditions and the following
17  * disclaimer in the documentation and/or other materials provided
18  * with the distribution.
19  * * Neither the name of the copyright holder(s) nor the names of its
20  * contributors may be used to endorse or promote products derived
21  * from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  * POSSIBILITY OF SUCH DAMAGE.
35  *
36  */
37 
38 #ifndef PCL_CLIPPER3D_H_
39 #define PCL_CLIPPER3D_H_
40 #include <pcl/point_cloud.h>
41 #include <vector>
42 
43 namespace pcl
44 {
45  /**
46  * \brief Base class for 3D clipper objects
47  * \author Suat Gedikli <gedikli@willowgarage.com>
48  * \ingroup filters
49  */
50  template<typename PointT>
51  class Clipper3D
52  {
53  public:
54  typedef boost::shared_ptr< Clipper3D<PointT> > Ptr;
55  typedef boost::shared_ptr< const Clipper3D<PointT> > ConstPtr;
56 
57  /**
58  * \brief virtual destructor. Never throws an exception.
59  */
60  virtual ~Clipper3D () throw () {}
61 
62  /**
63  * \brief interface to clip a single point
64  * \param[in] point the point to check against
65  * \return true, it point still exists, false if its clipped
66  */
67  virtual bool
68  clipPoint3D (const PointT& point) const = 0;
69 
70  /**
71  * \brief interface to clip a line segment given by two end points. The order of the end points is unimportant and will sty the same after clipping.
72  * This means basically, that the direction of the line will not flip after clipping.
73  * \param[in,out] pt1 start point of the line
74  * \param[in,out] pt2 end point of the line
75  * \return true if the clipped line is not empty, thus the parameters are still valid, false if line completely outside clipping space
76  */
77  virtual bool
78  clipLineSegment3D (PointT& pt1, PointT& pt2) const = 0;
79 
80  /**
81  * \brief interface to clip a planar polygon given by an ordered list of points
82  * \param[in,out] polygon the polygon in any direction (ccw or cw) but ordered, thus two neighboring points define an edge of the polygon
83  */
84  virtual void
85  clipPlanarPolygon3D (std::vector<PointT>& polygon) const = 0;
86 
87  /**
88  * \brief interface to clip a planar polygon given by an ordered list of points
89  * \param[in] polygon the polygon in any direction (ccw or cw) but ordered, thus two neighboring points define an edge of the polygon
90  * \param[out] clipped_polygon the clipped polygon
91  */
92  virtual void
93  clipPlanarPolygon3D (const std::vector<PointT>& polygon, std::vector<PointT>& clipped_polygon) const = 0;
94 
95  /**
96  * \brief interface to clip a point cloud
97  * \param[in] cloud_in input point cloud
98  * \param[out] clipped indices of points that remain after clipping the input cloud
99  * \param[in] indices the indices of points in the point cloud to be clipped.
100  * \return list of indices of remaining points after clipping.
101  */
102  virtual void
103  clipPointCloud3D (const pcl::PointCloud<PointT> &cloud_in, std::vector<int>& clipped, const std::vector<int>& indices = std::vector<int> ()) const = 0;
104 
105  /**
106  * \brief polymorphic method to clone the underlying clipper with its parameters.
107  * \return the new clipper object from the specific subclass with all its parameters.
108  */
109  virtual Clipper3D<PointT>*
110  clone () const = 0;
111  };
112 }
113 
114 #ifdef PCL_NO_PRECOMPILE
115 #include <pcl/filters/impl/clipper3D.hpp>
116 #endif
117 
118 #endif // PCL_CLIPPER3D_H_