|
Point Cloud Library (PCL)
1.4.0
|
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 */ 00037 00038 #ifndef PCL_SEARCH_BRUTE_FORCE_H_ 00039 #define PCL_SEARCH_BRUTE_FORCE_H_ 00040 00041 #include <pcl/search/search.h> 00042 00043 namespace pcl 00044 { 00045 namespace search 00046 { 00051 template<typename PointT> 00052 class BruteForce: public Search<PointT> 00053 { 00054 typedef typename Search<PointT>::PointCloud PointCloud; 00055 typedef typename Search<PointT>::PointCloudConstPtr PointCloudConstPtr; 00056 00057 typedef boost::shared_ptr<std::vector<int> > IndicesPtr; 00058 typedef boost::shared_ptr<const std::vector<int> > IndicesConstPtr; 00059 00060 struct Entry 00061 { 00062 Entry (int idx, float dist) : index (idx), distance (dist) {} 00063 Entry () {} 00064 unsigned index; 00065 float distance; 00066 bool operator < (const Entry& other) const 00067 { 00068 return distance < other.distance; 00069 } 00070 }; 00071 00072 // replace by some metric functor 00073 float getDistSqr (const PointT& point1, const PointT& point2) const; 00074 public: 00075 BruteForce () 00076 { 00077 } 00078 00080 virtual 00081 ~BruteForce () 00082 { 00083 } 00084 00089 inline void 00090 setInputCloud (const PointCloudConstPtr& cloud, const IndicesConstPtr& indices) 00091 { 00092 cloud_ = cloud; 00093 indices_ = indices; 00094 } 00095 00099 inline void 00100 setInputCloud (const PointCloudConstPtr& cloud) 00101 { 00102 const IndicesConstPtr& indices = IndicesConstPtr (); 00103 setInputCloud (cloud, indices); 00104 } 00105 00107 PointCloudConstPtr 00108 getInputCloud () 00109 { 00110 return (cloud_); 00111 } 00112 00114 virtual IndicesConstPtr const 00115 getIndices () 00116 { 00117 return (indices_); 00118 } 00119 00128 int 00129 nearestKSearch (const PointT &point, int k, std::vector<int> &k_indices, std::vector<float> &k_distances); 00130 00131 00141 inline int 00142 nearestKSearch (const PointCloud &cloud, int index, int k, std::vector<int> &k_indices, 00143 std::vector<float> &k_distances) 00144 { 00145 return nearestKSearch (cloud[index], k, k_indices, k_distances); 00146 } 00147 00159 inline int 00160 nearestKSearch (int index, int k, std::vector<int> &k_indices, std::vector<float> &k_distances) 00161 { 00162 return nearestKSearch (cloud_->operator[](index), k, k_indices, k_distances); 00163 } 00164 00173 int 00174 radiusSearch (const PointT& point, double radius, 00175 std::vector<int> &k_indices, std::vector<float> &k_sqr_distances, 00176 int max_nn = -1) const; 00177 00187 inline int 00188 radiusSearch (const PointCloud& cloud, int index, double radius, std::vector<int> &k_indices, 00189 std::vector<float> &k_distances, int max_nn = -1) 00190 { 00191 return (radiusSearch (cloud[index], radius, k_indices, k_distances, max_nn)); 00192 } 00193 00203 inline int 00204 radiusSearch (int index, double radius, std::vector<int> &k_indices, std::vector<float> &k_distances, 00205 int max_nn = -1) const 00206 { 00207 return (radiusSearch (cloud_->operator[](index), radius, k_indices, k_distances, max_nn)); 00208 } 00209 00210 protected: 00211 PointCloudConstPtr cloud_; 00212 IndicesConstPtr indices_; 00213 }; 00214 } 00215 } 00216 00217 #endif // PCL_SEARCH_BRUTE_FORCE_H_
1.7.6.1