Class for reading ASCII and binary STL files.
More...
|
| STLReader (const std::string &filename, Format format=FormatUnknown) |
|
void | displayInspectionInfo (const InspectionInfo &info, std::ostream &out) const |
|
int | inspect (InspectionInfo *info) |
|
int | readBegin () |
|
int | readEnd () |
|
int | readFacet (std::array< double, 3 > *V0, std::array< double, 3 > *V1, std::array< double, 3 > *V2, std::array< double, 3 > *N) |
|
int | readFooter () |
|
int | readFooter (const std::string &solid) |
|
int | readHeader (const std::string &solid, std::string *name, std::size_t *nT) |
|
int | readHeader (std::string *name, std::size_t *nT) |
|
int | readSolid (const std::string &solid, std::string *name, std::size_t *nV, std::size_t *nT, std::vector< std::array< double, 3 > > *V, std::vector< std::array< double, 3 > > *N, std::vector< std::array< std::size_t, 3 > > *T) |
|
int | readSolid (std::string *name, std::size_t *nV, std::size_t *nT, std::vector< std::array< double, 3 > > *V, std::vector< std::array< double, 3 > > *N, std::vector< std::array< std::size_t, 3 > > *T) |
|
const std::string & | getFilename () const |
|
Format | getFormat () const |
|
Class for reading ASCII and binary STL files.
Definition at line 83 of file STL.hpp.
◆ STLReader()
bitpit::STLReader::STLReader |
( |
const std::string & | filename, |
|
|
Format | format = FormatUnknown ) |
Constructor.
- Parameters
-
filename | is the name of the STL file |
format | is the format of the STL file |
Definition at line 137 of file STL.cpp.
◆ detectFormat()
STLReader::Format bitpit::STLReader::detectFormat |
( |
const std::string & | filename | ) |
|
|
static |
Detects the format of the specified STL file.
An ASCII STL file begins with the line "solid name" and concludes with the line "endsolid name", where name is an optional string.
A binary STL file has an 80-character header which is ignored, but should never begin with the ASCII representation of the string solid. Following the header is a 4-byte little-endian unsigned integer indicating the number of triangular facets in the file. The size of the binary file should be consistent with the number of factes. No extra data is allowed after the definition of the factes.
- Parameters
-
filename | is the name of the STL file |
- Returns
- The format of the specified STL file.
Definition at line 167 of file STL.cpp.
◆ displayInspectionInfo()
void bitpit::STLReader::displayInspectionInfo |
( |
const InspectionInfo & | info, |
|
|
std::ostream & | out ) const |
Display inspection information.
- Parameters
-
| info | are the information that will be displayed |
[in,out] | out | output stream |
Definition at line 656 of file STL.cpp.
◆ inspect()
Inspect the STL file.
- Parameters
-
info | on output it will contain the information gathered during the inspection |
- Returns
- Returns a negative number if an error occured, zero otherwise. The meaning of the error codes is the following:
- error = -1: error opening the STL file
- error = -2: the file is already open
Definition at line 307 of file STL.cpp.
◆ readBegin()
int bitpit::STLReader::readBegin |
( |
| ) |
|
Begin reading the file.
- Returns
- Returns a negative number if an error occured, zero otherwise. The meaning of the error codes is the following:
- error = -1: error opening the STL file
- error = -2: the file is already open
Definition at line 714 of file STL.cpp.
◆ readEnd()
int bitpit::STLReader::readEnd |
( |
| ) |
|
Close the current stream to STL file.
Definition at line 731 of file STL.cpp.
◆ readFacet()
int bitpit::STLReader::readFacet |
( |
std::array< double, 3 > * | V0, |
|
|
std::array< double, 3 > * | V1, |
|
|
std::array< double, 3 > * | V2, |
|
|
std::array< double, 3 > * | N ) |
Read facet data from an ASCII STL file.
This routine assumes that the file stream is already open.
- Parameters
-
[out] | V0 | on output will contain the coordinates of the first vertex |
[out] | V1 | on output will contain the coordinates of the second vertex |
[out] | V2 | on output will contain the coordinates of the third vertex |
[out] | N | on output will contain the normal |
- Returns
- Returns a negative number if an error occured, zero otherwise. The meaning of the error codes is the following:
- error = -1: failed to read from input stream
- error = -2: facet data section is malformed
- error = -3: the facet has more than 3 vertices
Definition at line 942 of file STL.cpp.
◆ readFooter() [1/2]
int bitpit::STLReader::readFooter |
( |
| ) |
|
Read the footer of an ASCII STL file.
This routine assumes that the file stream is already open.
- Returns
- Returns a negative number if an error occured, zero otherwise. The meaning of the error codes is the following:
- error = -1: failed to read data from output stream
- error = -2: footer was not found
Definition at line 896 of file STL.cpp.
◆ readFooter() [2/2]
int bitpit::STLReader::readFooter |
( |
const std::string & | solid | ) |
|
Read the footer of an ASCII STL file.
This routine assumes that the file stream is already open.
- Parameters
-
solid | is the name of the solid, if the name is empty, the first footer will be read |
- Returns
- Returns a negative number if an error occured, zero otherwise. The meaning of the error codes is the following:
- error = -1: failed to read data from output stream
- error = -2: footer was not found
Definition at line 913 of file STL.cpp.
◆ readHeader() [1/2]
int bitpit::STLReader::readHeader |
( |
const std::string & | solid, |
|
|
std::string * | name, |
|
|
std::size_t * | nT ) |
Read the header of the STL file.
This routine assumes that the file stream is already open.
- Parameters
-
[in] | solid | is the name of the solid, if the name is empty, the first header will be read |
[out] | name | on output will contain the name of the solid that has been actually read |
[out] | nT | on input will contain the number of factes of the solid |
- Returns
- Returns a negative number if an error occured, zero otherwise. The meaning of the error codes is the following:
- error = -1: failed to read data from output stream
- error = -2: header was not found
Definition at line 865 of file STL.cpp.
◆ readHeader() [2/2]
int bitpit::STLReader::readHeader |
( |
std::string * | name, |
|
|
std::size_t * | nT ) |
Read the header of the STL file.
This routine assumes that the file stream is already open.
- Parameters
-
[out] | name | on output will contain the name of the solid that has been actually read |
[out] | nT | on input will contain the number of factes of the solid |
- Returns
- Returns a negative number if an error occured, zero otherwise. The meaning of the error codes is the following:
- error = -1: failed to read data from output stream
- error = -2: header was not found
Definition at line 845 of file STL.cpp.
◆ readSolid() [1/2]
int bitpit::STLReader::readSolid |
( |
const std::string & | solid, |
|
|
std::string * | name, |
|
|
std::size_t * | nV, |
|
|
std::size_t * | nT, |
|
|
std::vector< std::array< double, 3 > > * | V, |
|
|
std::vector< std::array< double, 3 > > * | N, |
|
|
std::vector< std::array< std::size_t, 3 > > * | T ) |
Read solid data from the STL file.
This routine assumes that the file stream is already open.
- Parameters
-
[in] | solid | is the name of the solid that will to be read, if the name is empty, the first solid found will be read. Loading solids with a specific name is only supported for ASCII files |
[out] | name | on output will contain the name of the solid that has been actually read. Solid names are only supported for ASCII files |
[in,out] | nV | on input stores the current number of vertices hosted in V, on output stores the input values incremented by the number of vertices read from the STL file. |
[in,out] | nT | on input stores the number of facet->vertex connectivity entries stores in T, on output stores the input value incremented by the number of facets read from the STL file. |
[in,out] | V | is the list of vertex coordinates, vertices read from the STL file are appended at the end of V |
[in,out] | N | is the list of facet normals, normals read from the STL file are appended at the end of V |
[in,out] | T | is the facet->vertex connectivity, entries read from the STL file are appended at the end of T |
- Returns
- Returns a negative number if an error occured, zero otherwise.
Definition at line 790 of file STL.cpp.
◆ readSolid() [2/2]
int bitpit::STLReader::readSolid |
( |
std::string * | name, |
|
|
std::size_t * | nV, |
|
|
std::size_t * | nT, |
|
|
std::vector< std::array< double, 3 > > * | V, |
|
|
std::vector< std::array< double, 3 > > * | N, |
|
|
std::vector< std::array< std::size_t, 3 > > * | T ) |
Read solid data from the STL file.
This routine assumes that the file stream is already open.
- Parameters
-
[out] | name | on output will contain the name of the solid that has been actually read. Solid names are only supported for ASCII files |
[in,out] | nV | on input stores the current number of vertices hosted in V, on output stores the input values incremented by the number of vertices read from the STL file. |
[in,out] | nT | on input stores the number of facet->vertex connectivity entries stores in T, on output stores the input value incremented by the number of facets read from the STL file. |
[in,out] | V | is the list of vertex coordinates, vertices read from the STL file are appended at the end of V |
[in,out] | N | is the list of facet normals, normals read from the STL file are appended at the end of V |
[in,out] | T | is the facet->vertex connectivity, entries read from the STL file are appended at the end of T |
- Returns
- Returns a negative number if an error occured, zero otherwise.
Definition at line 759 of file STL.cpp.
The documentation for this class was generated from the following files:
---
layout: doxygen_footer
---