Point Cloud Library (PCL)  1.7.0
planar_region.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 the copyright holder(s) 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  */
37 
38 #ifndef PCL_SEGMENTATION_PLANAR_REGION_H_
39 #define PCL_SEGMENTATION_PLANAR_REGION_H_
40 
41 #include <pcl/segmentation/region_3d.h>
42 #include <pcl/geometry/planar_polygon.h>
43 
44 namespace pcl
45 {
46  /** \brief PlanarRegion represents a set of points that lie in a plane. Inherits summary statistics about these points from Region3D, and summary statistics of a 3D collection of points.
47  * \author Alex Trevor
48  */
49  template <typename PointT>
50  class PlanarRegion : public pcl::Region3D<PointT>, public pcl::PlanarPolygon<PointT>
51  {
52  protected:
58 
59  public:
60  /** \brief Empty constructor for PlanarRegion. */
61  PlanarRegion () : contour_labels_ ()
62  {}
63 
64  /** \brief Constructor for Planar region from a Region3D and a PlanarPolygon.
65  * \param[in] region a Region3D for the input data
66  * \param[in] polygon a PlanarPolygon for the input region
67  */
69  contour_labels_ ()
70  {
71  centroid_ = region.centroid;
72  covariance_ = region.covariance;
73  count_ = region.count;
74  contour_ = polygon.contour;
75  coefficients_ = polygon.coefficients;
76  }
77 
78  /** \brief Destructor. */
79  virtual ~PlanarRegion () {}
80 
81  /** \brief Constructor for PlanarRegion.
82  * \param[in] centroid the centroid of the region.
83  * \param[in] covariance the covariance of the region.
84  * \param[in] count the number of points in the region.
85  * \param[in] contour the contour / boudnary for the region
86  * \param[in] coefficients the model coefficients (a,b,c,d) for the plane
87  */
88  PlanarRegion (const Eigen::Vector3f& centroid, const Eigen::Matrix3f& covariance, unsigned count,
89  const typename pcl::PointCloud<PointT>::VectorType& contour,
90  const Eigen::Vector4f& coefficients) :
91  contour_labels_ ()
92  {
93  centroid_ = centroid;
94  covariance_ = covariance;
95  count_ = count;
96  contour_ = contour;
97  coefficients_ = coefficients;
98  }
99 
100  private:
101  /** \brief The labels (good=true, bad=false) for whether or not this boundary was observed,
102  * or was due to edge of frame / occlusion boundary.
103  */
104  std::vector<bool> contour_labels_;
105 
106  public:
107  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
108  };
109 }
110 
111 #endif //PCL_SEGMENTATION_PLANAR_REGION_H_