Point Cloud Library (PCL)  1.9.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 #include <Eigen/StdVector>
43 
44 namespace pcl
45 {
46  /**
47  * \brief Base class for 3D clipper objects
48  * \author Suat Gedikli <gedikli@willowgarage.com>
49  * \ingroup filters
50  */
51  template<typename PointT>
52  class Clipper3D
53  {
54  public:
55  typedef boost::shared_ptr< Clipper3D<PointT> > Ptr;
56  typedef boost::shared_ptr< const Clipper3D<PointT> > ConstPtr;
57 
58  /**
59  * \brief virtual destructor. Never throws an exception.
60  */
61  virtual ~Clipper3D () throw () {}
62 
63  /**
64  * \brief interface to clip a single point
65  * \param[in] point the point to check against
66  * \return true, it point still exists, false if its clipped
67  */
68  virtual bool
69  clipPoint3D (const PointT& point) const = 0;
70 
71  /**
72  * \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.
73  * This means basically, that the direction of the line will not flip after clipping.
74  * \param[in,out] pt1 start point of the line
75  * \param[in,out] pt2 end point of the line
76  * \return true if the clipped line is not empty, thus the parameters are still valid, false if line completely outside clipping space
77  */
78  virtual bool
79  clipLineSegment3D (PointT& pt1, PointT& pt2) const = 0;
80 
81  /**
82  * \brief interface to clip a planar polygon given by an ordered list of points
83  * \param[in,out] polygon the polygon in any direction (ccw or cw) but ordered, thus two neighboring points define an edge of the polygon
84  */
85  virtual void
86  clipPlanarPolygon3D (std::vector<PointT, Eigen::aligned_allocator<PointT> >& polygon) const = 0;
87 
88  /**
89  * \brief interface to clip a planar polygon given by an ordered list of points
90  * \param[in] polygon the polygon in any direction (ccw or cw) but ordered, thus two neighboring points define an edge of the polygon
91  * \param[out] clipped_polygon the clipped polygon
92  */
93  virtual void
94  clipPlanarPolygon3D (const std::vector<PointT, Eigen::aligned_allocator<PointT> >& polygon, std::vector<PointT, Eigen::aligned_allocator<PointT> >& clipped_polygon) const = 0;
95 
96  /**
97  * \brief interface to clip a point cloud
98  * \param[in] cloud_in input point cloud
99  * \param[out] clipped indices of points that remain after clipping the input cloud
100  * \param[in] indices the indices of points in the point cloud to be clipped.
101  * \return list of indices of remaining points after clipping.
102  */
103  virtual void
104  clipPointCloud3D (const pcl::PointCloud<PointT> &cloud_in, std::vector<int>& clipped, const std::vector<int>& indices = std::vector<int> ()) const = 0;
105 
106  /**
107  * \brief polymorphic method to clone the underlying clipper with its parameters.
108  * \return the new clipper object from the specific subclass with all its parameters.
109  */
110  virtual Clipper3D<PointT>*
111  clone () const = 0;
112  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
113  };
114 }
115 
116 #endif // PCL_CLIPPER3D_H_
This file defines compatibility wrappers for low level I/O functions.
Definition: convolution.h:45
virtual Clipper3D< PointT > * clone() const =0
polymorphic method to clone the underlying clipper with its parameters.
boost::shared_ptr< Clipper3D< PointT > > Ptr
Definition: clipper3D.h:55
PointCloud represents the base class in PCL for storing collections of 3D points. ...
virtual bool clipPoint3D(const PointT &point) const =0
interface to clip a single point
boost::shared_ptr< const Clipper3D< PointT > > ConstPtr
Definition: clipper3D.h:56
virtual void clipPointCloud3D(const pcl::PointCloud< PointT > &cloud_in, std::vector< int > &clipped, const std::vector< int > &indices=std::vector< int >()) const =0
interface to clip a point cloud
A point structure representing Euclidean xyz coordinates, and the RGB color.
virtual bool clipLineSegment3D(PointT &pt1, PointT &pt2) const =0
interface to clip a line segment given by two end points.
Base class for 3D clipper objects.
Definition: clipper3D.h:52
virtual void clipPlanarPolygon3D(std::vector< PointT, Eigen::aligned_allocator< PointT > > &polygon) const =0
interface to clip a planar polygon given by an ordered list of points
virtual ~Clipper3D()
virtual destructor.
Definition: clipper3D.h:61