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
52  {
53 
54  header_= readString(80);
56 
57  Triangles_.resize(numTriangles_);
58 
59 
60  for (unsigned int i=0; i<(numTriangles_);i++)
61  {
62 
63 
64  Triangles_[i].normal.x() = readFloat(4);
65  Triangles_[i].normal.y() = readFloat(4);
66  Triangles_[i].normal.z() = readFloat(4);
67 
68 
69  Triangles_[i].vertex1.x() = readFloat(4);
70  Triangles_[i].vertex1.y() = readFloat(4);
71  Triangles_[i].vertex1.z() = readFloat(4);
72 
73  Triangles_[i].vertex2.x() = readFloat(4);
74  Triangles_[i].vertex2.y() = readFloat(4);
75  Triangles_[i].vertex2.z() = readFloat(4);
76 
77 
78  Triangles_[i].vertex3.x() = readFloat(4);
79  Triangles_[i].vertex3.y() = readFloat(4);
80  Triangles_[i].vertex3.z() = readFloat(4);
81 
82 
83  //Now ignore (read) the two dummy characters
84  ignoreChar(2);
85 
86  }
87 
88 
89 
90 
91  }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
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:85
void ignoreChar(unsigned int size)
read and ignore the next number of characters
Definition: BinaryReader.cc:110
BinaryReader(std::string)
Default constuction, requires to users to prove the name of the file that will be opened.
Definition: BinaryReader.cc:18
unsigned int readUnsignedInt(unsigned int size)
read the next so many bytes as a unsined int
Definition: BinaryReader.cc:98
std::string readString(unsigned int numChar)
reads the next so many Characters (bytes) as a std::string
Definition: BinaryReader.cc:57
std::vector< STLTriangle > Triangles_
Definition: BinaryReaderSTL1by1by1bySquareUnitTest.cpp:121
std::string header_
Definition: BinaryReaderSTL1by1by1bySquareUnitTest.cpp:119
unsigned numTriangles_
Definition: BinaryReaderSTL1by1by1bySquareUnitTest.cpp:120
string fileName
Definition: UniformPSDSelfTest.py:10

References header_, 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
95  {
96  STLTriangle triangleToAdd(normal,vertex1,vertex2,vertex3);
97  Triangles_.push_back(triangleToAdd);
98  }
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:18
void normal(const Vector< double > &x, Vector< double > &normal)
Definition: free_surface_rotation.cc:65

References WallFunction::normal(), and Triangles_.

◆ getTriangle()

STLTriangle STLReader::getTriangle ( const unsigned int  num)
inline
113  {
114  return Triangles_[num];
115  }

References Triangles_.

Referenced by main().

◆ output()

void STLReader::output ( )
inline
101  {
102 
104  for (unsigned int i = 0; i < (numTriangles_); i++)
105  {
106  logger(INFO, "Triangle % has normal % and vertexes % % %",
107  i, Triangles_[i].normal, Triangles_[i].vertex1, Triangles_[i].vertex2, Triangles_[i].vertex3);
108  }
109  }
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
@ INFO

References header_, i, INFO, logger, NO_FLUSH, WallFunction::normal(), 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: