Point Cloud Library (PCL)
1.7.0
|
00001 /* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Point Cloud Library (PCL) - www.pointclouds.org 00005 * Copyright (c) 2009-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 #include <pcl/pcl_config.h> 00041 #ifdef HAVE_QHULL 00042 00043 #ifndef PCL_CONCAVE_HULL_H 00044 #define PCL_CONCAVE_HULL_H 00045 00046 #include <pcl/surface/convex_hull.h> 00047 00048 namespace pcl 00049 { 00050 //////////////////////////////////////////////////////////////////////////////////////////// 00051 /** \brief @b ConcaveHull (alpha shapes) using libqhull library. 00052 * \author Aitor Aldoma 00053 * \ingroup surface 00054 */ 00055 template<typename PointInT> 00056 class ConcaveHull : public MeshConstruction<PointInT> 00057 { 00058 protected: 00059 typedef boost::shared_ptr<ConcaveHull<PointInT> > Ptr; 00060 typedef boost::shared_ptr<const ConcaveHull<PointInT> > ConstPtr; 00061 00062 using PCLBase<PointInT>::input_; 00063 using PCLBase<PointInT>::indices_; 00064 using PCLBase<PointInT>::initCompute; 00065 using PCLBase<PointInT>::deinitCompute; 00066 00067 public: 00068 using MeshConstruction<PointInT>::reconstruct; 00069 00070 typedef pcl::PointCloud<PointInT> PointCloud; 00071 typedef typename PointCloud::Ptr PointCloudPtr; 00072 typedef typename PointCloud::ConstPtr PointCloudConstPtr; 00073 00074 /** \brief Empty constructor. */ 00075 ConcaveHull () : alpha_ (0), keep_information_ (false), voronoi_centers_ (), dim_(0) 00076 { 00077 }; 00078 00079 /** \brief Empty destructor */ 00080 virtual ~ConcaveHull () {} 00081 00082 /** \brief Compute a concave hull for all points given 00083 * 00084 * \param points the resultant points lying on the concave hull 00085 * \param polygons the resultant concave hull polygons, as a set of 00086 * vertices. The Vertices structure contains an array of point indices. 00087 */ 00088 void 00089 reconstruct (PointCloud &points, 00090 std::vector<pcl::Vertices> &polygons); 00091 00092 /** \brief Compute a concave hull for all points given 00093 * \param output the resultant concave hull vertices 00094 */ 00095 void 00096 reconstruct (PointCloud &output); 00097 00098 /** \brief Set the alpha value, which limits the size of the resultant 00099 * hull segments (the smaller the more detailed the hull). 00100 * 00101 * \param alpha positive, non-zero value, defining the maximum length 00102 * from a vertex to the facet center (center of the voronoi cell). 00103 */ 00104 inline void 00105 setAlpha (double alpha) 00106 { 00107 alpha_ = alpha; 00108 } 00109 00110 /** \brief Returns the alpha parameter, see setAlpha(). */ 00111 inline double 00112 getAlpha () 00113 { 00114 return (alpha_); 00115 } 00116 00117 /** \brief If set, the voronoi cells center will be saved in _voronoi_centers_ 00118 * \param voronoi_centers 00119 */ 00120 inline void 00121 setVoronoiCenters (PointCloudPtr voronoi_centers) 00122 { 00123 voronoi_centers_ = voronoi_centers; 00124 } 00125 00126 /** \brief If keep_information_is set to true the convex hull 00127 * points keep other information like rgb, normals, ... 00128 * \param value where to keep the information or not, default is false 00129 */ 00130 void 00131 setKeepInformation (bool value) 00132 { 00133 keep_information_ = value; 00134 } 00135 00136 /** \brief Returns the dimensionality (2 or 3) of the calculated hull. */ 00137 PCL_DEPRECATED (int getDim () const, "[pcl::ConcaveHull::getDim] This method is deprecated. Please use getDimension () instead."); 00138 00139 /** \brief Returns the dimensionality (2 or 3) of the calculated hull. */ 00140 inline int 00141 getDimension () const 00142 { 00143 return (dim_); 00144 } 00145 00146 /** \brief Sets the dimension on the input data, 2D or 3D. 00147 * \param[in] dimension The dimension of the input data. If not set, this will be determined automatically. 00148 */ 00149 void 00150 setDimension (int dimension) 00151 { 00152 if ((dimension == 2) || (dimension == 3)) 00153 dim_ = dimension; 00154 else 00155 PCL_ERROR ("[pcl::%s::setDimension] Invalid input dimension specified!\n", getClassName ().c_str ()); 00156 } 00157 00158 protected: 00159 /** \brief Class get name method. */ 00160 std::string 00161 getClassName () const 00162 { 00163 return ("ConcaveHull"); 00164 } 00165 00166 protected: 00167 /** \brief The actual reconstruction method. 00168 * 00169 * \param points the resultant points lying on the concave hull 00170 * \param polygons the resultant concave hull polygons, as a set of 00171 * vertices. The Vertices structure contains an array of point indices. 00172 */ 00173 void 00174 performReconstruction (PointCloud &points, 00175 std::vector<pcl::Vertices> &polygons); 00176 00177 virtual void 00178 performReconstruction (PolygonMesh &output); 00179 00180 virtual void 00181 performReconstruction (std::vector<pcl::Vertices> &polygons); 00182 00183 /** \brief The method accepts facets only if the distance from any vertex to the facet->center 00184 * (center of the voronoi cell) is smaller than alpha 00185 */ 00186 double alpha_; 00187 00188 /** \brief If set to true, the reconstructed point cloud describing the hull is obtained from 00189 * the original input cloud by performing a nearest neighbor search from Qhull output. 00190 */ 00191 bool keep_information_; 00192 00193 /** \brief the centers of the voronoi cells */ 00194 PointCloudPtr voronoi_centers_; 00195 00196 /** \brief the dimensionality of the concave hull */ 00197 int dim_; 00198 }; 00199 } 00200 00201 #ifdef PCL_NO_PRECOMPILE 00202 #include <pcl/surface/impl/concave_hull.hpp> 00203 #endif 00204 00205 #endif //#ifndef PCL_CONCAVE_HULL 00206 #endif