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: organized.h 3054 2011-11-01 08:02:31Z rusu $ 00037 * 00038 */ 00039 00040 #ifndef PCL_SEARCH_ORGANIZED_NEIGHBOR_SEARCH_H_ 00041 #define PCL_SEARCH_ORGANIZED_NEIGHBOR_SEARCH_H_ 00042 00043 #include <pcl/point_cloud.h> 00044 #include <pcl/point_types.h> 00045 #include <pcl/search/search.h> 00046 00047 #include <algorithm> 00048 #include <math.h> 00049 #include <queue> 00050 #include <vector> 00051 00052 namespace pcl 00053 { 00054 namespace search 00055 { 00060 template<typename PointT> 00061 class OrganizedNeighbor : public pcl::search::Search<PointT> 00062 { 00063 // public typedefs 00064 typedef pcl::PointCloud<PointT> PointCloud; 00065 typedef boost::shared_ptr<PointCloud> PointCloudPtr; 00066 typedef boost::shared_ptr<const PointCloud> PointCloudConstPtr; 00067 typedef boost::shared_ptr<const std::vector<int> > IndicesConstPtr; 00068 00069 public: 00070 00072 OrganizedNeighbor () 00073 { 00074 max_distance_ = std::numeric_limits<double>::max (); 00075 horizontal_window_ = 0; 00076 vertical_window_ = 0; 00077 } 00078 00080 ~OrganizedNeighbor () 00081 { 00082 } 00083 00087 inline void 00088 setInputCloud (const PointCloudConstPtr &cloud) 00089 { 00090 if (input_ != cloud) 00091 input_ = cloud; 00092 } 00093 00095 PointCloudConstPtr 00096 getInputCloud () 00097 { 00098 return input_; 00099 } 00100 00102 inline double 00103 getMaxDistance () const 00104 { 00105 return (max_distance_); 00106 } 00107 00109 inline void 00110 setMaxDistance (double max_dist) 00111 { 00112 max_distance_ = max_dist; 00113 } 00114 00119 inline void 00120 setSearchWindow (int horizontal, int vertical) 00121 { 00122 horizontal_window_ = horizontal; 00123 vertical_window_ = vertical; 00124 } 00125 00129 void 00130 setSearchWindowAsK (int k); 00131 00133 int 00134 getHorizontalSearchWindow () const 00135 { 00136 return (horizontal_window_); 00137 } 00138 00140 int 00141 getVerticalSearchWindow () const 00142 { 00143 return (vertical_window_); 00144 } 00145 00154 int 00155 nearestKSearch (const PointT &p_q, int k, std::vector<int> &k_indices, 00156 std::vector<float> &k_sqr_distances) 00157 { 00158 PCL_ERROR ("[pcl::search::OrganizedNeighbor::approxNearestKSearch] Method not implemented!\n"); 00159 return (0); 00160 } 00161 00171 int 00172 nearestKSearch (int index, int k, std::vector<int> &k_indices, std::vector<float> &k_distances); 00173 00183 int 00184 nearestKSearch (const pcl::PointCloud<PointT> &cloud, int index, int k, 00185 std::vector<int> &k_indices, std::vector<float> &k_distances); 00186 00195 int 00196 radiusSearch (const pcl::PointCloud<PointT> &cloud, int index, double radius, 00197 std::vector<int> &k_indices, std::vector<float> &k_distances, 00198 int max_nn = INT_MAX); 00199 00207 int 00208 radiusSearch (int index, double radius, 00209 std::vector<int> &k_indices, std::vector<float> &k_distances, 00210 int max_nn = INT_MAX) const; 00211 00219 int 00220 radiusSearch (const PointT &p_q, double radius, 00221 std::vector<int> &k_indices, std::vector<float> &k_distances, 00222 int max_nn = INT_MAX) const 00223 { 00224 PCL_ERROR ("[pcl::search::OrganizedNeighbor::radiusSearch] Method not implemented!\n"); 00225 return (0); 00226 } 00227 00228 protected: 00230 virtual std::string 00231 getName () const 00232 { 00233 return ("Organized_Neighbor_Search"); 00234 } 00235 00237 int horizontal_window_;int vertical_window_;int min_pts_; 00238 00240 PointCloudConstPtr input_; 00241 00243 double max_distance_; 00244 }; 00245 } 00246 } 00247 00248 #endif 00249