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