Point Cloud Library (PCL) 1.12.0
Loading...
Searching...
No Matches
octree.hpp
1/*
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2011, Willow Garage, Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
17 * * Neither the name of Willow Garage, Inc. nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 *
34 * Author: Anatoly Baskeheev, Itseez Ltd, (myname.mysurname@mycompany.com)
35 */
36
37#ifndef _PCL_GPU_OCTREE_
38#define _PCL_GPU_OCTREE_
39
40#include <vector>
41
42#include <pcl/memory.h>
43#include <pcl/point_types.h>
44#include <pcl/pcl_macros.h>
45#include <pcl/gpu/containers/device_array.h>
46#include <pcl/gpu/octree/device_format.hpp>
47
48namespace pcl
49{
50 namespace gpu
51 {
52 /**
53 * \brief Octree implementation on GPU. It suppors parallel building and parallel batch search as well .
54 * \author Anaoly Baksheev, Itseez, myname.mysurname@mycompany.com
55 */
56
57 class PCL_EXPORTS Octree
58 {
59 public:
60
61 /** \brief Default constructor.*/
63
64 /** \brief Denstructor.*/
65 virtual ~Octree();
66
67 /** \brief Types */
70
71 /** \brief Point typwe supported */
73
74 /** \brief Point cloud supported */
76
77 /** \brief Point Batch query cloud type */
79
80 /** \brief Point Radiuses for batch query */
82
83 /** \brief Point Indices for batch query */
85
86 /** \brief Point Sqrt distances array type */
88
90
91 /** \brief Sets cloud for which octree is built */
93
94 /** \brief Performs parallel octree building */
95 void build();
96
97 /** \brief Returns true if tree has been built */
98 bool isBuilt() const;
99
100 /** \brief Downloads Octree from GPU to search using CPU function. It use useful for single (not-batch) search */
102
103 /** \brief Performs search of all points within given radius on CPU. It call \a internalDownload if necessary
104 * \param[in] center center of sphere
105 * \param[in] radius radious of sphere
106 * \param[out] out indeces of points within give sphere
107 * \param[in] max_nn maximum numver of results returned
108 */
109 void radiusSearchHost(const PointType& center, float radius, std::vector<int>& out, int max_nn = INT_MAX);
110
111 /** \brief Performs approximate nearest neighbor search on CPU. It call \a internalDownload if necessary
112 * \param[in] query 3D point for which neighbour is be fetched
113 * \param[out] out_index neighbour index
114 * \param[out] sqr_dist square distance to the neighbour returned
115 */
117
118 /** \brief Performs batch radius search on GPU
119 * \param[in] centers array of centers
120 * \param[in] radius radius for all queries
121 * \param[in] max_results max number of returned points for each querey
122 * \param[out] result results packed to single array
123 */
124 void radiusSearch(const Queries& centers, float radius, int max_results, NeighborIndices& result) const;
125
126 /** \brief Performs batch radius search on GPU
127 * \param[in] centers array of centers
128 * \param[in] radiuses array of radiuses
129 * \param[in] max_results max number of returned points for each querey
130 * \param[out] result results packed to single array
131 */
133
134 /** \brief Performs batch radius search on GPU
135 * \param[in] centers array of centers
136 * \param[in] indices indices for centers array (only for these points search is performed)
137 * \param[in] radius radius for all queries
138 * \param[in] max_results max number of returned points for each querey
139 * \param[out] result results packed to single array
140 */
141 void radiusSearch(const Queries& centers, const Indices& indices, float radius, int max_results, NeighborIndices& result) const;
142
143 /** \brief Batch approximate nearest search on GPU
144 * \param[in] queries array of centers
145 * \param[out] result array of results ( one index for each query )
146 */
147 PCL_DEPRECATED(1, 14, "use approxNearestSearch() which returns square distances instead")
149
150 /** \brief Batch approximate nearest search on GPU
151 * \param[in] queries array of centers
152 * \param[out] result array of results ( one index for each query )
153 * \param[out] sqr_distance corresponding square distances to results from query point
154 */
156
157 /** \brief Batch exact k-nearest search on GPU for k == 1 only!
158 * \param[in] queries array of centers
159 * \param[in] k number of neighbors (only k == 1 is supported)
160 * \param[out] results array of results
161 */
162 void nearestKSearchBatch(const Queries& queries, int k, NeighborIndices& results) const;
163
164 /** \brief Batch exact k-nearest search on GPU for k == 1 only!
165 * \param[in] queries array of centers
166 * \param[in] k number of neighbors (only k == 1 is supported)
167 * \param[out] results array of results
168 * \param[out] sqr_distances square distances to results
169 */
171
172 /** \brief Desroys octree and release all resources */
173 void clear();
174 private:
175 void *impl;
176 bool built_;
177 };
178
179 /** \brief Performs brute force radius search on GPU
180 * \param[in] cloud cloud where to search
181 * \param[in] query query point
182 * \param[in] radius radius
183 * \param[out] result indeces of points within give sphere
184 * \param[in] buffer buffer for intermediate results. Keep reference to it between calls to eliminate internal allocations
185 */
186 PCL_EXPORTS void bruteForceRadiusSearchGPU(const Octree::PointCloud& cloud, const Octree::PointType& query, float radius, DeviceArray<int>& result, DeviceArray<int>& buffer);
187 }
188}
189
190#endif /* _PCL_GPU_OCTREE_ */
Iterator class for point clouds with or without given indices.
PointCloud represents the base class in PCL for storing collections of 3D points.
Octree implementation on GPU.
Definition octree.hpp:58
bool isBuilt() const
Returns true if tree has been built.
shared_ptr< Octree > Ptr
Types.
Definition octree.hpp:68
virtual ~Octree()
Denstructor.
void internalDownload()
Downloads Octree from GPU to search using CPU function.
void setCloud(const PointCloud &cloud_arg)
Sets cloud for which octree is built.
void radiusSearch(const Queries &centers, const Indices &indices, float radius, int max_results, NeighborIndices &result) const
Performs batch radius search on GPU.
void radiusSearchHost(const PointType &center, float radius, std::vector< int > &out, int max_nn=INT_MAX)
Performs search of all points within given radius on CPU.
Octree()
Default constructor.
const PointCloud * cloud_
Definition octree.hpp:89
void approxNearestSearchHost(const PointType &query, int &out_index, float &sqr_dist)
Performs approximate nearest neighbor search on CPU.
void radiusSearch(const Queries &centers, const Radiuses &radiuses, int max_results, NeighborIndices &result) const
Performs batch radius search on GPU.
void build()
Performs parallel octree building.
void radiusSearch(const Queries &centers, float radius, int max_results, NeighborIndices &result) const
Performs batch radius search on GPU.
Defines all the PCL implemented PointT point type structures.
Defines functions, macros and traits for allocating and using memory.
Defines all the PCL and non-PCL macros used.
#define PCL_DEPRECATED(Major, Minor, Message)
macro for compatibility across compilers and help remove old deprecated items for the Major....
Definition pcl_macros.h:156
A point structure representing Euclidean xyz coordinates.