Loading...
Searching...
No Matches
bitpit::STLWriter Class Reference
Class for writing ASCII and binary STL files. More...
Inheritance diagram for bitpit::STLWriter:

Collaboration diagram for bitpit::STLWriter:

Public Types | |
enum | WriteMode { WriteOverwrite , WriteAppend } |
![]() | |
enum | Format { FormatUnknown = -1 , FormatASCII , FormatBinary } |
Public Member Functions | |
STLWriter (const std::string &filename, Format format) | |
int | writeBegin (WriteMode writeMode, bool partialWrite=false) |
int | writeEnd () |
int | writeFacet (const std::array< double, 3 > &V0, const std::array< double, 3 > &V1, const std::array< double, 3 > &V2, const std::array< double, 3 > &N) |
int | writeFooter (const std::string &name) |
int | writeHeader (const std::string &name, std::size_t nT) |
int | writeSolid (const std::string &name, std::size_t nV, std::size_t nT, const std::vector< std::array< double, 3 > > &V, const std::vector< std::array< double, 3 > > &N, const std::vector< std::array< std::size_t, 3 > > &T) |
int | writeSolid (const std::string &name, std::size_t nV, std::size_t nT, const std::vector< std::vector< double > > &V, const std::vector< std::vector< double > > &N, const std::vector< std::vector< std::size_t > > &T) |
![]() | |
const std::string & | getFilename () const |
Format | getFormat () const |
Additional Inherited Members | |
![]() | |
typedef float | BINARY_REAL32 |
typedef uint16_t | BINARY_UINT16 |
typedef uint32_t | BINARY_UINT32 |
typedef uint8_t | BINARY_UINT8 |
![]() | |
STLBase (const std::string &filename) | |
STLBase (const std::string &filename, Format format) | |
void | setFilename (const std::string &filename) |
void | setFormat (Format format) |
![]() | |
static const std::string | ASCII_FACET_BEGIN = "facet" |
static const std::string | ASCII_FACET_END = "endfacet" |
static const std::string | ASCII_FILE_BEGIN = STLBase::ASCII_SOLID_BEGIN |
static const std::string | ASCII_FILE_END = STLBase::ASCII_SOLID_END |
static const std::size_t | ASCII_MINIMUM_SIZE = STLBase::ASCII_FILE_BEGIN.length() + STLBase::ASCII_FILE_END.length() |
static const std::string | ASCII_SOLID_BEGIN = "solid" |
static const std::string | ASCII_SOLID_END = "endsolid" |
static const std::size_t | BINARY_FACET_SIZE = 3 * sizeof(BINARY_REAL32) + 3 * 3 * sizeof(BINARY_REAL32) + sizeof(BINARY_UINT16) |
static const std::size_t | BINARY_HEADER_SIZE = 80 * sizeof(STLBase::BINARY_UINT8) |
static const std::size_t | BINARY_MINIMUM_SIZE = STLBase::BINARY_HEADER_SIZE + sizeof(STLBase::BINARY_UINT32) |
Detailed Description
Member Enumeration Documentation
◆ WriteMode
Constructor & Destructor Documentation
◆ STLWriter()
bitpit::STLWriter::STLWriter | ( | const std::string & | filename, |
Format | format ) |
Member Function Documentation
◆ writeBegin()
int bitpit::STLWriter::writeBegin | ( | WriteMode | writeMode, |
bool | partialWrite = false ) |
Begin writing the file.
- Parameters
-
writeMode is the write mode that will be used partialWrite tells the writer that only part of the facets will be written, this can be used for writing a binary file incrementally
- Returns
- Returns a negative number if an error occured, zero otherwise.
◆ writeEnd()
int bitpit::STLWriter::writeEnd | ( | ) |
◆ writeFacet()
int bitpit::STLWriter::writeFacet | ( | const std::array< double, 3 > & | V0, |
const std::array< double, 3 > & | V1, | ||
const std::array< double, 3 > & | V2, | ||
const std::array< double, 3 > & | N ) |
Write the specified facet data to the STL file.
This routine assumes that the file stream is already open.
- Parameters
-
V0 are the coordinates of the first vertex V1 are the coordinates of the second vertex V2 are the coordinates of the third vertex N is 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 write data to output stream
◆ writeFooter()
int bitpit::STLWriter::writeFooter | ( | const std::string & | name | ) |
Write the footer to the STL file.
This routine assumes that the file stream is already open.
- Parameters
-
name is the name 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 write data to output stream
◆ writeHeader()
int bitpit::STLWriter::writeHeader | ( | const std::string & | name, |
std::size_t | nT ) |
Write the header to the STL file.
This routine assumes that the file stream is already open.
- Parameters
-
name is the name of the solid nT are the number of facets 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 write data to output stream
◆ writeSolid()
int bitpit::STLWriter::writeSolid | ( | const std::string & | name, |
std::size_t | nV, | ||
std::size_t | nT, | ||
const std::vector< std::array< double, 3 > > & | V, | ||
const std::vector< std::array< double, 3 > > & | N, | ||
const std::vector< std::array< std::size_t, 3 > > & | T ) |
Write the specified solid data to the STL file.
This routine assumes that the file stream is already open.
- Parameters
-
name is the name of the solid nV are the number of vertices of the solid nT are the number of facets of the solid V is the list of vertex coordinates N is the list of facet normals T is the facet->vertex connectivity
- Returns
- Returns a negative number if an error occured, zero otherwise. The meaning of the error codes is the following:
- error = -1: failed to write data to output stream
- error = -2: input variable are not self-consistent
The documentation for this class was generated from the following files:
