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 
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
lvr2::Node::vH
Index vH
Definition: DynamicKDTree.hpp:14
lvr2::Node::point
BaseVecT point
Definition: DynamicKDTree.hpp:13
lvr2::DynamicKDTree::~DynamicKDTree
~DynamicKDTree()=default
lvr2::DynamicKDTree::insert
void insert(BaseVecT point, VertexHandle vH)
lvr2::DynamicKDTree
Definition: DynamicKDTree.hpp:19
lvr2::DynamicKDTree::deleteNode
void deleteNode(BaseVecT point)
lvr2::DynamicKDTree::findNearestRec
std::pair< Index, float > findNearestRec(Node< BaseVecT > *node, BaseVecT point, int depth, Index minDist, float minDistSq, BaseVecT currentBest)
lvr2::Node::left
Node< BaseVecT > * left
Definition: DynamicKDTree.hpp:15
NULL
#define NULL
Definition: mydefs.hpp:141
lvr2::DynamicKDTree::deleteNodeRec
Node< BaseVecT > * deleteNodeRec(Node< BaseVecT > *node, BaseVecT point, int depth)
lvr2::DynamicKDTree::sizeRec
int sizeRec(Node< BaseVecT > *node)
lvr2::DynamicKDTree::arePointsSame
bool arePointsSame(BaseVecT point1, BaseVecT point2)
Definition: DynamicKDTree.hpp:35
lvr2::DynamicKDTree::copyPoint
void copyPoint(BaseVecT &p1, BaseVecT &p2)
Definition: DynamicKDTree.hpp:40
lvr2::DynamicKDTree::insertRec
Node< BaseVecT > * insertRec(Node< BaseVecT > *node, BaseVecT point, VertexHandle vH, unsigned int depth)
lvr2::VertexHandle
Handle to access vertices of the mesh.
Definition: Handles.hpp:146
lvr2::DynamicKDTree::findNearest
Index findNearest(BaseVecT point)
lvr2::DynamicKDTree::minNode
Node< BaseVecT > * minNode(Node< BaseVecT > *x, Node< BaseVecT > *y, Node< BaseVecT > *z, int d)
lvr2::DynamicKDTree::newNode
struct Node< BaseVecT > * newNode(BaseVecT point, VertexHandle vH)
lvr2::DynamicKDTree::size
int size()
lvr2::DynamicKDTree::DynamicKDTree
DynamicKDTree(int k)
Definition: DynamicKDTree.hpp:60
lvr2::DynamicKDTree::k
int k
Definition: DynamicKDTree.hpp:23
lvr2::Node
Definition: DynamicKDTree.hpp:11
lvr2::DynamicKDTree::findMin
Node< BaseVecT > * findMin(Node< BaseVecT > *node, int d)
lvr2::DynamicKDTree::root
Node< BaseVecT > * root
Definition: DynamicKDTree.hpp:22
lvr2
Definition: BaseBufferManipulators.hpp:39
lvr2::DynamicKDTree::findMinRec
Node< BaseVecT > * findMinRec(Node< BaseVecT > *node, int d, unsigned depth)
lvr2::Index
uint32_t Index
Datatype used as index for each vertex, face and edge.
Definition: Handles.hpp:96
lvr2::Node::right
Node< BaseVecT > * right
Definition: DynamicKDTree.hpp:15


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 Wed Mar 2 2022 00:37:23