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