Open3D (C++ API)  0.18.0+252c867
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"
14 #include "open3d/utility/Logging.h"
15 
16 namespace open3d {
17 namespace core {
18 namespace nns {
19 
20 #ifdef BUILD_CUDA_MODULE
21 template <class T, class TIndex>
22 void 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 
32 class KnnIndex : public NNSIndex {
33 public:
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 
46 public:
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 {
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 
85 protected:
87 };
88 
89 } // namespace nns
90 } // namespace core
91 } // namespace open3d
#define LogError(...)
Definition: Logging.h:48
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
KnnIndex(const KnnIndex &)=delete
KnnIndex & operator=(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
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 double radius, bool sort) const override
Definition: KnnIndex.h:72
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