11 #ifndef CUBBYFLOW_CUDA_POINT_HASH_GRID_SEARCHER3_HPP 12 #define CUBBYFLOW_CUDA_POINT_HASH_GRID_SEARCHER3_HPP 14 #ifdef CUBBYFLOW_USE_CUDA 19 #include <cuda_runtime.h> 30 class CUDAPointHashGridSearcher3 final
38 HashUtils() =
default;
40 inline CUBBYFLOW_CUDA_HOST_DEVICE HashUtils(
float gridSpacing,
43 inline CUBBYFLOW_CUDA_HOST_DEVICE
void GetNearbyKeys(
44 float4 position, uint32_t* nearbyKeys)
const;
46 inline CUBBYFLOW_CUDA_HOST_DEVICE int3
47 GetBucketIndex(float4 position)
const;
49 inline CUBBYFLOW_CUDA_HOST_DEVICE uint32_t
50 GetHashKeyFromBucketIndex(int3 bucketIndex)
const;
52 inline CUBBYFLOW_CUDA_HOST_DEVICE uint32_t
53 GetHashKeyFromPosition(float4 position)
const;
60 template <
typename Callback>
61 class ForEachNearbyPointFunc
64 inline CUBBYFLOW_CUDA_HOST_DEVICE ForEachNearbyPointFunc(
65 float r,
float gridSpacing, uint3 resolution,
const uint32_t* sit,
66 const uint32_t* eit,
const uint32_t* si,
const float4* p,
67 const float4* o, Callback cb);
69 template <
typename Index>
70 inline CUBBYFLOW_CUDA_HOST_DEVICE
void operator()(Index idx);
73 HashUtils m_hashUtils;
75 const uint32_t* m_startIndexTable;
76 const uint32_t* m_endIndexTable;
77 const uint32_t* m_sortedIndices;
78 const float4* m_points;
79 const float4* m_origins;
93 CUDAPointHashGridSearcher3(
const uint3& resolution,
float gridSpacing);
107 CUDAPointHashGridSearcher3(uint32_t resolutionX, uint32_t resolutionY,
108 uint32_t resolutionZ,
float gridSpacing);
111 CUDAPointHashGridSearcher3(
const CUDAPointHashGridSearcher3& other);
114 CUDAPointHashGridSearcher3(CUDAPointHashGridSearcher3&& other) noexcept;
117 ~CUDAPointHashGridSearcher3() =
default;
120 CUDAPointHashGridSearcher3& operator=(
121 const CUDAPointHashGridSearcher3& other);
124 CUDAPointHashGridSearcher3& operator=(
125 CUDAPointHashGridSearcher3&& other) noexcept;
134 void Build(
const ConstCUDAArrayView1<float4>& points);
144 template <
typename Callback>
145 void ForEachNearbyPoint(
const ConstCUDAArrayView1<float4>& origins,
146 float radius, Callback callback)
const;
148 float GridSpacing()
const;
152 ConstCUDAArrayView1<float4> 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 CUDAPointHashGridSearcher3& other);
230 static Builder GetBuilder();
233 float m_gridSpacing = 1.0f;
234 uint3 m_resolution = make_uint3(1, 1, 1);
235 CUDAArray1<float4> m_points;
236 CUDAArray1<uint32_t> m_keys;
237 CUDAArray1<uint32_t> m_startIndexTable;
238 CUDAArray1<uint32_t> m_endIndexTable;
239 CUDAArray1<uint32_t> m_sortedIndices;
243 using CUDAPointHashGridSearcher3Ptr =
244 std::shared_ptr<CUDAPointHashGridSearcher3>;
250 class CUDAPointHashGridSearcher3::Builder final
254 Builder& WithResolution(
const Vector3UZ& resolution);
257 Builder& WithGridSpacing(
float gridSpacing);
260 CUDAPointHashGridSearcher3 Build()
const;
263 CUDAPointHashGridSearcher3Ptr MakeShared()
const;
266 float m_gridSpacing = 1.0f;
Definition: pybind11Utils.hpp:20
Vector3< size_t > Vector3UZ
Definition: Matrix.hpp:789