-
Notifications
You must be signed in to change notification settings - Fork 0
/
Simp.cpp
87 lines (76 loc) · 2.13 KB
/
Simp.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
#include <iostream>
#include <stdlib.h>
#include <string>
#include "Surface.h"
//These methods must be updated to match new data structures Vertex3f and Face3f
#include "SimpVertexClustering.h"
#include "SimpELEN.h"
#include "SimpQEM.h"
#include "SimpGPU.h"
using namespace std;
void writeOutput(char* fpath, Surface* s, string method, float goal)
{
string sa(fpath);
string sub = sa.substr(0, sa.length()-4);
int percentage = goal*100;
string qtd = to_string(percentage);
string output = sub+qtd+"_"+method+".off";
cerr << "Writing output to " + output << endl;
s->saveOFF(output);
//s->dumpBoundingBox();
cerr << deftty;
}
int main(int argc, char** argv)
{
if(argc < 6)
{
cerr << "*USAGE: Simplify <input file> <% of points to remove> <method (elen/qem/gpu/vc)> <grid_resolution> <no of threads>.\n";
exit(1);
}
string method = argv[3];
if(method != "elen" && method != "qem" && method != "vc" && method != "gpu")
{
cerr << "ERROR: Invalid decimation method.\n";
exit(1);
}
Surface* s = new Surface(argv[1]);
float goal = atof(argv[2]);
int gridresolution = atoi(argv[4]);
int nthreads = atoi(argv[5]);
if(method == "elen")
{
method = "ELEN";
int goal_vertices = goal*s->m_points.size();
SimpELEN* elen = new SimpELEN(s, nthreads);
elen->simplify(goal_vertices,gridresolution);
writeOutput(argv[1],s,method,goal);
}
else if (method == "qem")
{
method = "QEM";
int goal_vertices = goal*s->m_points.size();
SimpQEM* qem = new SimpQEM(s,nthreads);
qem->simplify(goal_vertices,gridresolution);
writeOutput(argv[1],s,method,goal);
}
else if (method == "gpu")
{
method = "GPU";
int goal_vertices = goal*s->m_points.size();
SimpGPU* gpusimp = new SimpGPU(s);
gpusimp->simplify(goal_vertices,gridresolution);
writeOutput(argv[1],s,method,goal);
}
else if (method == "vc")
{
method = "VCLUSTERING";
cout << "Vertex Clustering not available yet.\n";
exit(1);
//SimpVertexClustering* vc = new SimpVertexClustering(s, 5);
//vc->initCells();
//vc->simplifyClusters();
}
//delete vc;
delete s;
return 0;
}