iMSTK
Interactive Medical Simulation Toolkit
imstkNeighborSearch.h
1 /*
2 ** This file is part of the Interactive Medical Simulation Toolkit (iMSTK)
3 ** iMSTK is distributed under the Apache License, Version 2.0.
4 ** See accompanying NOTICE for details.
5 */
6 
7 #pragma once
8 
9 #include "imstkMath.h"
10 #include "imstkVecDataArray.h"
11 
12 namespace imstk
13 {
14 class GridBasedNeighborSearch;
15 class SpatialHashTableSeparateChaining;
16 
22 {
23 public:
24  enum class Method
25  {
26  UniformGridBasedSearch,
27  SpatialHashing
28  };
29 
34  NeighborSearch(Method searchMethod, double searchRadius = 0.0);
35 
39  void setSearchRadius(const double searchRadius);
40 
44  double getSearchRadius() const { return m_SearchRadius; }
45 
51  std::vector<std::vector<size_t>> getNeighbors(const VecDataArray<double, 3>& points);
52 
58  void getNeighbors(std::vector<std::vector<size_t>>& result, const VecDataArray<double, 3>& points);
59 
66  void getNeighbors(std::vector<std::vector<size_t>>& result, const VecDataArray<double, 3>& setA, const VecDataArray<double, 3>& setB);
67 
68 private:
69  Method m_Method;
70  double m_SearchRadius = 0.0;
71 
72  std::shared_ptr<GridBasedNeighborSearch> m_GridBasedSearcher;
73  std::shared_ptr<SpatialHashTableSeparateChaining> m_SpatialHashSearcher;
74 };
75 } // namespace imstk
Compound Geometry.
std::vector< std::vector< size_t > > getNeighbors(const VecDataArray< double, 3 > &points)
Search neighbors for each points within the search radius.
double getSearchRadius() const
Get the current search radius.
void setSearchRadius(const double searchRadius)
Set the search radius.
NeighborSearch(Method searchMethod, double searchRadius=0.0)
Constructor.
A wrapper class for Grid-based and spatial-hashing neighbor search.