Point Cloud Library (PCL) 1.15.0
Loading...
Searching...
No Matches
io.hpp
1/*
2 * Software License Agreement (BSD License)
3 *
4 * Point Cloud Library (PCL) - www.pointclouds.org
5 * Copyright (c) 2010-2011, Willow Garage, 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 Willow Garage, Inc. 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 * $Id$
37 *
38 */
39
40#ifndef PCL_KDTREE_IO_IMPL_HPP_
41#define PCL_KDTREE_IO_IMPL_HPP_
42
43#include <pcl/kdtree/io.h>
44
45//////////////////////////////////////////////////////////////////////////////////////////////
46template <typename Point1T, typename Point2T> void
48 const typename pcl::PointCloud<Point1T>::ConstPtr &cloud_in,
49 const typename pcl::PointCloud<Point2T>::ConstPtr &cloud_ref,
50 Indices &indices)
51{
53 tree.setInputCloud (cloud_ref);
54
55 Indices nn_idx (1);
56 std::vector<float> nn_dists (1);
57 indices.resize (cloud_in->size ());
58 for (std::size_t i = 0; i < cloud_in->size (); ++i)
59 {
60 tree.nearestKSearchT ((*cloud_in)[i], 1, nn_idx, nn_dists);
61 indices[i] = nn_idx[0];
62 }
63}
64
65//////////////////////////////////////////////////////////////////////////////////////////////
66template <typename PointT> void
68 const typename pcl::PointCloud<PointT>::ConstPtr &cloud_in,
69 const typename pcl::PointCloud<PointT>::ConstPtr &cloud_ref,
70 Indices &indices)
71{
73 tree.setInputCloud (cloud_ref);
74
75 Indices nn_idx (1);
76 std::vector<float> nn_dists (1);
77 indices.resize (cloud_in->size ());
78 for (std::size_t i = 0; i < cloud_in->size (); ++i)
79 {
80 tree.nearestKSearch (*cloud_in, i, 1, nn_idx, nn_dists);
81 indices[i] = nn_idx[0];
82 }
83}
84
85#endif // PCL_KDTREE_IO_IMPL_H_
86
KdTreeFLANN is a generic type of 3D spatial locator using kD-tree structures.
int nearestKSearch(const PointT &point, unsigned int k, Indices &k_indices, std::vector< float > &k_sqr_distances) const override
Search for k-nearest neighbors for the given query point.
void setInputCloud(const PointCloudConstPtr &cloud, const IndicesConstPtr &indices=IndicesConstPtr()) override
Provide a pointer to the input dataset.
int nearestKSearchT(const PointTDiff &point, unsigned int k, Indices &k_indices, std::vector< float > &k_sqr_distances) const
Search for k-nearest neighbors for the given query point.
Definition kdtree.h:173
std::size_t size() const
shared_ptr< const PointCloud< PointT > > ConstPtr
void getApproximateIndices(const typename pcl::PointCloud< PointT >::ConstPtr &cloud_in, const typename pcl::PointCloud< PointT >::ConstPtr &cloud_ref, Indices &indices)
Get a set of approximate indices for a given point cloud into a reference point cloud.
Definition io.hpp:67
IndicesAllocator<> Indices
Type used for indices in PCL.
Definition types.h:133