Point Cloud Library (PCL)
1.3.1
|
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 3031 2011-11-01 04:25:15Z 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/pcl_base.h" 00046 00047 #include "pcl/ModelCoefficients.h" 00048 #include "pcl/PolygonMesh.h" 00049 #include <math.h> 00050 00051 namespace pcl 00052 { 00058 inline bool 00059 comparePoints2D (const std::pair<int, Eigen::Vector4f> & p1, const std::pair<int, Eigen::Vector4f> & p2) 00060 { 00061 double angle1 = atan2 (p1.second[1], p1.second[0]) + M_PI; 00062 double angle2 = atan2 (p2.second[1], p2.second[0]) + M_PI; 00063 return (angle1 > angle2); 00064 } 00065 00067 00071 template<typename PointInT> 00072 class ConvexHull : public PCLBase<PointInT> 00073 { 00074 using PCLBase<PointInT>::input_; 00075 using PCLBase<PointInT>::indices_; 00076 using PCLBase<PointInT>::initCompute; 00077 using PCLBase<PointInT>::deinitCompute; 00078 00079 public: 00080 typedef pcl::PointCloud<PointInT> PointCloud; 00081 typedef typename PointCloud::Ptr PointCloudPtr; 00082 typedef typename PointCloud::ConstPtr PointCloudConstPtr; 00083 00085 ConvexHull () : total_area_(0), total_volume_(0) 00086 { 00087 keep_information_ = false; 00088 compute_area_ = false; 00089 }; 00090 00097 void 00098 reconstruct (PointCloud &points, 00099 std::vector<pcl::Vertices> &polygons); 00100 00104 void 00105 reconstruct (PointCloud &output); 00106 00111 void 00112 setKeepInformation (bool value) 00113 { 00114 keep_information_ = value; 00115 } 00116 00121 void 00122 setComputeAreaVolume (bool value) 00123 { 00124 compute_area_ = value; 00125 } 00126 00129 double 00130 getTotalArea () 00131 { 00132 return total_area_; 00133 } 00134 00138 double 00139 getTotalVolume () 00140 { 00141 return total_volume_; 00142 } 00143 00144 private: 00152 void 00153 performReconstruction (PointCloud &points, 00154 std::vector<pcl::Vertices> &polygons, 00155 bool fill_polygon_data = false); 00156 00157 bool keep_information_; 00158 bool compute_area_; 00159 double total_area_; 00160 double total_volume_; 00161 00162 protected: 00164 std::string 00165 getClassName () const 00166 { 00167 return ("ConvexHull"); 00168 } 00169 }; 00170 } 00171 00172 #endif //#ifndef PCL_CONVEX_HULL_2D_H_ 00173 #endif