Loading [MathJax]/extensions/TeX/AMSsymbols.js
Open3D (C++ API)  0.16.0
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
KnnIndex.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - Open3D: www.open3d.org -
3 // ----------------------------------------------------------------------------
4 // The MIT License (MIT)
5 //
6 // Copyright (c) 2018-2021 www.open3d.org
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to deal
10 // in the Software without restriction, including without limitation the rights
11 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 // copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 //
15 // The above copyright notice and this permission notice shall be included in
16 // all copies or substantial portions of the Software.
17 //
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 // IN THE SOFTWARE.
25 // ----------------------------------------------------------------------------
26 
27 #pragma once
28 
29 #include "open3d/core/Dtype.h"
30 #include "open3d/core/Tensor.h"
33 #include "open3d/utility/Logging.h"
34 
35 namespace open3d {
36 namespace core {
37 namespace nns {
38 
39 #ifdef BUILD_CUDA_MODULE
40 template <class T, class TIndex>
41 void KnnSearchCUDA(const Tensor& points,
42  const Tensor& points_row_splits,
43  const Tensor& queries,
44  const Tensor& queries_row_splits,
45  int knn,
46  Tensor& neighbors_index,
47  Tensor& neighbors_row_splits,
48  Tensor& neighbors_distance);
49 #endif
50 
51 class KnnIndex : public NNSIndex {
52 public:
53  KnnIndex();
54 
59  KnnIndex(const Tensor& dataset_points);
60  KnnIndex(const Tensor& dataset_points, const Dtype& index_dtype);
61  ~KnnIndex();
62  KnnIndex(const KnnIndex&) = delete;
63  KnnIndex& operator=(const KnnIndex&) = delete;
64 
65 public:
66  bool SetTensorData(const Tensor& dataset_points,
67  const Dtype& index_dtype = core::Int64) override;
68  bool SetTensorData(const Tensor& dataset_points,
69  const Tensor& points_row_splits,
70  const Dtype& index_dtype = core::Int64);
71  bool SetTensorData(const Tensor& dataset_points,
72  double radius,
73  const Dtype& index_dtype = core::Int64) override {
75  "[KnnIndex::SetTensorData with radius not implemented.");
76  }
77 
78  std::pair<Tensor, Tensor> SearchKnn(const Tensor& query_points,
79  int knn) const override;
80 
81  std::pair<Tensor, Tensor> SearchKnn(const Tensor& query_points,
82  const Tensor& queries_row_splits,
83  int knn) const;
84 
85  std::tuple<Tensor, Tensor, Tensor> SearchRadius(const Tensor& query_points,
86  const Tensor& radii,
87  bool sort) const override {
88  utility::LogError("KnnIndex::SearchRadius not implemented.");
89  }
90 
91  std::tuple<Tensor, Tensor, Tensor> SearchRadius(const Tensor& query_points,
92  const double radius,
93  bool sort) const override {
94  utility::LogError("KnnIndex::SearchRadius not implemented.");
95  }
96 
97  std::tuple<Tensor, Tensor, Tensor> SearchHybrid(
98  const Tensor& query_points,
99  const double radius,
100  const int max_knn) const override {
101  utility::LogError("KnnIndex::SearchHybrid not implemented.");
102  }
103 
104 protected:
106 };
107 
108 } // namespace nns
109 } // namespace core
110 } // namespace open3d
KnnIndex & operator=(const KnnIndex &)=delete
KnnIndex()
Definition: KnnIndex.cpp:38
bool SetTensorData(const Tensor &dataset_points, const Dtype &index_dtype=core::Int64) override
Definition: KnnIndex.cpp:50
Tensor points_row_splits_
Definition: KnnIndex.h:105
~KnnIndex()
Definition: KnnIndex.cpp:48
const Dtype Int64
Definition: Dtype.cpp:66
std::pair< Tensor, Tensor > SearchKnn(const Tensor &query_points, int knn) const override
Definition: KnnIndex.cpp:98
Definition: Dtype.h:39
Definition: NNSIndex.h:40
int points
Definition: FilePCD.cpp:73
std::tuple< Tensor, Tensor, Tensor > SearchHybrid(const Tensor &query_points, const double radius, const int max_knn) const override
Definition: KnnIndex.h:97
Definition: PinholeCameraIntrinsic.cpp:35
Definition: Tensor.h:51
bool SetTensorData(const Tensor &dataset_points, double radius, const Dtype &index_dtype=core::Int64) override
Definition: KnnIndex.h:71
Definition: KnnIndex.h:51
std::tuple< Tensor, Tensor, Tensor > SearchRadius(const Tensor &query_points, const Tensor &radii, bool sort) const override
Definition: KnnIndex.h:85
#define LogError(...)
Definition: Logging.h:67
std::tuple< Tensor, Tensor, Tensor > SearchRadius(const Tensor &query_points, const double radius, bool sort) const override
Definition: KnnIndex.h:91