Point Cloud Library (PCL) 1.12.0
Loading...
Searching...
No Matches
kdtree.hpp
1/*
2 * Software License Agreement (BSD License)
3 *
4 * Point Cloud Library (PCL) - www.pointclouds.org
5 * Copyright (c) 2012-, Open Perception, Inc.
6 *
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 *
13 * * Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * * Redistributions in binary form must reproduce the above
16 * copyright notice, this list of conditions and the following
17 * disclaimer in the documentation and/or other materials provided
18 * with the distribution.
19 * * Neither the name of the copyright holder(s) nor the names of its
20 * contributors may be used to endorse or promote products derived
21 * from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
35 *
36 */
37
38#ifndef PCL_SEARCH_KDTREE_IMPL_HPP_
39#define PCL_SEARCH_KDTREE_IMPL_HPP_
40
41#include <pcl/search/kdtree.h>
42
43///////////////////////////////////////////////////////////////////////////////////////////
44template <typename PointT, class Tree>
46 : pcl::search::Search<PointT> ("KdTree", sorted)
47 , tree_ (new Tree (sorted))
48{
49}
50
51///////////////////////////////////////////////////////////////////////////////////////////
52template <typename PointT, class Tree> void
58
59///////////////////////////////////////////////////////////////////////////////////////////
60template <typename PointT, class Tree> void
62{
63 sorted_results_ = sorted_results;
64 tree_->setSortedResults (sorted_results);
65}
66
67///////////////////////////////////////////////////////////////////////////////////////////
68template <typename PointT, class Tree> void
70{
71 tree_->setEpsilon (eps);
72}
73
74///////////////////////////////////////////////////////////////////////////////////////////
75template <typename PointT, class Tree> void
77 const PointCloudConstPtr& cloud,
78 const IndicesConstPtr& indices)
79{
80 tree_->setInputCloud (cloud, indices);
81 input_ = cloud;
82 indices_ = indices;
83}
84
85///////////////////////////////////////////////////////////////////////////////////////////
86template <typename PointT, class Tree> int
88 const PointT &point, int k, Indices &k_indices,
89 std::vector<float> &k_sqr_distances) const
90{
91 return (tree_->nearestKSearch (point, k, k_indices, k_sqr_distances));
92}
93
94///////////////////////////////////////////////////////////////////////////////////////////
95template <typename PointT, class Tree> int
97 const PointT& point, double radius,
98 Indices &k_indices, std::vector<float> &k_sqr_distances,
99 unsigned int max_nn) const
100{
101 return (tree_->radiusSearch (point, radius, k_indices, k_sqr_distances, max_nn));
102}
103
104#define PCL_INSTANTIATE_KdTree(T) template class PCL_EXPORTS pcl::search::KdTree<T>;
105
106#endif //#ifndef _PCL_SEARCH_KDTREE_IMPL_HPP_
107
108
Iterator class for point clouds with or without given indices.
int nearestKSearch(const PointT &point, int k, Indices &k_indices, std::vector< float > &k_sqr_distances) const override
Search for the k-nearest neighbors for the given query point.
Definition kdtree.hpp:87
void setEpsilon(float eps)
Set the search epsilon precision (error bound) for nearest neighbors searches.
Definition kdtree.hpp:69
void setInputCloud(const PointCloudConstPtr &cloud, const IndicesConstPtr &indices=IndicesConstPtr()) override
Provide a pointer to the input dataset.
Definition kdtree.hpp:76
void setSortedResults(bool sorted_results) override
Sets whether the results have to be sorted or not.
Definition kdtree.hpp:61
typename Search< PointT >::PointCloudConstPtr PointCloudConstPtr
Definition kdtree.h:65
typename PointRepresentation< PointT >::ConstPtr PointRepresentationConstPtr
Definition kdtree.h:80
void setPointRepresentation(const PointRepresentationConstPtr &point_representation)
Provide a pointer to the point representation to use to convert points into k-D vectors.
Definition kdtree.hpp:53
KdTree(bool sorted=true)
Constructor for KdTree.
Definition kdtree.hpp:45
int radiusSearch(const PointT &point, double radius, Indices &k_indices, std::vector< float > &k_sqr_distances, unsigned int max_nn=0) const override
Search for all the nearest neighbors of the query point in a given radius.
Definition kdtree.hpp:96
Generic search class.
Definition search.h:75
pcl::IndicesConstPtr IndicesConstPtr
Definition search.h:85
IndicesAllocator<> Indices
Type used for indices in PCL.
Definition types.h:133
A point structure representing Euclidean xyz coordinates, and the RGB color.