-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
105 lines (97 loc) · 3.41 KB
/
main.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#include "CutEllipsoid.h"
#include "CutSphere.h"
#include "CutBox.h"
#include "CutVoxel.h"
#include "PutVoxel.h"
#include "PutBox.h"
#include "PutSphere.h"
#include "PutEllipsoid.h"
#include "Sculptor.h"
#include "FiguraGeometrica.h"
#include <vector>
#include <fstream>
#include <string>
#include <iostream>
#include <memory>
int main(){
std::vector <FiguraGeometrica*> figuras;
std::unique_ptr <Sculptor> t = nullptr;
std::ifstream fin;
// Verificar se o arquivo esta aberto corretamente
fin.open("Kirby.txt");
if(!fin.is_open()){
exit(0);
}
std::string s;
while(fin.good()){
fin >> s;
if(fin.good()){
if(s.compare("dim") == 0){
int dimX, dimY, dimZ;
fin >> dimX >> dimY >> dimZ;
t = std::make_unique<Sculptor>(dimX, dimY, dimZ);
}
else if(s.compare("putbox") == 0){
int x0, x1, y0, y1, z0, z1;
float r, g, b, a;
fin >> x0 >> x1 >> y0 >> y1 >> z0 >> z1 >> r >> g >> b >> a;
figuras.push_back(
new PutBox(x0, x1, y0, y1, z0, z1, r, g, b, a));
}
else if(s.compare("putellipsoid") == 0){
int xcenter, ycenter, zcenter, rx, ry, rz;
float r, g, b, a;
fin >> xcenter >> ycenter >> zcenter >> rx >> ry >> rz >> r >> g >> b >> a;
figuras.push_back(
new PutEllipsoid(xcenter, ycenter, zcenter, rx, ry, rz, r, g, b, a));
}
else if(s.compare("putsphere") == 0){
int xcenter, ycenter, zcenter, radius;
float r, g, b, a;
fin >> xcenter >> ycenter >> zcenter >> radius >> r >> g >> b >> a;
figuras.push_back(
new PutSphere(xcenter, ycenter, zcenter, radius, r, g, b, a));
}
else if(s.compare("putvoxel") == 0){
int x, y, z;
float r, g, b, a;
fin >> x >> y >> z >> r >> g >> b >> a;
figuras.push_back(
new PutVoxel(x, y, z, r, g, b, a));
}
else if(s.compare("cutbox") == 0){
int x0, x1, y0, y1, z0 ,z1;
fin >> x0 >> x1 >> y0 >> y1 >> z0 >> z1;
figuras.push_back(
new CutBox(x0, x1, y0, y1, z0, z1));
}
else if(s.compare("cutellipsoid") == 0){
int xcenter, ycenter, zcenter, rx, ry, rz;
fin >> xcenter >> ycenter >> zcenter >> rx >> ry >> rz;
figuras.push_back(
new CutEllipsoid(xcenter, ycenter, zcenter, rx, ry, rz));
}
else if(s.compare("cutsphere") == 0){
int xcenter, ycenter, zcenter, radius;
fin >> xcenter >> ycenter >> zcenter >> radius;
figuras.push_back(
new CutSphere(xcenter, ycenter, zcenter, radius));
}
else if(s.compare("cutvoxel") == 0){
int x, y, z;
fin >> x >> y >> z;
figuras.push_back(
new CutVoxel(x, y, z));
}
}
}
for(int i=0; i<figuras.size(); i++){
figuras[i]->draw(*t);
}
for(int i=0; i<figuras.size(); i++){
delete figuras[i];
}
t->writeOFF("Kirby.off");
fin.close();
return 0;
}