-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
38 lines (36 loc) · 950 Bytes
/
main.cpp
File metadata and controls
38 lines (36 loc) · 950 Bytes
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
#include "mesh.hpp"
#include <fstream>
#include <sstream>
int main(int argc, char *argv[]) {
if (argc < 4) {
std::cerr
<< "Usage: <executable> <input file> <output file prefix> <ratio[,ratio]*> <threshold>"
<< std::endl;
exit(1);
}
std::ifstream in(argv[1]);
std::istringstream ratio_list(argv[3]);
std::istringstream threshold(argv[4]);
std::vector<real> ratios;
real ratio;
ratio_list >> ratio;
ratios.emplace_back(ratio);
while (ratio_list.good()) {
char comma;
ratio_list >> comma >> ratio;
ratios.emplace_back(ratio);
}
real thres;
threshold >> thres;
Mesh m(in);
m.simplify(
[&argv](Mesh &m, real ratio) {
std::ostringstream path;
path << argv[2] << '_' << ratio << ".obj";
std::ofstream out(path.str());
m.dump(out);
out.close();
},
ratios, thres);
in.close();
}