11 #ifndef CUBBYFLOW_CUDA_POINT_HASH_GRID_SEARCHER2_HPP 12 #define CUBBYFLOW_CUDA_POINT_HASH_GRID_SEARCHER2_HPP 14 #ifdef CUBBYFLOW_USE_CUDA 19 #include <cuda_runtime.h> 30 class CUDAPointHashGridSearcher2 final
38 HashUtils() =
default;
40 inline CUBBYFLOW_CUDA_HOST_DEVICE HashUtils(
float gridSpacing,
43 inline CUBBYFLOW_CUDA_HOST_DEVICE
void GetNearbyKeys(
44 float2 position, uint32_t* nearbyKeys)
const;
46 inline CUBBYFLOW_CUDA_HOST_DEVICE int2
47 GetBucketIndex(float2 position)
const;
49 inline CUBBYFLOW_CUDA_HOST_DEVICE uint32_t
50 GetHashKeyFromBucketIndex(int2 bucketIndex)
const;
52 inline CUBBYFLOW_CUDA_HOST_DEVICE uint32_t
53 GetHashKeyFromPosition(float2 position)
const;
61 template <
typename Callback>
62 class ForEachNearbyPointFunc
65 inline CUBBYFLOW_CUDA_HOST_DEVICE ForEachNearbyPointFunc(
66 float r,
float gridSpacing, uint2 resolution,
const uint32_t* sit,
67 const uint32_t* eit,
const uint32_t* si,
const float2* p,
68 const float2* o, Callback cb);
70 template <
typename Index>
71 inline CUBBYFLOW_CUDA_HOST_DEVICE
void operator()(Index idx);
74 HashUtils m_hashUtils;
76 const uint32_t* m_startIndexTable;
77 const uint32_t* m_endIndexTable;
78 const uint32_t* m_sortedIndices;
79 const float2* m_points;
80 const float2* m_origins;
94 CUDAPointHashGridSearcher2(
const uint2& resolution,
float gridSpacing);
107 CUDAPointHashGridSearcher2(uint32_t resolutionX, uint32_t resolutionY,
111 CUDAPointHashGridSearcher2(
const CUDAPointHashGridSearcher2& other);
114 CUDAPointHashGridSearcher2(CUDAPointHashGridSearcher2&& other) noexcept;
117 ~CUDAPointHashGridSearcher2() =
default;
120 CUDAPointHashGridSearcher2& operator=(
121 const CUDAPointHashGridSearcher2& other);
124 CUDAPointHashGridSearcher2& operator=(
125 CUDAPointHashGridSearcher2&& other) noexcept;
134 void Build(
const ConstCUDAArrayView1<float2>& points);
144 template <
typename Callback>
145 void ForEachNearbyPoint(
const ConstCUDAArrayView1<float2>& origins,
146 float radius, Callback callback)
const;
148 float GridSpacing()
const;
152 ConstCUDAArrayView1<float2> SortedPoints()
const;
162 ConstCUDAArrayView1<uint32_t> Keys()
const;
187 ConstCUDAArrayView1<uint32_t> StartIndexTable()
const;
212 ConstCUDAArrayView1<uint32_t> EndIndexTable()
const;
224 ConstCUDAArrayView1<uint32_t> SortedIndices()
const;
227 void Set(
const CUDAPointHashGridSearcher2& other);
230 static Builder GetBuilder();
233 float m_gridSpacing = 1.0f;
235 uint2 m_resolution = make_uint2(1, 1);
236 CUDAArray1<float2> m_points;
237 CUDAArray1<uint32_t> m_keys;
238 CUDAArray1<uint32_t> m_startIndexTable;
239 CUDAArray1<uint32_t> m_endIndexTable;
240 CUDAArray1<uint32_t> m_sortedIndices;
244 using CUDAPointHashGridSearcher2Ptr =
245 std::shared_ptr<CUDAPointHashGridSearcher2>;
251 class CUDAPointHashGridSearcher2::Builder final
255 Builder& WithResolution(
const Vector2UZ& resolution);
258 Builder& WithGridSpacing(
float gridSpacing);
261 CUDAPointHashGridSearcher2 Build()
const;
264 CUDAPointHashGridSearcher2Ptr MakeShared()
const;
268 float m_gridSpacing = 1.0f;
Vector2< size_t > Vector2UZ
Definition: Matrix.hpp:776
Definition: pybind11Utils.hpp:20