Loading [MathJax]/extensions/TeX/AMSsymbols.js
Open3D (C++ API)  0.19.0
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
NearestNeighborSearch.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 <vector>
11 
12 #include "open3d/core/Tensor.h"
17 
18 namespace open3d {
19 namespace core {
20 namespace nns {
21 
26 public:
31  // NearestNeighborSearch(const Tensor &dataset_points)
32  // : dataset_points_(dataset_points){};
33  NearestNeighborSearch(const Tensor &dataset_points,
34  const Dtype &index_dtype = core::Int32)
35  : dataset_points_(dataset_points), index_dtype_(index_dtype) {
37  };
41 
42 public:
46  bool KnnIndex();
47 
51  bool MultiRadiusIndex();
52 
58 
62  bool HybridIndex(utility::optional<double> radius = {});
63 
72  std::pair<Tensor, Tensor> KnnSearch(const Tensor &query_points, int knn);
73 
87  std::tuple<Tensor, Tensor, Tensor> FixedRadiusSearch(
88  const Tensor &query_points, double radius, bool sort = true);
89 
102  std::tuple<Tensor, Tensor, Tensor> MultiRadiusSearch(
103  const Tensor &query_points, const Tensor &radii);
104 
117  std::tuple<Tensor, Tensor, Tensor> HybridSearch(const Tensor &query_points,
118  const double radius,
119  const int max_knn) const;
120 
121 private:
122  bool SetIndex();
123 
125  void AssertNotCUDA(const Tensor &t) const;
126 
127 protected:
128  std::unique_ptr<NanoFlannIndex> nanoflann_index_;
129  std::unique_ptr<nns::FixedRadiusIndex> fixed_radius_index_;
130  std::unique_ptr<nns::KnnIndex> knn_index_;
133 };
134 } // namespace nns
135 } // namespace core
136 } // namespace open3d
double t
Definition: SurfaceReconstructionPoisson.cpp:172
Definition: Dtype.h:20
Definition: Tensor.h:32
A Class for nearest neighbor search.
Definition: NearestNeighborSearch.h:25
bool MultiRadiusIndex()
Definition: NearestNeighborSearch.cpp:38
NearestNeighborSearch(const NearestNeighborSearch &)=delete
std::unique_ptr< nns::KnnIndex > knn_index_
Definition: NearestNeighborSearch.h:130
std::tuple< Tensor, Tensor, Tensor > HybridSearch(const Tensor &query_points, const double radius, const int max_knn) const
Definition: NearestNeighborSearch.cpp:130
bool FixedRadiusIndex(utility::optional< double > radius={})
Definition: NearestNeighborSearch.cpp:40
std::tuple< Tensor, Tensor, Tensor > FixedRadiusSearch(const Tensor &query_points, double radius, bool sort=true)
Definition: NearestNeighborSearch.cpp:98
bool KnnIndex()
Definition: NearestNeighborSearch.cpp:23
std::tuple< Tensor, Tensor, Tensor > MultiRadiusSearch(const Tensor &query_points, const Tensor &radii)
Definition: NearestNeighborSearch.cpp:118
~NearestNeighborSearch()
Definition: NearestNeighborSearch.cpp:16
const Tensor dataset_points_
Definition: NearestNeighborSearch.h:131
std::unique_ptr< nns::FixedRadiusIndex > fixed_radius_index_
Definition: NearestNeighborSearch.h:129
bool HybridIndex(utility::optional< double > radius={})
Definition: NearestNeighborSearch.cpp:60
std::pair< Tensor, Tensor > KnnSearch(const Tensor &query_points, int knn)
Definition: NearestNeighborSearch.cpp:79
std::unique_ptr< NanoFlannIndex > nanoflann_index_
Definition: NearestNeighborSearch.h:128
NearestNeighborSearch & operator=(const NearestNeighborSearch &)=delete
const Dtype index_dtype_
Definition: NearestNeighborSearch.h:132
NearestNeighborSearch(const Tensor &dataset_points, const Dtype &index_dtype=core::Int32)
Definition: NearestNeighborSearch.h:33
Definition: Optional.h:259
const Dtype Int32
Definition: Dtype.cpp:46
void AssertNotSYCL(const Tensor &tensor)
Definition: Tensor.h:1428
Definition: PinholeCameraIntrinsic.cpp:16