-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
116 lines (93 loc) · 2.79 KB
/
Copy pathmain.cpp
File metadata and controls
116 lines (93 loc) · 2.79 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
105
106
107
108
109
110
111
112
113
114
115
116
//
// main.cpp
//
//
// Created by Xuan Huang on 6/23/16.
//
//
#include "functions.h"
#include <string.h>
#include <math.h>
#define PI 3.1415926
using namespace std;
int main(int argc, char* argv[]){
if(argc != 4){
cout << "Usage: ./test [flag: -Lap -s -q] inputOff outputOff" <<endl;
return 1;
}
string runFlag = argv[1];
string infi = argv[2];
string outfi = argv[3];
ifstream inputFile(infi);
if(!inputFile){
cout << "Cannot open file" << endl;
return 1;
}
vector<vertex> v;
vector<edge> e;
vector<face> f;
readIn(v, e, f, infi);
double maxAngle, minAngle, med, aspectratio;
maxminAng(v, f, maxAngle, minAngle);
aspectratio = aspectR(v, f, med);
cout << "\noriginal :" <<endl;
cout << "max: " << maxAngle*180/PI << " min: " << minAngle*180/PI<<endl;
cout << "aspectR: " << aspectratio<<endl;
int a =20;
float thresh = 2;
while(a >0 ){
if(!runFlag.compare("-Lap")){
smoothLapAng(v, f);
}else if(!runFlag.compare("-s")){
for (int i = 0; i < 8; ++i){
if(aspectratio < 4){
thresh = 1.2;
}else if(aspectratio < 8 ){
thresh = aspectratio /4;
}
smooth2Star(v, f, thresh);
}
}else if(!runFlag.compare("-q")){
for (int i = 0; i < 8; ++i){
if(aspectratio < 4){
thresh = 1.2;
}else if(aspectratio < 8 ){
thresh = aspectratio /4;
}
smooth2StarQ(v, f, thresh);
}
}else{
cout << "Wrong flag!" <<endl;
return 1;
}
a--;
}
cout << "\nafter smooth : "<<endl;
aspectratio = aspectR(v, f, med);
maxminAng(v, f, maxAngle, minAngle);
cout << "max: " << maxAngle*180/PI << " min: " << minAngle*180/PI<<endl;
cout << "aspectR: " << aspectratio<<endl;
/*
for (int i=0; i<v.size(); i++) {
cout << v[i].x << " "<< v[i].y << " "<< v[i].z << " "<< endl;
}
for (int i=0; i<e.size(); i++) {
cout << e[i].node1 << " "<< e[i].node2<< endl;
}
cout << f.size() <<endl;*/
ofstream outputfile;
outputfile.open(outfi, ios::out | ios::trunc);
outputfile << "OFF" << endl;
outputfile << v.size()<<" "<< f.size()<<" "<<e.size()<<" "<< endl;
for (int i =0; i<v.size(); i++){
outputfile << v[i].x << " " << v[i].y << " " << v[i].z <<endl;
}
for (int i =0; i<f.size(); i++){
outputfile << f[i].listOfV.size() << " "<< f[i].listToS();
outputfile <<"\n";
}
outputfile.close();
//double s = lineDistPoint(1, 1, 2, 2, 3, 4);
//cout << s <<endl;
return 0;
}