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