00001 /* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Point Cloud Library (PCL) - www.pointclouds.org 00005 * Copyright (c) 2010-2012, Willow Garage, Inc. 00006 * 00007 * All rights reserved. 00008 * 00009 * Redistribution and use in source and binary forms, with or without 00010 * modification, are permitted provided that the following conditions 00011 * are met: 00012 * 00013 * * Redistributions of source code must retain the above copyright 00014 * notice, this list of conditions and the following disclaimer. 00015 * * Redistributions in binary form must reproduce the above 00016 * copyright notice, this list of conditions and the following 00017 * disclaimer in the documentation and/or other materials provided 00018 * with the distribution. 00019 * * Neither the name of Willow Garage, Inc. nor the names of its 00020 * contributors may be used to endorse or promote products derived 00021 * from this software without specific prior written permission. 00022 * 00023 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00024 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00025 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00026 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00027 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00028 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00029 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00030 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00031 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00032 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00033 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00034 * POSSIBILITY OF SUCH DAMAGE. 00035 * 00036 * $Id$ 00037 * 00038 */ 00039 00040 #ifndef PCL_SURFACE_RECONSTRUCTION_H_ 00041 #define PCL_SURFACE_RECONSTRUCTION_H_ 00042 00043 #include <pcl/pcl_base.h> 00044 #include <pcl/PolygonMesh.h> 00045 #include <pcl/search/pcl_search.h> 00046 #include <pcl/conversions.h> 00047 #include <pcl/surface/boost.h> 00048 00049 namespace pcl 00050 { 00060 template <typename PointInT> 00061 class PCLSurfaceBase: public PCLBase<PointInT> 00062 { 00063 public: 00064 typedef boost::shared_ptr<PCLSurfaceBase<PointInT> > Ptr; 00065 typedef boost::shared_ptr<const PCLSurfaceBase<PointInT> > ConstPtr; 00066 00067 typedef typename pcl::search::Search<PointInT> KdTree; 00068 typedef typename pcl::search::Search<PointInT>::Ptr KdTreePtr; 00069 00071 PCLSurfaceBase () : tree_ () {} 00072 00074 virtual ~PCLSurfaceBase () {} 00075 00079 inline void 00080 setSearchMethod (const KdTreePtr &tree) 00081 { 00082 tree_ = tree; 00083 } 00084 00086 inline KdTreePtr 00087 getSearchMethod () { return (tree_); } 00088 00093 virtual void 00094 reconstruct (pcl::PolygonMesh &output) = 0; 00095 00096 protected: 00098 KdTreePtr tree_; 00099 00101 virtual std::string 00102 getClassName () const { return (""); } 00103 }; 00104 00118 template <typename PointInT> 00119 class SurfaceReconstruction: public PCLSurfaceBase<PointInT> 00120 { 00121 public: 00122 typedef boost::shared_ptr<SurfaceReconstruction<PointInT> > Ptr; 00123 typedef boost::shared_ptr<const SurfaceReconstruction<PointInT> > ConstPtr; 00124 00125 using PCLSurfaceBase<PointInT>::input_; 00126 using PCLSurfaceBase<PointInT>::indices_; 00127 using PCLSurfaceBase<PointInT>::initCompute; 00128 using PCLSurfaceBase<PointInT>::deinitCompute; 00129 using PCLSurfaceBase<PointInT>::tree_; 00130 using PCLSurfaceBase<PointInT>::getClassName; 00131 00133 SurfaceReconstruction () : check_tree_ (true) {} 00134 00136 virtual ~SurfaceReconstruction () {} 00137 00142 virtual void 00143 reconstruct (pcl::PolygonMesh &output); 00144 00151 virtual void 00152 reconstruct (pcl::PointCloud<PointInT> &points, 00153 std::vector<pcl::Vertices> &polygons); 00154 00155 protected: 00158 bool check_tree_; 00159 00163 virtual void 00164 performReconstruction (pcl::PolygonMesh &output) = 0; 00165 00170 virtual void 00171 performReconstruction (pcl::PointCloud<PointInT> &points, 00172 std::vector<pcl::Vertices> &polygons) = 0; 00173 }; 00174 00187 template <typename PointInT> 00188 class MeshConstruction: public PCLSurfaceBase<PointInT> 00189 { 00190 public: 00191 typedef boost::shared_ptr<MeshConstruction<PointInT> > Ptr; 00192 typedef boost::shared_ptr<const MeshConstruction<PointInT> > ConstPtr; 00193 00194 using PCLSurfaceBase<PointInT>::input_; 00195 using PCLSurfaceBase<PointInT>::indices_; 00196 using PCLSurfaceBase<PointInT>::initCompute; 00197 using PCLSurfaceBase<PointInT>::deinitCompute; 00198 using PCLSurfaceBase<PointInT>::tree_; 00199 using PCLSurfaceBase<PointInT>::getClassName; 00200 00202 MeshConstruction () : check_tree_ (true) {} 00203 00205 virtual ~MeshConstruction () {} 00206 00216 virtual void 00217 reconstruct (pcl::PolygonMesh &output); 00218 00224 virtual void 00225 reconstruct (std::vector<pcl::Vertices> &polygons); 00226 00227 protected: 00230 bool check_tree_; 00231 00235 virtual void 00236 performReconstruction (pcl::PolygonMesh &output) = 0; 00237 00241 virtual void 00242 performReconstruction (std::vector<pcl::Vertices> &polygons) = 0; 00243 }; 00244 } 00245 00246 #include <pcl/surface/impl/reconstruction.hpp> 00247 00248 #endif // PCL_SURFACE_RECONSTRUCTION_H_ 00249