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