DynamicKDTree.hpp
Go to the documentation of this file.
1 //
2 // Created by patrick on 4/11/19.
3 //
4 
5 #ifndef LAS_VEGAS_DYNAMICKDTREE_HPP
6 #define LAS_VEGAS_DYNAMICKDTREE_HPP
7 
8 namespace lvr2{
9 
10  template <typename BaseVecT>
11  struct Node
12  {
13  BaseVecT point; // To store k dimensional point
14  Index vH; //To store the belonging vertexHandle index
16  };
17 
18  template <typename BaseVecT>
19  class DynamicKDTree {
20 
21  private:
23  int k;
24 
25  struct Node<BaseVecT>* newNode(BaseVecT point, VertexHandle vH);
26 
27  Node<BaseVecT>* insertRec(Node<BaseVecT>* node, BaseVecT point, VertexHandle vH, unsigned int depth);
28 
29  Node<BaseVecT>* minNode(Node<BaseVecT>* x, Node<BaseVecT>* y, Node<BaseVecT>* z, int d);
30 
31  Node<BaseVecT>* findMinRec(Node<BaseVecT>* node, int d, unsigned depth);
32 
33  Node<BaseVecT> *findMin(Node<BaseVecT>* node, int d);
34 
35  bool arePointsSame(BaseVecT point1, BaseVecT point2)
36  {
37  return point1 == point2;
38  }
39 
40  void copyPoint(BaseVecT& p1, BaseVecT& p2)
41  {
42  p1 = p2;
43  }
44 
45  Node<BaseVecT>* deleteNodeRec(Node<BaseVecT>* node, BaseVecT point, int depth);
46 
47  int sizeRec(Node<BaseVecT>* node);
48 
49  std::pair<Index, float> findNearestRec(Node<BaseVecT>* node, BaseVecT point, int depth, Index minDist, float minDistSq, BaseVecT currentBest);
50 
51  public:
52  void insert(BaseVecT point, VertexHandle vH);
53 
54  void deleteNode(BaseVecT point);
55 
56  int size();
57 
58  Index findNearest(BaseVecT point);
59 
60  explicit DynamicKDTree(int k) : k(k)
61  {
62  root = NULL;
63  }
64 
65  //TODO
66  ~DynamicKDTree() = default;
67 
68  };
69 }
70 
71 #include "DynamicKDTree.tcc"
72 
73 #endif //LAS_VEGAS_DYNAMICKDTREE_HPP
Handle to access vertices of the mesh.
Definition: Handles.hpp:146
void copyPoint(BaseVecT &p1, BaseVecT &p2)
uint32_t Index
Datatype used as index for each vertex, face and edge.
Definition: Handles.hpp:96
bool arePointsSame(BaseVecT point1, BaseVecT point2)
Node< BaseVecT > * left
Node< BaseVecT > * right
Node< BaseVecT > * root
BaseVecT point
#define NULL
Definition: mydefs.hpp:141


lvr2
Author(s): Thomas Wiemann , Sebastian Pütz , Alexander Mock , Lars Kiesow , Lukas Kalbertodt , Tristan Igelbrink , Johan M. von Behren , Dominik Feldschnieders , Alexander Löhr
autogenerated on Mon Feb 28 2022 22:46:06