Open3D (C++ API)  0.18.0+5c982c7
NeighborSearchCommon.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - Open3D: www.open3d.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2023 www.open3d.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 #include <memory>
11 
12 #include "open3d/utility/MiniVec.h"
13 
14 namespace open3d {
15 namespace core {
16 namespace nns {
17 
19 enum Metric { L1, L2, Linf };
20 
21 #ifdef __CUDACC__
22 #define HOST_DEVICE __host__ __device__
23 #else
24 #define HOST_DEVICE
25 #endif
26 
28 HOST_DEVICE inline size_t SpatialHash(int x, int y, int z) {
29  return x * 73856096 ^ y * 193649663 ^ z * 83492791;
30 }
31 
33  return SpatialHash(xyz[0], xyz[1], xyz[2]);
34 }
35 
41 template <class TVecf>
43  const TVecf &pos, const typename TVecf::Scalar_t &inv_voxel_size) {
44  TVecf ref_coord = pos * inv_voxel_size;
45 
46  utility::MiniVec<int, 3> voxel_index;
47  voxel_index = floor(ref_coord).template cast<int>();
48  return voxel_index;
49 }
50 #undef HOST_DEVICE
51 
55 };
56 
57 } // namespace nns
58 } // namespace core
59 } // namespace open3d
#define HOST_DEVICE
Definition: NeighborSearchCommon.h:24
Metric
Supported metrics.
Definition: NeighborSearchCommon.h:19
@ Linf
Definition: NeighborSearchCommon.h:19
@ L1
Definition: NeighborSearchCommon.h:19
@ L2
Definition: NeighborSearchCommon.h:19
HOST_DEVICE size_t SpatialHash(int x, int y, int z)
Spatial hashing function for integer coordinates.
Definition: NeighborSearchCommon.h:28
HOST_DEVICE utility::MiniVec< int, 3 > ComputeVoxelIndex(const TVecf &pos, const typename TVecf::Scalar_t &inv_voxel_size)
Definition: NeighborSearchCommon.h:42
FN_SPECIFIERS MiniVec< float, N > floor(const MiniVec< float, N > &a)
Definition: MiniVec.h:75
Definition: PinholeCameraIntrinsic.cpp:16
Base struct for NanoFlann index holder.
Definition: NeighborSearchCommon.h:53
virtual ~NanoFlannIndexHolderBase()
Definition: NeighborSearchCommon.h:54
Definition: MiniVec.h:24