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