11 this->filename = filename;
25 void Loader::openFile()
27 if ((this->file = fopen(this->filename,
"r")) == NULL)
33 void Loader::closeFile()
38 Vertex Loader::readVertex()
40 double tmpX, tmpY, tmpZ;
42 if (fscanf_s(this->file,
" %lf %lf %lf", &tmpX, &tmpY, &tmpZ) != 3)
51 Vertex v(tmpX, tmpY, tmpZ);
53 if (tmpX < this->minX) this->minX = tmpX;
54 if (tmpY < this->minY) this->minY = tmpY;
55 if (tmpZ < this->minZ) this->minZ = tmpZ;
56 if (tmpX > this->maxX) this->maxX = tmpX;
57 if (tmpY > this->maxY) this->maxY = tmpY;
58 if (tmpZ > this->maxZ) this->maxZ = tmpZ;
63 Face Loader::readFace()
66 int tmpnA, tmpnB, tmpnC;
68 if (fscanf_s(this->file,
" %d//%d %d//%d %d//%d", &tmpA, &tmpnA, &tmpB, &tmpnB, &tmpC, &tmpnC) != 6)
73 Face f(tmpA, tmpnA, tmpB, tmpnB, tmpC, tmpnC);
80 double tmpX, tmpY, tmpZ;
82 if (fscanf_s(this->file,
" %lf %lf %lf", &tmpX, &tmpY, &tmpZ) != 3)
104 fscanf_s(f,
"%c", &linetype);
112 brick->
addFace(this->readFace());
120 while (linetype !=
'\0' && linetype !=
'\n')
122 fscanf_s(f,
"%c", &linetype);
198 double cX = this->maxX - (this->maxX - this->minX) / 2;
199 double cY = this->maxY - (this->maxY - this->minY) / 2;
200 double cZ = this->maxZ - (this->maxZ - this->minZ) / 2;
202 Vertex center(cX, cY, cZ);
Define vertex consisting 3 double coordinates.
Define face consisting 3 links to vetices.
void addNormal(Normal normal)
Brick * load(Composite *obj)