STLReader Class Reference
+ Inheritance diagram for STLReader:

Public Member Functions

 STLReader (std::string fileName)
 
void addTriangle (const Vec3D normal, const Vec3D vertex1, const Vec3D vertex2, const Vec3D vertex3)
 
void output ()
 
STLTriangle getTriangle (const unsigned int num)
 
- Public Member Functions inherited from BinaryReader
 BinaryReader (std::string)
 Default constuction, requires to users to prove the name of the file that will be opened. More...
 
 ~BinaryReader ()
 Destructor, simple closes the file. More...
 
std::string readString (unsigned int numChar)
 reads the next so many Characters (bytes) as a std::string More...
 
double readDouble (unsigned int size)
 read the next so many bytes as a double More...
 
unsigned int readUnsignedInt (unsigned int size)
 read the next so many bytes as a unsined int More...
 
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) More...
 
void ignoreChar (unsigned int size)
 read and ignore the next number of characters More...
 

Private Attributes

std::string header_
 
unsigned numTriangles_
 
std::vector< STLTriangleTriangles_
 

Constructor & Destructor Documentation

◆ STLReader()

STLReader::STLReader ( std::string  fileName)
inline
72  : BinaryReader(fileName)
73  {
74 
75  header_= readString(80);
77 
78  Triangles_.resize(numTriangles_);
79 
80 
81  for (unsigned int i=0; i<(numTriangles_);i++)
82  {
83 
84 
85  Triangles_[i].normal.x() = readFloat(4);
86  Triangles_[i].normal.y() = readFloat(4);
87  Triangles_[i].normal.z() = readFloat(4);
88 
89 
90  Triangles_[i].vertex1.x() = readFloat(4);
91  Triangles_[i].vertex1.y() = readFloat(4);
92  Triangles_[i].vertex1.z() = readFloat(4);
93 
94  Triangles_[i].vertex2.x() = readFloat(4);
95  Triangles_[i].vertex2.y() = readFloat(4);
96  Triangles_[i].vertex2.z() = readFloat(4);
97 
98 
99  Triangles_[i].vertex3.x() = readFloat(4);
100  Triangles_[i].vertex3.y() = readFloat(4);
101  Triangles_[i].vertex3.z() = readFloat(4);
102 
103 
104  //Now ignore (read) the two dummy characters
105  ignoreChar(2);
106 
107  }
108 
109 
110 
111 
112  }
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
BinaryReader(std::string)
Default constuction, requires to users to prove the name of the file that will be opened.
Definition: BinaryReader.cc:41
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
std::vector< STLTriangle > Triangles_
Definition: BinaryReaderSTL1by1by1bySquareUnitTest.cpp:142
std::string header_
Definition: BinaryReaderSTL1by1by1bySquareUnitTest.cpp:140
unsigned numTriangles_
Definition: BinaryReaderSTL1by1by1bySquareUnitTest.cpp:141
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51

References header_, constants::i, BinaryReader::ignoreChar(), numTriangles_, BinaryReader::readFloat(), BinaryReader::readString(), BinaryReader::readUnsignedInt(), and Triangles_.

Member Function Documentation

◆ addTriangle()

void STLReader::addTriangle ( const Vec3D  normal,
const Vec3D  vertex1,
const Vec3D  vertex2,
const Vec3D  vertex3 
)
inline
116  {
117  STLTriangle triangleToAdd(normal,vertex1,vertex2,vertex3);
118  Triangles_.push_back(triangleToAdd);
119  }
Test of the STL reader. The files used is STL file with containing 12 triange that a 1 by 1 by 1 squa...
Definition: BinaryReaderSTL1by1by1bySquareUnitTest.cpp:39

References Triangles_.

◆ getTriangle()

STLTriangle STLReader::getTriangle ( const unsigned int  num)
inline
134  {
135  return Triangles_[num];
136  }

References Triangles_.

Referenced by main().

◆ output()

void STLReader::output ( )
inline
122  {
123 
125  for (unsigned int i = 0; i < (numTriangles_); i++)
126  {
127  logger(INFO, "Triangle % has normal % and vertexes % % %",
128  i, Triangles_[i].normal, Triangles_[i].vertex1, Triangles_[i].vertex2, Triangles_[i].vertex3);
129  }
130  }
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
@ INFO

References header_, constants::i, INFO, logger, NO_FLUSH, numTriangles_, and Triangles_.

Member Data Documentation

◆ header_

std::string STLReader::header_
private

Referenced by output(), and STLReader().

◆ numTriangles_

unsigned STLReader::numTriangles_
private

Referenced by output(), and STLReader().

◆ Triangles_

std::vector<STLTriangle> STLReader::Triangles_
private

The documentation for this class was generated from the following file: