Open3D (C++ API)
0.19.0
Toggle main menu visibility
Loading...
Searching...
No Matches
cpp
open3d
ml
impl
misc
NeighborSearchCommon.h
Go to the documentation of this file.
1
// ----------------------------------------------------------------------------
2
// - Open3D: www.open3d.org -
3
// ----------------------------------------------------------------------------
4
// Copyright (c) 2018-2024 www.open3d.org
5
// SPDX-License-Identifier: MIT
6
// ----------------------------------------------------------------------------
7
8
#pragma once
9
10
#include <nanoflann.hpp>
11
12
#include "
open3d/utility/MiniVec.h
"
13
14
namespace
open3d
{
15
namespace
ml
{
16
namespace
impl
{
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
32
HOST_DEVICE
inline
size_t
SpatialHash
(
const
utility::MiniVec<int, 3>
& xyz) {
33
return
SpatialHash
(xyz[0], xyz[1], xyz[2]);
34
}
35
41
template
<
class
TVecf>
42
HOST_DEVICE
inline
utility::MiniVec<int, 3>
ComputeVoxelIndex
(
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
53
template
<
class
T>
54
class
Adaptor
{
55
public
:
56
Adaptor
(
size_t
num_points,
const
T*
const
data)
57
: num_points(num_points), data(data) {}
58
59
inline
size_t
kdtree_get_point_count
()
const
{
return
num_points; }
60
61
inline
T
kdtree_get_pt
(
const
size_t
idx,
int
dim)
const
{
62
return
data[3 * idx + dim];
63
}
64
65
template
<
class
BBOX>
66
bool
kdtree_get_bbox
(BBOX&)
const
{
67
return
false
;
68
}
69
70
private
:
71
size_t
num_points;
72
const
T*
const
data
;
73
};
74
75
template
<
int
METRIC,
class
T>
76
struct
SelectNanoflannAdaptor
{};
77
78
template
<
class
T>
79
struct
SelectNanoflannAdaptor
<
L2
, T> {
80
typedef
nanoflann::L2_Adaptor<T, Adaptor<T>>
Adaptor_t
;
81
};
82
83
template
<
class
T>
84
struct
SelectNanoflannAdaptor
<
L1
, T> {
85
typedef
nanoflann::L1_Adaptor<T, Adaptor<T>>
Adaptor_t
;
86
};
87
88
}
// namespace impl
89
}
// namespace ml
90
}
// namespace open3d
MiniVec.h
open3d::ml::impl::Adaptor::Adaptor
Adaptor(size_t num_points, const T *const data)
Definition
NeighborSearchCommon.h:56
open3d::ml::impl::Adaptor::kdtree_get_point_count
size_t kdtree_get_point_count() const
Definition
NeighborSearchCommon.h:59
open3d::ml::impl::Adaptor::kdtree_get_bbox
bool kdtree_get_bbox(BBOX &) const
Definition
NeighborSearchCommon.h:66
open3d::ml::impl::Adaptor::kdtree_get_pt
T kdtree_get_pt(const size_t idx, int dim) const
Definition
NeighborSearchCommon.h:61
HOST_DEVICE
#define HOST_DEVICE
Definition
NeighborSearchCommon.h:24
open3d::data
Definition
Dataset.cpp:18
open3d::ml::impl
Definition
ContinuousConv.h:16
open3d::ml::impl::SpatialHash
HOST_DEVICE size_t SpatialHash(int x, int y, int z)
Spatial hashing function for integer coordinates.
Definition
NeighborSearchCommon.h:28
open3d::ml::impl::Metric
Metric
Supported metrics.
Definition
NeighborSearchCommon.h:19
open3d::ml::impl::Linf
@ Linf
Definition
NeighborSearchCommon.h:19
open3d::ml::impl::L1
@ L1
Definition
NeighborSearchCommon.h:19
open3d::ml::impl::L2
@ L2
Definition
NeighborSearchCommon.h:19
open3d::ml::impl::ComputeVoxelIndex
HOST_DEVICE utility::MiniVec< int, 3 > ComputeVoxelIndex(const TVecf &pos, const typename TVecf::Scalar_t &inv_voxel_size)
Definition
NeighborSearchCommon.h:42
open3d::ml
Definition
Cloud.cpp:53
open3d
Definition
PinholeCameraIntrinsic.cpp:16
open3d::ml::impl::SelectNanoflannAdaptor< L1, T >::Adaptor_t
nanoflann::L1_Adaptor< T, Adaptor< T > > Adaptor_t
Definition
NeighborSearchCommon.h:85
open3d::ml::impl::SelectNanoflannAdaptor< L2, T >::Adaptor_t
nanoflann::L2_Adaptor< T, Adaptor< T > > Adaptor_t
Definition
NeighborSearchCommon.h:80
open3d::ml::impl::SelectNanoflannAdaptor
Definition
NeighborSearchCommon.h:76
open3d::utility::MiniVec
Definition
MiniVec.h:24
Generated by
1.17.0