Point Cloud Library (PCL)  1.9.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() {};
89 
90  void setCloud(const PointCloud& input_points);
91  void build();
92  void radiusSearchHost(const PointType& center, float radius, std::vector<int>& out, int max_nn) const;
93  void approxNearestSearchHost(const PointType& query, int& out_index, float& sqr_dist) const;
94 
95  void radiusSearch(const Queries& queries, float radius, NeighborIndices& results);
96  void radiusSearch(const Queries& queries, const Radiuses& radiuses, NeighborIndices& results);
97 
98  void radiusSearch(const Queries& queries, const Indices& indices, float radius, NeighborIndices& results);
99 
100  void approxNearestSearch(const Queries& queries, NeighborIndices& results) const;
101 
102  void nearestKSearchBatch(const Queries& queries, int k, NeighborIndices& results) const;
103 
104  //just reference
106 
107  // data
111 
113 
114  //storage
116 
118  {
119  std::vector<int> nodes;
120  std::vector<int> codes;
121 
122  std::vector<int> begs;
123  std::vector<int> ends;
124 
125 
126  std::vector<int> indices;
127 
128  std::vector<float> points_sorted;
130 
132 
133  } host_octree;
134 
135 
136  void internalDownload();
137  private:
138  template<typename BatchType>
139  void radiusSearchEx(BatchType& batch, const Queries& queries, NeighborIndices& results);
140  };
141 
142  void bruteForceRadiusSearch(const OctreeImpl::PointCloud& cloud, const OctreeImpl::PointType& query, float radius, DeviceArray<int>& result, DeviceArray<int>& buffer);
143 
144  }
145 }
146 
147 #endif /* PCL_GPU_OCTREE_INTERNAL_HPP_ */
This file defines compatibility wrappers for low level I/O functions.
Definition: convolution.h:45
DeviceArray2D class
Definition: device_array.h:153
DeviceArray class
Definition: device_array.h:56
DeviceArray2D< int > storage
Definition: internal.hpp:115
OctreeGlobalWithBox octreeGlobal
Definition: internal.hpp:112
void bruteForceRadiusSearch(const OctreeImpl::PointCloud &cloud, const OctreeImpl::PointType &query, float radius, DeviceArray< int > &result, DeviceArray< int > &buffer)
DeviceArray2D< float > points_sorted
Definition: internal.hpp:108
DeviceArray< int > codes
Definition: internal.hpp:109
DeviceArray< int > indices
Definition: internal.hpp:110