Open3D (C++ API)  0.17.0
Loading...
Searching...
No Matches
KnnIndex.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 "open3d/core/Dtype.h"
11#include "open3d/core/Tensor.h"
15
16namespace open3d {
17namespace core {
18namespace nns {
19
20#ifdef BUILD_CUDA_MODULE
21template <class T, class TIndex>
22void KnnSearchCUDA(const Tensor& points,
23 const Tensor& points_row_splits,
24 const Tensor& queries,
25 const Tensor& queries_row_splits,
26 int knn,
27 Tensor& neighbors_index,
28 Tensor& neighbors_row_splits,
29 Tensor& neighbors_distance);
30#endif
31
32class KnnIndex : public NNSIndex {
33public:
34 KnnIndex();
35
40 KnnIndex(const Tensor& dataset_points);
41 KnnIndex(const Tensor& dataset_points, const Dtype& index_dtype);
42 ~KnnIndex();
43 KnnIndex(const KnnIndex&) = delete;
44 KnnIndex& operator=(const KnnIndex&) = delete;
45
46public:
47 bool SetTensorData(const Tensor& dataset_points,
48 const Dtype& index_dtype = core::Int64) override;
49 bool SetTensorData(const Tensor& dataset_points,
50 const Tensor& points_row_splits,
51 const Dtype& index_dtype = core::Int64);
52 bool SetTensorData(const Tensor& dataset_points,
53 double radius,
54 const Dtype& index_dtype = core::Int64) override {
55 utility::LogError(
56 "[KnnIndex::SetTensorData with radius not implemented.");
57 }
58
59 std::pair<Tensor, Tensor> SearchKnn(const Tensor& query_points,
60 int knn) const override;
61
62 std::pair<Tensor, Tensor> SearchKnn(const Tensor& query_points,
63 const Tensor& queries_row_splits,
64 int knn) const;
65
66 std::tuple<Tensor, Tensor, Tensor> SearchRadius(const Tensor& query_points,
67 const Tensor& radii,
68 bool sort) const override {
69 utility::LogError("KnnIndex::SearchRadius not implemented.");
70 }
71
72 std::tuple<Tensor, Tensor, Tensor> SearchRadius(const Tensor& query_points,
73 const double radius,
74 bool sort) const override {
75 utility::LogError("KnnIndex::SearchRadius not implemented.");
76 }
77
78 std::tuple<Tensor, Tensor, Tensor> SearchHybrid(
79 const Tensor& query_points,
80 const double radius,
81 const int max_knn) const override {
82 utility::LogError("KnnIndex::SearchHybrid not implemented.");
83 }
84
85protected:
87};
88
89} // namespace nns
90} // namespace core
91} // namespace open3d
Definition Dtype.h:20
Definition Tensor.h:32
Definition KnnIndex.h:32
std::pair< Tensor, Tensor > SearchKnn(const Tensor &query_points, int knn) const override
Definition KnnIndex.cpp:79
std::tuple< Tensor, Tensor, Tensor > SearchRadius(const Tensor &query_points, const double radius, bool sort) const override
Definition KnnIndex.h:72
KnnIndex(const KnnIndex &)=delete
KnnIndex()
Definition KnnIndex.cpp:19
std::tuple< Tensor, Tensor, Tensor > SearchHybrid(const Tensor &query_points, const double radius, const int max_knn) const override
Definition KnnIndex.h:78
bool SetTensorData(const Tensor &dataset_points, const Dtype &index_dtype=core::Int64) override
Definition KnnIndex.cpp:31
KnnIndex & operator=(const KnnIndex &)=delete
Tensor points_row_splits_
Definition KnnIndex.h:86
~KnnIndex()
Definition KnnIndex.cpp:29
bool SetTensorData(const Tensor &dataset_points, double radius, const Dtype &index_dtype=core::Int64) override
Definition KnnIndex.h:52
std::tuple< Tensor, Tensor, Tensor > SearchRadius(const Tensor &query_points, const Tensor &radii, bool sort) const override
Definition KnnIndex.h:66
Definition NNSIndex.h:21
int points
Definition FilePCD.cpp:54
const Dtype Int64
Definition Dtype.cpp:47
Definition PinholeCameraIntrinsic.cpp:16