Point Cloud Library (PCL)  1.12.0-dev
planar_polygon.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2010-2012, 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 Willow Garage, Inc. 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  * $Id: planar_polygon.h 4696 2012-02-23 06:12:55Z rusu $
37  *
38  */
39 
40 #pragma once
41 
42 #include <pcl/ModelCoefficients.h>
43 #include <pcl/memory.h>
44 #include <pcl/pcl_macros.h>
45 #include <pcl/point_cloud.h>
46 
47 namespace pcl {
48 /** \brief PlanarPolygon represents a planar (2D) polygon, potentially in a 3D space.
49  * \author Alex Trevor
50  */
51 template <typename PointT>
53 public:
54  using Ptr = shared_ptr<PlanarPolygon<PointT>>;
55  using ConstPtr = shared_ptr<const PlanarPolygon<PointT>>;
56 
57  /** \brief Empty constructor for PlanarPolygon */
59 
60  /** \brief Constructor for PlanarPolygon
61  * \param[in] contour a vector of points bounding the polygon
62  * \param[in] coefficients a vector of the plane's coefficients (a,b,c,d)
63  */
65  Eigen::Vector4f& coefficients)
66  : contour_(contour), coefficients_(coefficients)
67  {}
68 
69  /** \brief Destructor. */
70  virtual ~PlanarPolygon() {}
71 
72  /** \brief Set the internal contour
73  * \param[in] contour the new planar polygonal contour
74  */
75  void
77  {
78  contour_ = contour.points;
79  }
80 
81  /** \brief Getter for the contour / boundary */
84  {
85  return (contour_);
86  }
87 
88  /** \brief Getter for the contour / boundary */
90  getContour() const
91  {
92  return (contour_);
93  }
94 
95  /** \brief Setr the internal coefficients
96  * \param[in] coefficients the new coefficients to be set
97  */
98  void
99  setCoefficients(const Eigen::Vector4f& coefficients)
100  {
101  coefficients_ = coefficients;
102  }
103 
104  /** \brief Set the internal coefficients
105  * \param[in] coefficients the new coefficients to be set
106  */
107  void
109  {
110  for (int i = 0; i < 4; i++)
111  coefficients_[i] = coefficients.values.at(i);
112  }
113 
114  /** \brief Getter for the coefficients */
115  Eigen::Vector4f&
117  {
118  return (coefficients_);
119  }
120 
121  /** \brief Getter for the coefficients */
122  const Eigen::Vector4f&
124  {
125  return (coefficients_);
126  }
127 
128 protected:
129  /** \brief A list of points on the boundary/contour of the planar region. */
131 
132  /** \brief A list of model coefficients (a,b,c,d). */
133  Eigen::Vector4f coefficients_;
134 
135 public:
137 };
138 } // namespace pcl
pcl_macros.h
Defines all the PCL and non-PCL macros used.
pcl::PlanarPolygon::getCoefficients
const Eigen::Vector4f & getCoefficients() const
Getter for the coefficients.
Definition: planar_polygon.h:123
pcl
Definition: convolution.h:46
pcl::PlanarPolygon::~PlanarPolygon
virtual ~PlanarPolygon()
Destructor.
Definition: planar_polygon.h:70
pcl::PointCloud::points
std::vector< PointT, Eigen::aligned_allocator< PointT > > points
The point data.
Definition: point_cloud.h:395
pcl::PlanarPolygon::Ptr
shared_ptr< PlanarPolygon< PointT > > Ptr
Definition: planar_polygon.h:54
pcl::PlanarPolygon::setCoefficients
void setCoefficients(const pcl::ModelCoefficients &coefficients)
Set the internal coefficients.
Definition: planar_polygon.h:108
pcl::PlanarPolygon::setCoefficients
void setCoefficients(const Eigen::Vector4f &coefficients)
Setr the internal coefficients.
Definition: planar_polygon.h:99
pcl::PlanarPolygon::contour_
pcl::PointCloud< PointT >::VectorType contour_
A list of points on the boundary/contour of the planar region.
Definition: planar_polygon.h:130
pcl::PointCloud
PointCloud represents the base class in PCL for storing collections of 3D points.
Definition: distances.h:55
pcl::ModelCoefficients::values
std::vector< float > values
Definition: ModelCoefficients.h:19
pcl::PointCloud::VectorType
std::vector< PointT, Eigen::aligned_allocator< PointT > > VectorType
Definition: point_cloud.h:411
pcl::PlanarPolygon::PlanarPolygon
PlanarPolygon()
Empty constructor for PlanarPolygon.
Definition: planar_polygon.h:58
pcl::PlanarPolygon::coefficients_
Eigen::Vector4f coefficients_
A list of model coefficients (a,b,c,d).
Definition: planar_polygon.h:133
pcl::ModelCoefficients
Definition: ModelCoefficients.h:11
pcl::PlanarPolygon::PlanarPolygon
PlanarPolygon(typename pcl::PointCloud< PointT >::VectorType &contour, Eigen::Vector4f &coefficients)
Constructor for PlanarPolygon.
Definition: planar_polygon.h:64
pcl::PlanarPolygon::ConstPtr
shared_ptr< const PlanarPolygon< PointT > > ConstPtr
Definition: planar_polygon.h:55
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::PlanarPolygon::getCoefficients
Eigen::Vector4f & getCoefficients()
Getter for the coefficients.
Definition: planar_polygon.h:116
pcl::PlanarPolygon::getContour
const pcl::PointCloud< PointT >::VectorType & getContour() const
Getter for the contour / boundary.
Definition: planar_polygon.h:90
pcl::PlanarPolygon
PlanarPolygon represents a planar (2D) polygon, potentially in a 3D space.
Definition: planar_polygon.h:52
pcl::PlanarPolygon::setContour
void setContour(const pcl::PointCloud< PointT > &contour)
Set the internal contour.
Definition: planar_polygon.h:76
memory.h
Defines functions, macros and traits for allocating and using memory.
pcl::PlanarPolygon::getContour
pcl::PointCloud< PointT >::VectorType & getContour()
Getter for the contour / boundary.
Definition: planar_polygon.h:83