|
This gives functionality to read information from binary formats like STL etc. This class is complete stand-alone and is tested with one any reference to other MecuryDPM code except Vections and Logger. More...
#include <BinaryReader.h>
Public Member Functions | |
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 Member Functions | |
void | openFile (std::string fileName) |
opens the file with fileName More... | |
void | closeFile () |
close the file with fileName More... | |
Private Attributes | |
std::ifstream | binaryFile_ |
The pointer for the binary file. More... | |
This gives functionality to read information from binary formats like STL etc. This class is complete stand-alone and is tested with one any reference to other MecuryDPM code except Vections and Logger.
|
explicit |
Default constuction, requires to users to prove the name of the file that will be opened.
[in[ | fileName fileName of the binary file which is to be opened \deatails This is the default and only constuctor and it calls the private method openFile. |
References openFile().
BinaryReader::~BinaryReader | ( | ) |
Destructor, simple closes the file.
This is the destructor it simple closes the file as this is the only memory that needs freeing up
References closeFile().
|
private |
close the file with fileName
Simple function that closes the file; this is private and can only be called by the destructor
References binaryFile_.
Referenced by ~BinaryReader().
void BinaryReader::ignoreChar | ( | unsigned int | size | ) |
read and ignore the next number of characters
[in] | size | number of bytpes to be ignored |
Reads and disgards the next size characters size*8 bytes from the binary file
References binaryFile_.
Referenced by main(), WallHandler::readTriangleWall(), and STLReader::STLReader().
|
private |
opens the file with fileName
[in] | fileName | fileName of the binary file which is to be opened |
This opens the file associated with fileName, note the file is points is stored in the private varibles binaryFile_
References binaryFile_, ERROR, and logger.
Referenced by BinaryReader().
double BinaryReader::readDouble | ( | unsigned int | size | ) |
read the next so many bytes as a double
[in] | size | This is the size in bytes of the double stored in the file |
Usage myDouble = readDouble(4) would read a 8*4 = 32 bit double from the file; or myDouble = readDouble(8) would read a 64 bit double from the file.
References binaryFile_.
double BinaryReader::readFloat | ( | unsigned int | size | ) |
read the next so many bytes as a double (not in this case they were saves as a float orgainlly)
[in] | size | This is the size in bytes of the float stored in the file |
Usage myDouble = readFloat(4) would read 32 bit float from file covert it to a double and then return this double.
References binaryFile_.
Referenced by main(), WallHandler::readTriangleWall(), and STLReader::STLReader().
std::string BinaryReader::readString | ( | unsigned int | numChar | ) |
reads the next so many Characters (bytes) as a std::string
[in] | numChar | The number of characters to be read in from the binary file. |
The usages is myString = readString(6) will read in the next 6 characters from the binaryfile as a string.
References binaryFile_.
Referenced by main(), WallHandler::readTriangleWall(), and STLReader::STLReader().
unsigned int BinaryReader::readUnsignedInt | ( | unsigned int | size | ) |
read the next so many bytes as a unsined int
[in] | size | This is the size in bytes of the unsigned int that is stored in the file. |
Usage myUnsignedInt = readUnsignedInt(4) woudl read a 32 bit (4*8) unsigned int from the file.
References binaryFile_.
Referenced by main(), WallHandler::readTriangleWall(), and STLReader::STLReader().
|
private |
The pointer for the binary file.
Referenced by closeFile(), ignoreChar(), openFile(), readDouble(), readFloat(), readString(), and readUnsignedInt().