-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSimp.cpp
More file actions
104 lines (81 loc) · 2.5 KB
/
Simp.cpp
File metadata and controls
104 lines (81 loc) · 2.5 KB
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
#include <iostream>
#include <stdlib.h>
#include <string>
#include "Surface.h"
#include "SimpVertexClustering.h"
#include "SimpELEN.h"
#include "SimpQEM.h"
using namespace std;
int main(int argc, char** argv)
{
if(argc < 6)
{
cerr << "*USAGE: Simplify <input file> <fraction of points to remove> <method (elen/qem/vc)> <grid_resolution> <no of threads>.\n";
exit(1);
}
string method = argv[3];
if(method != "elen" && method != "qem" && method != "vc")
{
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]);
// Vector3f v1(1,0,0);
// Vector3f v2(0,1,0);
// Vector3f v3(0,0,1);
//
// Vector3f v4 = v1.cross(v2);
//
// cerr << "v1 x v2 = (" << v4.x << "," << v4.y << "," << v4.z << ")\n";
// cerr << "v1 . v2 = " << v1.dot(v2) << endl;
//
// Vector3f v5 = v3.cross(v4);
// cerr << "v3 x v4 = (" << v5.x << "," << v5.y << "," << v5.z << ")\n";
if(method == "elen")
{
method = "ELEN";
int goal_vertices = goal*s->m_points.size();
SimpELEN* elen = new SimpELEN(s, nthreads);
//elen->initUniformGrid(gridresolution);
//elen->initEdgeCosts();
elen->simplify(goal_vertices,gridresolution);
}
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);
}
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();
}
//Vertex Clustering
// SimpVertexClustering* vc = new SimpVertexClustering(s, 10);
// vc->initCells();
// vc->simplifyClusters();
string sa(argv[1]);
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 << redtty << "Bounding box(min): " << s->bbox.minx << " " << s->bbox.miny << " " << s->bbox.minz << endl;
cerr << redtty << "Bounding box(max): " << s->bbox.maxx << " " << s->bbox.maxy << " " << s->bbox.maxz << endl;
cerr << "Length: " << s->bbox.getXLen() << " " << s->bbox.getYLen() << " " << s->bbox.getZLen() << endl;
cerr << deftty;
//delete vc;
delete s;
return 0;
}