Test of the binary reader. The files used is STL file with containing one triange.
This code users BinaryReader to open a binary file called SimpleTrianlge.stl and read in currently the single tringle from this file. The triangle was created using nclab.org and contains a single triangle with normal (0,0,1) and vertex (0,1,0), (1,0,0) and (1,1,0). This is currently a UnitTest as does not require selftest data; however, it does require he file SimpleTrianlge.stl to exist
45 std::ifstream STLFile;
61 logger(
FATAL,
"Failed to read the correct number of triangles");
63 double xTmp,yTmp,zTmp;
65 for (
unsigned int i=0;
i<(numTriangles);
i++)
73 Vec3D Normal(xTmp,yTmp,zTmp);
75 if (!(Normal.isEqualTo(
Vec3D(0,0,1),1e-10)))
83 Vec3D Point1(xTmp,yTmp,zTmp);
85 if (!(Point1.isEqualTo(
Vec3D(0,1,0),1e-10)))
92 Vec3D Point2(xTmp,yTmp,zTmp);
94 if (!(Point2.isEqualTo(
Vec3D(1,0,0),1e-10)))
102 Vec3D Point3(xTmp,yTmp,zTmp);
104 if (!(Point3.isEqualTo(
Vec3D(1,1,0),1e-10)))
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.
This gives functionality to read information from binary formats like STL etc. This class is complete...
Definition: BinaryReader.h:37
double readFloat(unsigned int size)
read the next so many bytes as a double (not in this case they were saves as a float orgainlly)
Definition: BinaryReader.cc:108
void ignoreChar(unsigned int size)
read and ignore the next number of characters
Definition: BinaryReader.cc:133
unsigned int readUnsignedInt(unsigned int size)
read the next so many bytes as a unsined int
Definition: BinaryReader.cc:121
std::string readString(unsigned int numChar)
reads the next so many Characters (bytes) as a std::string
Definition: BinaryReader.cc:80
Definition: BinaryReaderSTL1by1by1bySquareUnitTest.cpp:69
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51
References FATAL, getMercuryDPMSourceDir(), constants::i, BinaryReader::ignoreChar(), Vec3D::isEqualTo(), logger, BinaryReader::readFloat(), BinaryReader::readString(), and BinaryReader::readUnsignedInt().