Loading [MathJax]/extensions/TeX/AMSsymbols.js
Open3D (C++ API)  0.14.1
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
FixedRadiusIndex.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 <vector>
30 
31 #include "open3d/core/Dtype.h"
32 #include "open3d/core/Tensor.h"
35 
36 namespace open3d {
37 namespace core {
38 namespace nns {
39 
67 template <class T>
68 void BuildSpatialHashTableCPU(const Tensor& points,
69  double radius,
70  const Tensor& points_row_splits,
71  const Tensor& hash_table_splits,
72  Tensor& hash_table_index,
73  Tensor& hash_table_cell_splits);
74 
136 template <class T>
137 void FixedRadiusSearchCPU(const Tensor& points,
138  const Tensor& queries,
139  double radius,
140  const Tensor& points_row_splits,
141  const Tensor& queries_row_splits,
142  const Tensor& hash_table_splits,
143  const Tensor& hash_table_index,
144  const Tensor& hash_table_cell_splits,
145  const Metric metric,
146  const bool ignore_query_point,
147  const bool return_distances,
148  const bool sort,
149  Tensor& neighbors_index,
150  Tensor& neighbors_row_splits,
151  Tensor& neighbors_distance);
152 
204 template <class T>
205 void HybridSearchCPU(const Tensor& points,
206  const Tensor& queries,
207  double radius,
208  int max_knn,
209  const Tensor& points_row_splits,
210  const Tensor& queries_row_splits,
211  const Tensor& hash_table_splits,
212  const Tensor& hash_table_index,
213  const Tensor& hash_table_cell_splits,
214  const Metric metric,
215  Tensor& neighbors_index,
216  Tensor& neighbors_count,
217  Tensor& neighbors_distance);
218 
219 #ifdef BUILD_CUDA_MODULE
220 template <class T>
246 void BuildSpatialHashTableCUDA(const Tensor& points,
247  double radius,
248  const Tensor& points_row_splits,
249  const Tensor& hash_table_splits,
250  Tensor& hash_table_index,
251  Tensor& hash_table_cell_splits);
252 
253 // Fixed radius search. This function computes a list of neighbor indices
314 template <class T>
315 void FixedRadiusSearchCUDA(const Tensor& points,
316  const Tensor& queries,
317  double radius,
318  const Tensor& points_row_splits,
319  const Tensor& queries_row_splits,
320  const Tensor& hash_table_splits,
321  const Tensor& hash_table_index,
322  const Tensor& hash_table_cell_splits,
323  const Metric metric,
324  const bool ignore_query_point,
325  const bool return_distances,
326  const bool sort,
327  Tensor& neighbors_index,
328  Tensor& neighbors_row_splits,
329  Tensor& neighbors_distance);
330 
382 template <class T>
383 void HybridSearchCUDA(const Tensor& points,
384  const Tensor& queries,
385  double radius,
386  int max_knn,
387  const Tensor& points_row_splits,
388  const Tensor& queries_row_splits,
389  const Tensor& hash_table_splits,
390  const Tensor& hash_table_index,
391  const Tensor& hash_table_cell_splits,
392  const Metric metric,
393  Tensor& neighbors_index,
394  Tensor& neighbors_count,
395  Tensor& neighbors_distance);
396 #endif
397 
401 class FixedRadiusIndex : public NNSIndex {
402 public:
405 
410  FixedRadiusIndex(const Tensor& dataset_points, double radius);
412  FixedRadiusIndex(const FixedRadiusIndex&) = delete;
413  FixedRadiusIndex& operator=(const FixedRadiusIndex&) = delete;
414 
415 public:
416  bool SetTensorData(const Tensor& dataset_points) override {
418  "FixedRadiusIndex::SetTensorData witout radius not "
419  "implemented.");
420  }
421 
422  bool SetTensorData(const Tensor& dataset_points, double radius) override;
423  bool SetTensorData(const Tensor& dataset_points,
424  const Tensor& points_row_splits,
425  double radius);
426 
427  std::pair<Tensor, Tensor> SearchKnn(const Tensor& query_points,
428  int knn) const override {
429  utility::LogError("FixedRadiusIndex::SearchKnn not implemented.");
430  }
431 
432  std::tuple<Tensor, Tensor, Tensor> SearchRadius(
433  const Tensor& query_points,
434  const Tensor& radii,
435  bool sort = true) const override {
437  "FixedRadiusIndex::SearchRadius with multi-radii not "
438  "implemented.");
439  }
440 
441  std::tuple<Tensor, Tensor, Tensor> SearchRadius(
442  const Tensor& query_points,
443  double radius,
444  bool sort = true) const override;
445  std::tuple<Tensor, Tensor, Tensor> SearchRadius(
446  const Tensor& query_points,
447  const Tensor& queries_row_splits,
448  double radius,
449  bool sort = true) const;
450 
451  std::tuple<Tensor, Tensor, Tensor> SearchHybrid(const Tensor& query_points,
452  double radius,
453  int max_knn) const override;
454 
455  std::tuple<Tensor, Tensor, Tensor> SearchHybrid(
456  const Tensor& query_points,
457  const Tensor& queries_row_splits,
458  double radius,
459  int max_knn) const;
460 
461  const double hash_table_size_factor = 1.0 / 32;
462  const int64_t max_hash_tabls_size = 33554432;
463 
464 protected:
469 };
470 
471 } // namespace nns
472 } // namespace core
473 } // namespace open3d
const int64_t max_hash_tabls_size
Definition: FixedRadiusIndex.h:462
FixedRadiusIndex for nearest neighbor range search.
Definition: FixedRadiusIndex.h:401
Tensor points_row_splits_
Definition: FixedRadiusIndex.h:465
Definition: NNSIndex.h:40
Metric
Supported metrics.
Definition: NeighborSearchCommon.h:38
const double hash_table_size_factor
Definition: FixedRadiusIndex.h:461
int points
Definition: FilePCD.cpp:73
FixedRadiusIndex()
Default Constructor.
Definition: FixedRadiusIndex.cpp:37
void HybridSearchCPU(const Tensor &points, const Tensor &queries, double radius, int max_knn, const Tensor &points_row_splits, const Tensor &queries_row_splits, const Tensor &hash_table_splits, const Tensor &hash_table_index, const Tensor &hash_table_cell_splits, const Metric metric, Tensor &neighbors_index, Tensor &neighbors_count, Tensor &neighbors_distance)
Definition: FixedRadiusSearchOps.cpp:93
~FixedRadiusIndex()
Definition: FixedRadiusIndex.cpp:45
std::tuple< Tensor, Tensor, Tensor > SearchHybrid(const Tensor &query_points, double radius, int max_knn) const override
Definition: FixedRadiusIndex.cpp:195
Tensor hash_table_splits_
Definition: FixedRadiusIndex.h:466
Tensor hash_table_index_
Definition: FixedRadiusIndex.h:468
std::tuple< Tensor, Tensor, Tensor > SearchRadius(const Tensor &query_points, const Tensor &radii, bool sort=true) const override
Definition: FixedRadiusIndex.h:432
FixedRadiusIndex & operator=(const FixedRadiusIndex &)=delete
void BuildSpatialHashTableCPU(const Tensor &points, double radius, const Tensor &points_row_splits, const Tensor &hash_table_splits, Tensor &hash_table_index, Tensor &hash_table_cell_splits)
Definition: FixedRadiusSearchOps.cpp:40
Definition: PinholeCameraIntrinsic.cpp:35
Definition: Tensor.h:50
bool SetTensorData(const Tensor &dataset_points) override
Definition: FixedRadiusIndex.h:416
std::pair< Tensor, Tensor > SearchKnn(const Tensor &query_points, int knn) const override
Definition: FixedRadiusIndex.h:427
Tensor hash_table_cell_splits_
Definition: FixedRadiusIndex.h:467
void FixedRadiusSearchCPU(const Tensor &points, const Tensor &queries, double radius, const Tensor &points_row_splits, const Tensor &queries_row_splits, const Tensor &hash_table_splits, const Tensor &hash_table_index, const Tensor &hash_table_cell_splits, const Metric metric, const bool ignore_query_point, const bool return_distances, const bool sort, Tensor &neighbors_index, Tensor &neighbors_row_splits, Tensor &neighbors_distance)
Definition: FixedRadiusSearchOps.cpp:57
#define LogError(...)
Definition: Logging.h:72