ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
NearestNeighborSearch.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 <Optional.h>
11 
12 #include <vector>
13 
18 
19 namespace cloudViewer {
20 namespace core {
21 namespace nns {
22 
27 public:
32  // NearestNeighborSearch(const Tensor &dataset_points)
33  // : dataset_points_(dataset_points){};
34  NearestNeighborSearch(const Tensor &dataset_points,
35  const Dtype &index_dtype = core::Int32)
36  : dataset_points_(dataset_points), index_dtype_(index_dtype) {
38  };
42 
43 public:
47  bool KnnIndex();
48 
52  bool MultiRadiusIndex();
53 
59 
63  bool HybridIndex(utility::optional<double> radius = {});
64 
73  std::pair<Tensor, Tensor> KnnSearch(const Tensor &query_points, int knn);
74 
88  std::tuple<Tensor, Tensor, Tensor> FixedRadiusSearch(
89  const Tensor &query_points, double radius, bool sort = true);
90 
103  std::tuple<Tensor, Tensor, Tensor> MultiRadiusSearch(
104  const Tensor &query_points, const Tensor &radii);
105 
118  std::tuple<Tensor, Tensor, Tensor> HybridSearch(const Tensor &query_points,
119  const double radius,
120  const int max_knn) const;
121 
122 private:
123  bool SetIndex();
124 
126  void AssertNotCUDA(const Tensor &t) const;
127 
128 protected:
129  std::unique_ptr<NanoFlannIndex> nanoflann_index_;
130  std::unique_ptr<nns::FixedRadiusIndex> fixed_radius_index_;
131  std::unique_ptr<nns::KnnIndex> knn_index_;
134 };
135 } // namespace nns
136 } // namespace core
137 } // namespace cloudViewer
A Class for nearest neighbor search.
NearestNeighborSearch & operator=(const NearestNeighborSearch &)=delete
std::tuple< Tensor, Tensor, Tensor > FixedRadiusSearch(const Tensor &query_points, double radius, bool sort=true)
bool HybridIndex(utility::optional< double > radius={})
std::unique_ptr< nns::FixedRadiusIndex > fixed_radius_index_
bool FixedRadiusIndex(utility::optional< double > radius={})
NearestNeighborSearch(const Tensor &dataset_points, const Dtype &index_dtype=core::Int32)
NearestNeighborSearch(const NearestNeighborSearch &)=delete
std::tuple< Tensor, Tensor, Tensor > HybridSearch(const Tensor &query_points, const double radius, const int max_knn) const
std::unique_ptr< NanoFlannIndex > nanoflann_index_
std::tuple< Tensor, Tensor, Tensor > MultiRadiusSearch(const Tensor &query_points, const Tensor &radii)
std::pair< Tensor, Tensor > KnnSearch(const Tensor &query_points, int knn)
void AssertNotSYCL(const Tensor &tensor)
Definition: Tensor.h:1436
const Dtype Int32
Definition: Dtype.cpp:46
Generic file read and write utility for python interface.
std::vector< PointCoordinateType > radii
Definition: qM3C2Tools.cpp:42