-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cu
153 lines (128 loc) · 4.33 KB
/
main.cu
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <fstream>
#include <getopt.h>
#include <cstdlib>
#include <polylla.cu>
#include <triangulation.cu>
int main(int argc, char **argv) {
int opt;
std::string node_file, ele_file, neigh_file, off_file, output;
int size = 0;
while ((opt = getopt(argc, argv, "noi")) != -1) {
switch (opt) {
case 'n':
if (argc != 6) {
std::cerr << "Usage: " << argv[0] << " -n <node_file> <ele_file> <neigh_file> <output name>\n";
return 1;
}
node_file = argv[2];
ele_file = argv[3];
neigh_file = argv[4];
output = argv[5];
break;
case 'o':
if (argc != 4) {
std::cerr << "Usage: " << argv[0] << " -o <off file> <output name>\n";
return 1;
}
off_file = argv[2];
output = argv[3];
break;
case 'i':
if (argc != 4) {
std::cerr << "Usage: " << argv[0] << " -i <size> <output name>\n";
return 1;
}
size = std::atoi(argv[2]);
output = argv[3];
break;
default:
std::cerr << "Usage: " << argv[0] << " [-n | -o | -i] args\n";
return 1;
}
}
if (!node_file.empty() && !ele_file.empty() && !neigh_file.empty()) {
// Process node, ele, neigh files
Polylla mesh(node_file, ele_file, neigh_file);
mesh.print_stats(output + ".json");
std::cout << "output json in " << output << ".json" << std::endl;
} else if (!off_file.empty()) {
// Process off file
Polylla mesh(off_file);
mesh.print_stats(output + ".json");
std::cout << "output json in " << output << ".json" << std::endl;
} else if (size > 0) {
// Process size directly
Polylla mesh(size);
mesh.print_stats(output + ".json");
std::cout << "output json in " << output << ".json" << std::endl;
} else {
std::cerr << "Invalid arguments.\n";
return 1;
}
return 0;
}
/*#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <fstream>
#include <polylla.cu>
#include <triangulation.cu>
//#include <compresshalfedge.hpp>
//#include <io_void.hpp>
//#include <delfin.hpp>
//
#include <unistd.h> // for getopt
int main(int argc, char **argv) {
int opt;
std::string node_file, ele_file, neigh_file, off_file, output;
while ((opt = getopt(argc, argv, "n:e:i:o:s:")) != -1) {
switch (opt) {
case 'n':
node_file = optarg;
break;
case 'e':
ele_file = optarg;
break;
case 'i':
neigh_file = optarg;
break;
case 'o':
output = optarg;
break;
case 's':
off_file = optarg;
break;
default:
std::cout << "Usage: " << argv[0] << " -n <node_file .node> -e <ele_file .ele> -i <neigh_file .neigh> -o <output name>" << std::endl;
std::cout << "Or: " << argv[0] << " -s <size> -o <output name>" << std::endl;
return 1;
}
}
if (!node_file.empty() && !ele_file.empty() && !neigh_file.empty()) {
// Process node, ele, neigh files
Polylla mesh(node_file, ele_file, neigh_file);
mesh.print_stats(output + ".json");
std::cout << "output json in " << output << ".json" << std::endl;
} else if (!off_file.empty()) {
// Process off file
int size = atoi(off_file.c_str());
std::string output_name = "" + output;
Polylla mesh(off_file);
mesh.print_stats(output_name + ".json");
std::cout << "output json in " << output_name << ".json" << std::endl;
} else {
// Process size directly
int size = atoi(output.c_str());
std::string output_name = "" + output;
Polylla mesh(size);
mesh.print_stats(output_name + ".json");
std::cout << "output json in " << output_name << ".json" << std::endl;
}
return 0;
}
*/