|
Point Cloud Library (PCL)
1.4.0
|
00001 /* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Copyright (c) 2010, Willow Garage, Inc. 00005 * All rights reserved. 00006 * 00007 * Redistribution and use in source and binary forms, with or without 00008 * modification, are permitted provided that the following conditions 00009 * are met: 00010 * 00011 * * Redistributions of source code must retain the above copyright 00012 * notice, this list of conditions and the following disclaimer. 00013 * * Redistributions in binary form must reproduce the above 00014 * copyright notice, this list of conditions and the following 00015 * disclaimer in the documentation and/or other materials provided 00016 * with the distribution. 00017 * * Neither the name of Willow Garage, Inc. nor the names of its 00018 * contributors may be used to endorse or promote products derived 00019 * from this software without specific prior written permission. 00020 * 00021 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00022 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00023 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00024 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00025 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00026 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00027 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00028 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00029 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00031 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00032 * POSSIBILITY OF SUCH DAMAGE. 00033 * 00034 * $Id: convex_hull.h 3753 2011-12-31 23:30:57Z rusu $ 00035 * 00036 */ 00037 00038 #include <pcl/pcl_config.h> 00039 #ifdef HAVE_QHULL 00040 00041 #ifndef PCL_CONVEX_HULL_2D_H_ 00042 #define PCL_CONVEX_HULL_2D_H_ 00043 00044 // PCL includes 00045 #include "pcl/surface/reconstruction.h" 00046 00047 #include "pcl/ModelCoefficients.h" 00048 #include "pcl/PolygonMesh.h" 00049 00050 namespace pcl 00051 { 00057 inline bool 00058 comparePoints2D (const std::pair<int, Eigen::Vector4f> & p1, const std::pair<int, Eigen::Vector4f> & p2) 00059 { 00060 double angle1 = atan2 (p1.second[1], p1.second[0]) + M_PI; 00061 double angle2 = atan2 (p2.second[1], p2.second[0]) + M_PI; 00062 return (angle1 > angle2); 00063 } 00064 00066 00070 template<typename PointInT> 00071 class ConvexHull : public MeshConstruction<PointInT> 00072 { 00073 protected: 00074 using PCLBase<PointInT>::input_; 00075 using PCLBase<PointInT>::indices_; 00076 using PCLBase<PointInT>::initCompute; 00077 using PCLBase<PointInT>::deinitCompute; 00078 00079 public: 00080 using MeshConstruction<PointInT>::reconstruct; 00081 00082 typedef pcl::PointCloud<PointInT> PointCloud; 00083 typedef typename PointCloud::Ptr PointCloudPtr; 00084 typedef typename PointCloud::ConstPtr PointCloudConstPtr; 00085 00087 ConvexHull () : total_area_(0), total_volume_(0), dim_(0) 00088 { 00089 keep_information_ = false; 00090 compute_area_ = false; 00091 }; 00092 00099 void 00100 reconstruct (PointCloud &points, 00101 std::vector<pcl::Vertices> &polygons); 00102 00106 void 00107 reconstruct (PointCloud &output); 00108 00113 void 00114 setKeepInformation (bool value) 00115 { 00116 keep_information_ = value; 00117 } 00118 00123 void 00124 setComputeAreaVolume (bool value) 00125 { 00126 compute_area_ = value; 00127 } 00128 00131 double 00132 getTotalArea () 00133 { 00134 return total_area_; 00135 } 00136 00140 double 00141 getTotalVolume () 00142 { 00143 return total_volume_; 00144 } 00145 00147 inline int 00148 getDim () const 00149 { 00150 return dim_; 00151 } 00152 00153 protected: 00161 void 00162 performReconstruction (PointCloud &points, 00163 std::vector<pcl::Vertices> &polygons, 00164 bool fill_polygon_data = false); 00165 00166 virtual void 00167 performReconstruction (PolygonMesh &output); 00168 00169 virtual void 00170 performReconstruction (std::vector<pcl::Vertices> &polygons); 00171 00172 00174 std::string 00175 getClassName () const 00176 { 00177 return ("ConvexHull"); 00178 } 00179 00180 bool keep_information_; 00181 bool compute_area_; 00182 double total_area_; 00183 double total_volume_; 00184 00186 int dim_; 00187 00188 }; 00189 } 00190 00191 #endif //#ifndef PCL_CONVEX_HULL_2D_H_ 00192 #endif
1.7.6.1