BinaryReaderSTL1by1by1bySquareUnitTest.cpp File Reference
#include <fstream>
#include <iostream>
#include <vector>
#include <string>
#include <BinaryReader.h>
#include <Logger.h>
#include <Math/Vector.h>
#include <CMakeDefinitions.h>

Classes

class  STLTriangle
 Test of the STL reader. The files used is STL file with containing 12 triange that a 1 by 1 by 1 square and was created in autocad. More...
 
class  STLReader
 

Functions

int main ()
 

Function Documentation

◆ main()

int main ( )
152 {
153  std::string directory(getMercuryDPMSourceDir());
154  STLReader myReader(directory+"/Drivers/ImportTools/ExampleSTLFiles/Box1x1x1.stl");
155 
156  std::vector<STLTriangle> answer;
157 
158 
159  answer.emplace_back(Vec3D(0,1,0),Vec3D(1.60291, 1.36214, 1e-06),Vec3D(0.602907, 1.36214, 1e-06),Vec3D(1.60291, 1.36214, 1));
160 
161  answer.emplace_back(Vec3D(0, 1, -0),Vec3D(1.60291, 1.36214, 1),Vec3D(0.602907, 1.36214, 1e-06),Vec3D(0.602907, 1.36214, 1));
162 
163  answer.emplace_back(Vec3D(1, 0, -0),Vec3D(1.60291, 0.362136, 1e-06),Vec3D(1.60291, 1.36214, 1e-06), Vec3D(1.60291, 0.362136, 1));
164 
165  answer.emplace_back(Vec3D(1, -0, 0),Vec3D(1.60291, 0.362136, 1),Vec3D(1.60291, 1.36214, 1e-06),Vec3D(1.60291, 1.36214, 1));
166 
167  answer.emplace_back(Vec3D(0, -1, 0),Vec3D(0.602907, 0.362136, 1e-06),Vec3D(1.60291, 0.362136, 1e-06),Vec3D(0.602907, 0.362136, 1));
168 
169  answer.emplace_back(Vec3D(0, -1, 0),Vec3D(0.602907, 0.362136, 1),Vec3D(1.60291, 0.362136, 1e-06),Vec3D(1.60291, 0.362136, 1));
170 
171  answer.emplace_back(Vec3D(-1, 1.11022e-16, 0),Vec3D(0.602907, 1.36214, 1e-06),Vec3D(0.602907, 0.362136, 1e-06),Vec3D(0.602907, 1.36214, 1));
172 
173  answer.emplace_back(Vec3D(-1, 1.11022e-16, 0),Vec3D(0.602907, 1.36214, 1),Vec3D(0.602907, 0.362136, 1e-06),Vec3D(0.602907, 0.362136, 1));
174 
175  answer.emplace_back(Vec3D(0, -0, 1),Vec3D(0.602907, 0.362136, 1),Vec3D(1.60291, 0.362136, 1),Vec3D(0.602907, 1.36214, 1));
176 
177  answer.emplace_back(Vec3D(-0, 0, 1),Vec3D(0.602907, 1.36214, 1),Vec3D(1.60291, 0.362136, 1),Vec3D(1.60291, 1.36214, 1));
178 
179  answer.emplace_back(Vec3D(0, -0, -1),Vec3D(0.602907, 1.36214, 1e-06),Vec3D(1.60291, 1.36214, 1e-06),Vec3D(0.602907, 0.362136, 1e-06));
180 
181  answer.emplace_back(Vec3D(0, 0, -1),Vec3D(0.602907, 0.362136, 1e-06),Vec3D(1.602907, 1.362136, 1e-06),Vec3D(1.60291, 0.362136, 1e-06));
182 
183 
184 
185 
186  for (unsigned int i=0;i<answer.size();i++)
187  {
188 // std::cout << answer[i].normal << std::endl;
189 // std::cout <<myReader.getTriangle(i).normal << std::endl;
190 //
191 // std::cout << answer[i].vertex1 << std::endl;
192 // std::cout <<myReader.getTriangle(i).vertex1 << std::endl;
193 //
194 // std::cout << answer[i].vertex2 << std::endl;
195 // std::cout <<myReader.getTriangle(i).vertex2 << std::endl;
196 //
197 // std::cout << answer[i].vertex3 << std::endl;
198 // std::cout <<myReader.getTriangle(i).vertex3 << std::endl;
199 
200 
201  if (!(answer[i].isEqualTo(myReader.getTriangle(i),1e-4)))
202  logger(FATAL,"Triangle % has need read incorrectly",i);
203 
204 
205 
206  }
207 
208 
209 
210 
211 }
const std::string getMercuryDPMSourceDir()
This file is used for generating definitions that give access to CMakeVariables from within a cpp fil...
Definition: CMakeDefinitions.cc:32
LL< Log::FATAL > FATAL
Definition of the different loglevels by its wrapper class LL. These are used as tags in template met...
Definition: Logger.cc:52
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
Definition: BinaryReaderSTL1by1by1bySquareUnitTest.cpp:69
Definition: Vector.h:51
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51

References FATAL, getMercuryDPMSourceDir(), STLReader::getTriangle(), constants::i, and logger.