-
Notifications
You must be signed in to change notification settings - Fork 0
/
Node.cpp
54 lines (46 loc) · 928 Bytes
/
Node.cpp
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
#include "Node.h"
// default constructor
Node::Node() {
// set to empty point
point2D null_point;
null_point.x = 0.0;
null_point.y = 0.0;
setPoint(null_point);
setType(LEAF);
setRoot(false);
setDepth(0);
setLeft(NULL);
setRight(NULL);
}
Node::Node(point2D point) {
setPoint(point);
// default; these get set when kd-tree is built
setType(LEAF);
setRoot(false);
setDepth(1);
setLeft(NULL);
setRight(NULL);
}
// PRINT FUNCTIONS
void Node::printInfo() {
printPoint(getPoint());
printType();
if (!isRoot()) {
printf("Depth: %d\n", getDepth());
}
fflush(stdout);
}
void Node::printType() {
string type;
if (isRoot()) return; // tree will state if it's printing the root
if (getType() == VERTICAL) {
type = "VERTICAL";
} else if (getType() == HORIZONTAL) {
type = "HORIZONTAL";
} else if (getType() == LEAF) {
type = "LEAF";
}
printf("Type: %s\n", type.c_str());
}
Node::~Node() {
}