Point Cloud Library (PCL)  1.11.1-dev
reconstruction.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$
37  *
38  */
39 
40 #pragma once
41 
42 #include <pcl/pcl_base.h>
43 #include <pcl/PolygonMesh.h>
44 #include <pcl/conversions.h>
45 #include <pcl/search/search.h> // for Search
46 
47 namespace pcl
48 {
49  /** \brief Pure abstract class. All types of meshing/reconstruction
50  * algorithms in \b libpcl_surface must inherit from this, in order to make
51  * sure we have a consistent API. The methods that we care about here are:
52  *
53  * - \b setSearchMethod(&SearchPtr): passes a search locator
54  * - \b reconstruct(&PolygonMesh): creates a PolygonMesh object from the input data
55  *
56  * \author Radu B. Rusu, Michael Dixon, Alexandru E. Ichim
57  */
58  template <typename PointInT>
59  class PCLSurfaceBase: public PCLBase<PointInT>
60  {
61  public:
62  using Ptr = shared_ptr<PCLSurfaceBase<PointInT> >;
63  using ConstPtr = shared_ptr<const PCLSurfaceBase<PointInT> >;
64 
66  using KdTreePtr = typename KdTree::Ptr;
67 
68  /** \brief Empty constructor. */
69  PCLSurfaceBase () : tree_ () {}
70 
71  /** \brief Empty destructor */
73 
74  /** \brief Provide an optional pointer to a search object.
75  * \param[in] tree a pointer to the spatial search object.
76  */
77  inline void
78  setSearchMethod (const KdTreePtr &tree)
79  {
80  tree_ = tree;
81  }
82 
83  /** \brief Get a pointer to the search method used. */
84  inline KdTreePtr
85  getSearchMethod () { return (tree_); }
86 
87  /** \brief Base method for surface reconstruction for all points given in
88  * <setInputCloud (), setIndices ()>
89  * \param[out] output the resultant reconstructed surface model
90  */
91  virtual void
92  reconstruct (pcl::PolygonMesh &output) = 0;
93 
94  protected:
95  /** \brief A pointer to the spatial search object. */
97 
98  /** \brief Abstract class get name method. */
99  virtual std::string
100  getClassName () const { return (""); }
101  };
102 
103  /** \brief SurfaceReconstruction represents a base surface reconstruction
104  * class. All \b surface reconstruction methods take in a point cloud and
105  * generate a new surface from it, by either re-sampling the data or
106  * generating new data altogether. These methods are thus \b not preserving
107  * the topology of the original data.
108  *
109  * \note Reconstruction methods that always preserve the original input
110  * point cloud data as the surface vertices and simply construct the mesh on
111  * top should inherit from \ref MeshConstruction.
112  *
113  * \author Radu B. Rusu, Michael Dixon, Alexandru E. Ichim
114  * \ingroup surface
115  */
116  template <typename PointInT>
117  class SurfaceReconstruction: public PCLSurfaceBase<PointInT>
118  {
119  public:
120  using Ptr = shared_ptr<SurfaceReconstruction<PointInT> >;
121  using ConstPtr = shared_ptr<const SurfaceReconstruction<PointInT> >;
122 
129 
130  /** \brief Constructor. */
132 
133  /** \brief Destructor. */
135 
136  /** \brief Base method for surface reconstruction for all points given in
137  * <setInputCloud (), setIndices ()>
138  * \param[out] output the resultant reconstructed surface model
139  */
140  void
141  reconstruct (pcl::PolygonMesh &output) override;
142 
143  /** \brief Base method for surface reconstruction for all points given in
144  * <setInputCloud (), setIndices ()>
145  * \param[out] points the resultant points lying on the new surface
146  * \param[out] polygons the resultant polygons, as a set of
147  * vertices. The Vertices structure contains an array of point indices.
148  */
149  virtual void
151  std::vector<pcl::Vertices> &polygons);
152 
153  protected:
154  /** \brief A flag specifying whether or not the derived reconstruction
155  * algorithm needs the search object \a tree.*/
157 
158  /** \brief Abstract surface reconstruction method.
159  * \param[out] output the output polygonal mesh
160  */
161  virtual void
163 
164  /** \brief Abstract surface reconstruction method.
165  * \param[out] points the resultant points lying on the surface
166  * \param[out] polygons the resultant polygons, as a set of vertices. The Vertices structure contains an array of point indices.
167  */
168  virtual void
170  std::vector<pcl::Vertices> &polygons) = 0;
171  };
172 
173  /** \brief MeshConstruction represents a base surface reconstruction
174  * class. All \b mesh constructing methods that take in a point cloud and
175  * generate a surface that uses the original data as vertices should inherit
176  * from this class.
177  *
178  * \note Reconstruction methods that generate a new surface or create new
179  * vertices in locations different than the input data should inherit from
180  * \ref SurfaceReconstruction.
181  *
182  * \author Radu B. Rusu, Michael Dixon, Alexandru E. Ichim
183  * \ingroup surface
184  */
185  template <typename PointInT>
186  class MeshConstruction: public PCLSurfaceBase<PointInT>
187  {
188  public:
189  using Ptr = shared_ptr<MeshConstruction<PointInT> >;
190  using ConstPtr = shared_ptr<const MeshConstruction<PointInT> >;
191 
198 
199  /** \brief Constructor. */
201 
202  /** \brief Destructor. */
204 
205  /** \brief Base method for surface reconstruction for all points given in
206  * <setInputCloud (), setIndices ()>
207  * \param[out] output the resultant reconstructed surface model
208  *
209  * \note This method copies the input point cloud data from
210  * PointCloud<T> to PCLPointCloud2, and is implemented here for backwards
211  * compatibility only!
212  *
213  */
214  void
215  reconstruct (pcl::PolygonMesh &output) override;
216 
217  /** \brief Base method for mesh construction for all points given in
218  * <setInputCloud (), setIndices ()>
219  * \param[out] polygons the resultant polygons, as a set of
220  * vertices. The Vertices structure contains an array of point indices.
221  */
222  virtual void
223  reconstruct (std::vector<pcl::Vertices> &polygons);
224 
225  protected:
226  /** \brief A flag specifying whether or not the derived reconstruction
227  * algorithm needs the search object \a tree.*/
229 
230  /** \brief Abstract surface reconstruction method.
231  * \param[out] output the output polygonal mesh
232  */
233  virtual void
235 
236  /** \brief Abstract surface reconstruction method.
237  * \param[out] polygons the resultant polygons, as a set of vertices. The Vertices structure contains an array of point indices.
238  */
239  virtual void
240  performReconstruction (std::vector<pcl::Vertices> &polygons) = 0;
241  };
242 }
243 
244 #include <pcl/surface/impl/reconstruction.hpp>
pcl::search::Search
Generic search class.
Definition: search.h:74
pcl::PCLSurfaceBase::PCLSurfaceBase
PCLSurfaceBase()
Empty constructor.
Definition: reconstruction.h:69
pcl
Definition: convolution.h:46
pcl::PCLSurfaceBase< PointNT >::Ptr
shared_ptr< PCLSurfaceBase< PointNT > > Ptr
Definition: reconstruction.h:62
pcl::MeshConstruction::performReconstruction
virtual void performReconstruction(pcl::PolygonMesh &output)=0
Abstract surface reconstruction method.
pcl::MeshConstruction::reconstruct
void reconstruct(pcl::PolygonMesh &output) override
Base method for surface reconstruction for all points given in <setInputCloud (), setIndices ()>
Definition: reconstruction.hpp:131
pcl::SurfaceReconstruction::SurfaceReconstruction
SurfaceReconstruction()
Constructor.
Definition: reconstruction.h:131
pcl::PCLBase
PCL base class.
Definition: pcl_base.h:69
pcl::PointCloud< PointInT >
pcl::MeshConstruction::~MeshConstruction
~MeshConstruction()
Destructor.
Definition: reconstruction.h:203
pcl::PCLSurfaceBase< PointNT >::KdTreePtr
typename KdTree::Ptr KdTreePtr
Definition: reconstruction.h:66
pcl::SurfaceReconstruction
SurfaceReconstruction represents a base surface reconstruction class.
Definition: reconstruction.h:117
pcl::PCLSurfaceBase::getClassName
virtual std::string getClassName() const
Abstract class get name method.
Definition: reconstruction.h:100
pcl::PCLSurfaceBase::reconstruct
virtual void reconstruct(pcl::PolygonMesh &output)=0
Base method for surface reconstruction for all points given in <setInputCloud (), setIndices ()>
pcl::PolygonMesh
Definition: PolygonMesh.h:14
pcl::search::Search< PointInT >::Ptr
shared_ptr< pcl::search::Search< PointInT > > Ptr
Definition: search.h:81
pcl::PCLSurfaceBase::~PCLSurfaceBase
~PCLSurfaceBase()
Empty destructor.
Definition: reconstruction.h:72
pcl::PCLSurfaceBase< PointNT >::ConstPtr
shared_ptr< const PCLSurfaceBase< PointNT > > ConstPtr
Definition: reconstruction.h:63
pcl::MeshConstruction::check_tree_
bool check_tree_
A flag specifying whether or not the derived reconstruction algorithm needs the search object tree.
Definition: reconstruction.h:228
pcl::PCLSurfaceBase::tree_
KdTreePtr tree_
A pointer to the spatial search object.
Definition: reconstruction.h:96
pcl::PCLSurfaceBase::getSearchMethod
KdTreePtr getSearchMethod()
Get a pointer to the search method used.
Definition: reconstruction.h:85
pcl::SurfaceReconstruction::~SurfaceReconstruction
~SurfaceReconstruction()
Destructor.
Definition: reconstruction.h:134
pcl::SurfaceReconstruction::check_tree_
bool check_tree_
A flag specifying whether or not the derived reconstruction algorithm needs the search object tree.
Definition: reconstruction.h:156
pcl::SurfaceReconstruction::reconstruct
void reconstruct(pcl::PolygonMesh &output) override
Base method for surface reconstruction for all points given in <setInputCloud (), setIndices ()>
Definition: reconstruction.hpp:51
pcl::SurfaceReconstruction::performReconstruction
virtual void performReconstruction(pcl::PolygonMesh &output)=0
Abstract surface reconstruction method.
pcl::PCLSurfaceBase
Pure abstract class.
Definition: reconstruction.h:59
pcl::PCLSurfaceBase::setSearchMethod
void setSearchMethod(const KdTreePtr &tree)
Provide an optional pointer to a search object.
Definition: reconstruction.h:78
pcl::MeshConstruction::MeshConstruction
MeshConstruction()
Constructor.
Definition: reconstruction.h:200
pcl::MeshConstruction
MeshConstruction represents a base surface reconstruction class.
Definition: reconstruction.h:186