Point Cloud Library (PCL)  1.11.1-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/memory.h>
43 #include <pcl/pcl_macros.h>
44 #include <pcl/point_cloud.h>
45 #include <pcl/ModelCoefficients.h>
46 
47 namespace pcl
48 {
49  /** \brief PlanarPolygon represents a planar (2D) polygon, potentially in a 3D space.
50  * \author Alex Trevor
51  */
52  template <typename PointT>
54  {
55  public:
56  using Ptr = shared_ptr<PlanarPolygon<PointT> >;
57  using ConstPtr = shared_ptr<const PlanarPolygon<PointT> >;
58 
59  /** \brief Empty constructor for PlanarPolygon */
61  {}
62 
63  /** \brief Constructor for PlanarPolygon
64  * \param[in] contour a vector of points bounding the polygon
65  * \param[in] coefficients a vector of the plane's coefficients (a,b,c,d)
66  */
68  Eigen::Vector4f& coefficients)
69  : contour_ (contour), coefficients_ (coefficients)
70  {}
71 
72  /** \brief Destructor. */
73  virtual ~PlanarPolygon () {}
74 
75  /** \brief Set the internal contour
76  * \param[in] contour the new planar polygonal contour
77  */
78  void
80  {
81  contour_ = contour.points;
82  }
83 
84  /** \brief Getter for the contour / boundary */
87  {
88  return (contour_);
89  }
90 
91  /** \brief Getter for the contour / boundary */
93  getContour () const
94  {
95  return (contour_);
96  }
97 
98  /** \brief Setr the internal coefficients
99  * \param[in] coefficients the new coefficients to be set
100  */
101  void
102  setCoefficients (const Eigen::Vector4f &coefficients)
103  {
104  coefficients_ = coefficients;
105  }
106 
107  /** \brief Set the internal coefficients
108  * \param[in] coefficients the new coefficients to be set
109  */
110  void
112  {
113  for (int i = 0; i < 4; i++)
114  coefficients_[i] = coefficients.values.at (i);
115  }
116 
117  /** \brief Getter for the coefficients */
118  Eigen::Vector4f&
120  {
121  return (coefficients_);
122  }
123 
124  /** \brief Getter for the coefficients */
125  const Eigen::Vector4f&
127  {
128  return (coefficients_);
129  }
130 
131  protected:
132  /** \brief A list of points on the boundary/contour of the planar region. */
134 
135  /** \brief A list of model coefficients (a,b,c,d). */
136  Eigen::Vector4f coefficients_;
137 
138  public:
140  };
141 }
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:126
pcl
Definition: convolution.h:46
pcl::PlanarPolygon::~PlanarPolygon
virtual ~PlanarPolygon()
Destructor.
Definition: planar_polygon.h:73
pcl::PointCloud::points
std::vector< PointT, Eigen::aligned_allocator< PointT > > points
The point data.
Definition: point_cloud.h:388
pcl::PlanarPolygon::Ptr
shared_ptr< PlanarPolygon< PointT > > Ptr
Definition: planar_polygon.h:56
pcl::PlanarPolygon::setCoefficients
void setCoefficients(const pcl::ModelCoefficients &coefficients)
Set the internal coefficients.
Definition: planar_polygon.h:111
pcl::PlanarPolygon::setCoefficients
void setCoefficients(const Eigen::Vector4f &coefficients)
Setr the internal coefficients.
Definition: planar_polygon.h:102
pcl::PlanarPolygon::contour_
pcl::PointCloud< PointT >::VectorType contour_
A list of points on the boundary/contour of the planar region.
Definition: planar_polygon.h:133
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:404
pcl::PlanarPolygon::PlanarPolygon
PlanarPolygon()
Empty constructor for PlanarPolygon.
Definition: planar_polygon.h:60
pcl::PlanarPolygon::coefficients_
Eigen::Vector4f coefficients_
A list of model coefficients (a,b,c,d).
Definition: planar_polygon.h:136
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:67
pcl::PlanarPolygon::ConstPtr
shared_ptr< const PlanarPolygon< PointT > > ConstPtr
Definition: planar_polygon.h:57
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:119
pcl::PlanarPolygon::getContour
const pcl::PointCloud< PointT >::VectorType & getContour() const
Getter for the contour / boundary.
Definition: planar_polygon.h:93
pcl::PlanarPolygon
PlanarPolygon represents a planar (2D) polygon, potentially in a 3D space.
Definition: planar_polygon.h:53
pcl::PlanarPolygon::setContour
void setContour(const pcl::PointCloud< PointT > &contour)
Set the internal contour.
Definition: planar_polygon.h:79
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:86