Point Cloud Library (PCL)
1.3.1
|
00001 /* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Point Cloud Library (PCL) - www.pointclouds.org 00005 * Copyright (c) 2010-2011, 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: search.h 3054 2011-11-01 08:02:31Z rusu $ 00037 * 00038 */ 00039 00040 #ifndef PCL_SEARCH_SEARCH_H_ 00041 #define PCL_SEARCH_SEARCH_H_ 00042 00043 #include <pcl/point_cloud.h> 00044 #include <pcl/common/io.h> 00045 00046 namespace pcl 00047 { 00048 namespace search 00049 { 00051 template<typename PointT> 00052 class Search 00053 { 00054 public: 00055 typedef pcl::PointCloud<PointT> PointCloud; 00056 typedef typename PointCloud::Ptr PointCloudPtr; 00057 typedef typename PointCloud::ConstPtr PointCloudConstPtr; 00058 00059 typedef boost::shared_ptr<pcl::search::Search<PointT> > Ptr; 00060 typedef boost::shared_ptr<const pcl::search::Search<PointT> > ConstPtr; 00061 00062 typedef boost::shared_ptr<std::vector<int> > IndicesPtr; 00063 typedef boost::shared_ptr<const std::vector<int> > IndicesConstPtr; 00064 00066 Search () 00067 { 00068 } 00069 00071 virtual 00072 ~Search () 00073 { 00074 } 00075 00080 virtual void 00081 setInputCloud (const PointCloudConstPtr& cloud, const IndicesConstPtr& indices) {} 00082 00086 virtual void 00087 setInputCloud (const PointCloudConstPtr& cloud) = 0; 00088 00090 virtual PointCloudConstPtr 00091 getInputCloud () = 0; 00092 00094 virtual IndicesConstPtr const 00095 getIndices () { return (IndicesConstPtr ()); } 00096 00105 virtual int 00106 nearestKSearch (const PointT &point, int k, std::vector<int> &k_indices, 00107 std::vector<float> &k_sqr_distances) = 0; 00108 00117 template <typename PointTDiff> int 00118 nearestKSearchT (const PointTDiff &point, int k, std::vector<int> &k_indices, 00119 std::vector<float> &k_sqr_distances) 00120 { 00121 PointT p; 00122 // Copy all the data fields from the input cloud to the output one 00123 typedef typename pcl::traits::fieldList<PointT>::type FieldListInT; 00124 typedef typename pcl::traits::fieldList<PointTDiff>::type FieldListOutT; 00125 typedef typename pcl::intersect<FieldListInT, FieldListOutT>::type FieldList; 00126 pcl::for_each_type <FieldList> (pcl::NdConcatenateFunctor <PointT, PointTDiff> ( 00127 point, p)); 00128 return (nearestKSearch (p, k, k_indices, k_sqr_distances)); 00129 } 00130 00140 virtual int 00141 nearestKSearch (const PointCloud& cloud, int index, int k, std::vector<int>& k_indices, 00142 std::vector<float>& k_sqr_distances) = 0; 00143 00153 virtual int 00154 nearestKSearch (int index, int k, std::vector<int>& k_indices, std::vector<float>& k_sqr_distances) = 0; 00155 00164 virtual int 00165 radiusSearch (const PointT& point, const double radius, std::vector<int>& k_indices, 00166 std::vector<float>& k_distances, int max_nn = -1) const = 0; 00167 00176 template <typename PointTDiff> int 00177 radiusSearchT (const PointTDiff& point, double radius, std::vector<int>& k_indices, 00178 std::vector<float>& k_distances, int max_nn = -1) 00179 { 00180 PointT p; 00181 // Copy all the data fields from the input cloud to the output one 00182 typedef typename pcl::traits::fieldList<PointT>::type FieldListInT; 00183 typedef typename pcl::traits::fieldList<PointTDiff>::type FieldListOutT; 00184 typedef typename pcl::intersect<FieldListInT, FieldListOutT>::type FieldList; 00185 pcl::for_each_type <FieldList> (pcl::NdConcatenateFunctor <PointT, PointTDiff> ( 00186 point, p)); 00187 return (radiusSearch (p, radius, k_indices, k_distances, max_nn)); 00188 } 00189 00199 virtual int 00200 radiusSearch (const PointCloud& cloud, int index, double radius, std::vector<int>& k_indices, 00201 std::vector<float>& k_distances, int max_nn = -1) = 0; 00202 00212 virtual int 00213 radiusSearch (int index, double radius, std::vector<int>& k_indices, std::vector<float>& k_distances, 00214 int max_nn = -1) const = 0; 00215 }; 00216 } 00217 } 00218 00219 #endif //#ifndef _PCL_SEARCH_GENERIC_SEARCH_H_