-
Notifications
You must be signed in to change notification settings - Fork 0
/
op_modes.c
69 lines (43 loc) · 1.04 KB
/
op_modes.c
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
57
58
59
60
61
62
63
64
65
66
67
/* MARDALE Andrei-Iulian - 311CB */
#include "bsp.h"
void mode1 (FILE *in, FILE *out) {
//line number and point number
int ln = 0, pn = 0;
//get lines
TLine *lines = getLines(in, &ln);
//get points
TPoint *points = getPoints(in, &pn);
//read tree from file
Tree T = readTree(in, lines);
//need lines no longer
free(lines);
lines = NULL;
//label regions using points
labelRegions(T, points, pn);
//need points no longer
free(points);
points = NULL;
//print tree
printTree(out, T);
fprintf(out, "\n");
//solve all points
localizePoints(in, out, T);
destroyTree(&T);
}
void mode2 (FILE *in, FILE *out) {
int ln = 0, pn = 0;
TLine *lines = getLines(in, &ln);
//build tree using lines
Tree T = buildTree(lines, ln);
free(lines);
lines = NULL;
//reads points after building tree (better memory usage)
TPoint *points = getPoints(in, &pn);
labelRegions(T, points, pn);
free(points);
points = NULL;
printTree(out, T);
fprintf(out, "\n");
localizePoints(in, out, T);
destroyTree(&T);
}