ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
KnnIndex.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 #include <Logging.h>
11 
12 #include "cloudViewer/core/Dtype.h"
16 
17 namespace cloudViewer {
18 namespace core {
19 namespace nns {
20 
21 #ifdef BUILD_CUDA_MODULE
22 template <class T, class TIndex>
23 void KnnSearchCUDA(const Tensor& points,
24  const Tensor& points_row_splits,
25  const Tensor& queries,
26  const Tensor& queries_row_splits,
27  int knn,
28  Tensor& neighbors_index,
29  Tensor& neighbors_row_splits,
30  Tensor& neighbors_distance);
31 #endif
32 
33 class KnnIndex : public NNSIndex {
34 public:
35  KnnIndex();
36 
41  KnnIndex(const Tensor& dataset_points);
42  KnnIndex(const Tensor& dataset_points, const Dtype& index_dtype);
43  ~KnnIndex();
44  KnnIndex(const KnnIndex&) = delete;
45  KnnIndex& operator=(const KnnIndex&) = delete;
46 
47 public:
48  bool SetTensorData(const Tensor& dataset_points,
49  const Dtype& index_dtype = core::Int64) override;
50  bool SetTensorData(const Tensor& dataset_points,
51  const Tensor& points_row_splits,
52  const Dtype& index_dtype = core::Int64);
53  bool SetTensorData(const Tensor& dataset_points,
54  double radius,
55  const Dtype& index_dtype = core::Int64) override {
57  "[KnnIndex::SetTensorData with radius not implemented.");
58  }
59 
60  std::pair<Tensor, Tensor> SearchKnn(const Tensor& query_points,
61  int knn) const override;
62 
63  std::pair<Tensor, Tensor> SearchKnn(const Tensor& query_points,
64  const Tensor& queries_row_splits,
65  int knn) const;
66 
67  std::tuple<Tensor, Tensor, Tensor> SearchRadius(const Tensor& query_points,
68  const Tensor& radii,
69  bool sort) const override {
70  utility::LogError("KnnIndex::SearchRadius not implemented.");
71  }
72 
73  std::tuple<Tensor, Tensor, Tensor> SearchRadius(const Tensor& query_points,
74  const double radius,
75  bool sort) const override {
76  utility::LogError("KnnIndex::SearchRadius not implemented.");
77  }
78 
79  std::tuple<Tensor, Tensor, Tensor> SearchHybrid(
80  const Tensor& query_points,
81  const double radius,
82  const int max_knn) const override {
83  utility::LogError("KnnIndex::SearchHybrid not implemented.");
84  }
85 
86 protected:
88 };
89 
90 } // namespace nns
91 } // namespace core
92 } // namespace cloudViewer
int points
KnnIndex & operator=(const KnnIndex &)=delete
std::tuple< Tensor, Tensor, Tensor > SearchRadius(const Tensor &query_points, const Tensor &radii, bool sort) const override
Definition: KnnIndex.h:67
bool SetTensorData(const Tensor &dataset_points, const Dtype &index_dtype=core::Int64) override
Definition: KnnIndex.cpp:32
std::tuple< Tensor, Tensor, Tensor > SearchHybrid(const Tensor &query_points, const double radius, const int max_knn) const override
Definition: KnnIndex.h:79
bool SetTensorData(const Tensor &dataset_points, double radius, const Dtype &index_dtype=core::Int64) override
Definition: KnnIndex.h:53
KnnIndex(const KnnIndex &)=delete
std::tuple< Tensor, Tensor, Tensor > SearchRadius(const Tensor &query_points, const double radius, bool sort) const override
Definition: KnnIndex.h:73
std::pair< Tensor, Tensor > SearchKnn(const Tensor &query_points, int knn) const override
Definition: KnnIndex.cpp:80
#define LogError(...)
Definition: Logging.h:60
const Dtype Int64
Definition: Dtype.cpp:47
Generic file read and write utility for python interface.
std::vector< PointCoordinateType > radii
Definition: qM3C2Tools.cpp:42