Point Cloud Library (PCL)  1.9.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/common/eigen.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 = boost::shared_ptr<PlanarPolygon<PointT> >;
57  using ConstPtr = boost::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 }
const Eigen::Vector4f & getCoefficients() const
Getter for the coefficients.
virtual ~PlanarPolygon()
Destructor.
void setCoefficients(const pcl::ModelCoefficients &coefficients)
Set the internal coefficients.
std::vector< PointT, Eigen::aligned_allocator< PointT > > points
The point data.
Definition: point_cloud.h:423
const pcl::PointCloud< PointT >::VectorType & getContour() const
Getter for the contour / boundary.
PlanarPolygon()
Empty constructor for PlanarPolygon.
pcl::PointCloud< PointT >::VectorType & getContour()
Getter for the contour / boundary.
This file defines compatibility wrappers for low level I/O functions.
Definition: convolution.h:45
std::vector< float > values
void setCoefficients(const Eigen::Vector4f &coefficients)
Setr the internal coefficients.
#define PCL_MAKE_ALIGNED_OPERATOR_NEW
Macro to signal a class requires a custom allocator.
Definition: pcl_macros.h:344
std::vector< PointT, Eigen::aligned_allocator< PointT > > VectorType
Definition: point_cloud.h:439
pcl::PointCloud< PointT >::VectorType contour_
A list of points on the boundary/contour of the planar region.
PlanarPolygon represents a planar (2D) polygon, potentially in a 3D space.
Eigen::Vector4f & getCoefficients()
Getter for the coefficients.
PointCloud represents the base class in PCL for storing collections of 3D points. ...
PlanarPolygon(typename pcl::PointCloud< PointT >::VectorType &contour, Eigen::Vector4f &coefficients)
Constructor for PlanarPolygon.
Eigen::Vector4f coefficients_
A list of model coefficients (a,b,c,d).
boost::shared_ptr< const PlanarPolygon< PointT > > ConstPtr
boost::shared_ptr< PlanarPolygon< PointT > > Ptr
Defines all the PCL and non-PCL macros used.
void setContour(const pcl::PointCloud< PointT > &contour)
Set the internal contour.