Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
bitpit::STLWriter Class Reference

Class for writing ASCII and binary STL files. More...

Inheritance diagram for bitpit::STLWriter:
Inheritance graph
[legend]
Collaboration diagram for bitpit::STLWriter:
Collaboration graph
[legend]

Public Types

enum  WriteMode { WriteOverwrite , WriteAppend }
 
- Public Types inherited from bitpit::STLBase
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)
 
- Public Member Functions inherited from bitpit::STLBase
const std::string & getFilename () const
 
Format getFormat () const
 

Additional Inherited Members

- Protected Types inherited from bitpit::STLBase
typedef float BINARY_REAL32
 
typedef uint16_t BINARY_UINT16
 
typedef uint32_t BINARY_UINT32
 
typedef uint8_t BINARY_UINT8
 
- Protected Member Functions inherited from bitpit::STLBase
 STLBase (const std::string &filename)
 
 STLBase (const std::string &filename, Format format)
 
void setFilename (const std::string &filename)
 
void setFormat (Format format)
 
- Static Protected Attributes inherited from bitpit::STLBase
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

Class for writing ASCII and binary STL files.

Definition at line 156 of file STL.hpp.

Member Enumeration Documentation

◆ WriteMode

enum bitpit::STLWriter::WriteMode

Definition at line 159 of file STL.hpp.

Constructor & Destructor Documentation

◆ STLWriter()

bitpit::STLWriter::STLWriter ( const std::string & filename,
Format format )

Constructor.

Parameters
filenameis the name of the STL file
formatis the format of the STL file

Definition at line 1346 of file STL.cpp.

Member Function Documentation

◆ writeBegin()

int bitpit::STLWriter::writeBegin ( WriteMode writeMode,
bool partialWrite = false )

Begin writing the file.

Parameters
writeModeis the write mode that will be used
partialWritetells 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.

Definition at line 1362 of file STL.cpp.

◆ writeEnd()

int bitpit::STLWriter::writeEnd ( )

Close the current stream to STL file.

Definition at line 1403 of file STL.cpp.

◆ 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
V0are the coordinates of the first vertex
V1are the coordinates of the second vertex
V2are the coordinates of the third vertex
Nis 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

Definition at line 1542 of file STL.cpp.

◆ 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
nameis 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

Definition at line 1515 of file STL.cpp.

◆ 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
nameis the name of the solid
nTare 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

Definition at line 1491 of file STL.cpp.

◆ 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
nameis the name of the solid
nVare the number of vertices of the solid
nTare the number of facets of the solid
Vis the list of vertex coordinates
Nis the list of facet normals
Tis 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

Definition at line 1426 of file STL.cpp.


The documentation for this class was generated from the following files:
--- layout: doxygen_footer ---