-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkdtree.h
56 lines (51 loc) · 1.18 KB
/
kdtree.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#pragma once
#ifndef KD_TREE
#define KD_TREE
#include <stdio.h>
class KDTreeIterator;
class KDTree
{
friend class KDTreeIterator;
private:
struct Node {float pos; bool leaf; int a; int b;};
Node* nodes; //Ahnentafel list
int k;
int n;
int maxdepth;
int targetLeafSize;
int numNodes;
float* points;
int* idlist;
int curid;
int count;
void build(int a, int b, int depth);
KDTree(const KDTree& other) {printf("SHOULDNT SEE THIS\n");}; //can't copy tree
void operator=(const KDTree& other) {printf("SHOULDNT SEE THIS\n");}; //can't assign tree
public:
KDTree(int k, int targetLeafSize = 10);
~KDTree();
void setPoints(float* points, int count);
void rebuild();
KDTreeIterator find(float* position, float radius);
void debugLines(float** data, int* lines); //data = vertex coord + colour
};
class KDTreeIterator
{
friend class KDTree;
private:
float* pos;
float radius;
int curdepth;
int cur;
int leafindex;
bool* tovisit;
int* instances;
KDTree& tree;
KDTreeIterator(KDTree& kdtree, float* pos, float radius);
void operator=(const KDTreeIterator& other) {}; //can't assign iterator
public:
KDTreeIterator(const KDTreeIterator& other);
~KDTreeIterator();
int next();
};
#endif