-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
92 lines (89 loc) · 2.1 KB
/
main.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/time.h>
#include "macros.h"
#include "globalVariables.h"
#if DISPLAY
#include "glDisplay.h"
#endif
extern Mesh mesh;
int main(int argc, char** argv)
{
char path[1024];
char inputPath[1024];
char outputPath[1024];
outputPath[0] = inputPath[0] = 0;
bool timing = false;
bool disp = false;
int seed = 0;
int c;
mesh.setRandomizeFlag(false);
while((c = getopt(argc, argv, "wcdr::ti:o:")) != -1)
{
switch(c)
{
case 'd':
disp = true;
break;
case 'i':
sprintf(inputPath, "%s", optarg);
break;
case 'o':
sprintf(outputPath, "%s", optarg);
break;
case 't':
timing = true;
break;
case 'r':
mesh.setRandomizeFlag(true);
if(optarg == NULL)
{
struct timeval t;
gettimeofday(&t, NULL);
mesh.setSeed(unsigned(t.tv_sec*1e6+t.tv_usec));
}
else
{
seed = atoi(optarg);
mesh.setSeed(unsigned(seed));
}
break;
case 'w':
mesh.setMethod(WALKING);
break;
case 'c':
mesh.setMethod(CONFLICT_GRAPH);
break;
}
}
if(strlen(inputPath) == 0)
{
printf("Invalid input path. To know how to use it, please refer to the document.\n");
return 0;
}
std::vector<vec3> v = mesh.loadNodes(inputPath);
struct timeval ts, te;
gettimeofday(&ts, NULL);
mesh.delaunay(v);
gettimeofday(&te, NULL);
double dt = (te.tv_sec-ts.tv_sec)*1e6;
dt += (te.tv_usec-ts.tv_usec);
if(timing)
printf("time = %0.3fs\n", dt/(1e6));
if(strlen(outputPath) > 0)
{
sprintf(path, "%s.node", outputPath);
mesh.outputNodes(path);
sprintf(path, "%s.ele", outputPath);
mesh.outputElements(path);
}
if(disp)
{
#if DISPLAY
glDisplay(argc, argv);
#endif
}
return 0;
}