Point Cloud Library (PCL)  1.14.1-dev
internal.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_INTERNAL_HPP_
38 #define PCL_GPU_OCTREE_INTERNAL_HPP_
39 
40 #include <pcl/gpu/containers/device_array.h>
41 #include <pcl/gpu/octree/device_format.hpp>
42 #include <pcl/gpu/utils/safe_call.hpp>
43 
44 namespace pcl
45 {
46  namespace device
47  {
48  struct OctreeGlobal
49  {
50  int *nodes;
51  int *codes;
52  int *begs;
53  int *ends;
54 
55  int *nodes_num;
56 
57  int *parent;
58 
59  OctreeGlobal() : nodes(nullptr), codes(nullptr), begs(nullptr), ends(nullptr), nodes_num(nullptr), parent(nullptr) {}
60  };
61 
63  {
64  float3 minp, maxp;
65  };
66 
67 
68  class OctreeImpl
69  {
70  public:
71  using PointType = float4;
73 
76 
82 
84 
85  static void get_gpu_arch_compiled_for(int& bin, int& ptr);
86 
87  OctreeImpl() {};
88 
89  void setCloud(const PointCloud& input_points);
90  void build();
91  void radiusSearchHost(const PointType& center, float radius, std::vector<int>& out, int max_nn) const;
92  void approxNearestSearchHost(const PointType& query, int& out_index, float& sqr_dist) const;
93 
94  void radiusSearch(const Queries& queries, float radius, NeighborIndices& results);
95  void radiusSearch(const Queries& queries, const Radiuses& radiuses, NeighborIndices& results);
96 
97  void radiusSearch(const Queries& queries, const Indices& indices, float radius, NeighborIndices& results);
98 
99  void approxNearestSearch(const Queries& queries, NeighborIndices& results, BatchResultSqrDists& sqr_distance) const;
100 
101  void nearestKSearchBatch(const Queries& queries, int k, NeighborIndices& results, BatchResultSqrDists& sqr_distances) const;
102 
103  //just reference
105 
106  // data
110 
112 
113  //storage
115 
117  {
118  std::vector<int> nodes;
119  std::vector<int> codes;
120 
121  std::vector<int> begs;
122  std::vector<int> ends;
123 
124 
125  std::vector<int> indices;
126 
127  std::vector<float> points_sorted;
129 
131 
133 
134 
136  private:
137  template<typename BatchType>
138  void radiusSearchEx(BatchType& batch, const Queries& queries, NeighborIndices& results);
139  };
140 
141  void bruteForceRadiusSearch(const OctreeImpl::PointCloud& cloud, const OctreeImpl::PointType& query, float radius, DeviceArray<int>& result, DeviceArray<int>& buffer);
142 
143  }
144 }
145 
146 #endif /* PCL_GPU_OCTREE_INTERNAL_HPP_ */
OctreeGlobalWithBox octreeGlobal
Definition: internal.hpp:111
struct pcl::device::OctreeImpl::OctreeDataHost host_octree
void radiusSearch(const Queries &queries, float radius, NeighborIndices &results)
DeviceArray2D< float > points_sorted
Definition: internal.hpp:107
DeviceArray< int > codes
Definition: internal.hpp:108
static void get_gpu_arch_compiled_for(int &bin, int &ptr)
void nearestKSearchBatch(const Queries &queries, int k, NeighborIndices &results, BatchResultSqrDists &sqr_distances) const
void radiusSearchHost(const PointType &center, float radius, std::vector< int > &out, int max_nn) const
DeviceArray2D< int > storage
Definition: internal.hpp:114
void setCloud(const PointCloud &input_points)
DeviceArray< int > indices
Definition: internal.hpp:109
void approxNearestSearchHost(const PointType &query, int &out_index, float &sqr_dist) const
void radiusSearch(const Queries &queries, const Radiuses &radiuses, NeighborIndices &results)
DeviceArray< PointType > PointArray
Definition: internal.hpp:72
void radiusSearch(const Queries &queries, const Indices &indices, float radius, NeighborIndices &results)
void approxNearestSearch(const Queries &queries, NeighborIndices &results, BatchResultSqrDists &sqr_distance) const
DeviceArray2D class
Definition: device_array.h:188
DeviceArray class
Definition: device_array.h:54
void bruteForceRadiusSearch(const OctreeImpl::PointCloud &cloud, const OctreeImpl::PointType &query, float radius, DeviceArray< int > &result, DeviceArray< int > &buffer)