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