STLCore Class Reference

Core routines used when reading/writing STL files. More...

Inheritance diagram for STLCore:
[legend]

Public Types

enum  STLFormat { ASCII , BINARY , UNKNOWN }
 Enumeration for the format of data in the stream. More...
 

Protected Member Functions

 STLCore ()=default
 Default construct. More...
 

Static Protected Member Functions

static bool isBinaryName (const fileName &filename, const STLFormat format)
 Detect 'stlb' extension as binary when format = UNKNOWN. More...
 
static int detectBinaryHeader (const fileName &filename)
 Check contents to detect if the file is a binary STL. More...
 
static std::unique_ptr< std::istream > readBinaryHeader (const fileName &filename, label &nTrisEstimated)
 Read STL binary file header. More...
 
static void writeBinaryHeader (ostream &os, uint32_t nTris)
 Write STL binary file and number of triangles to stream. More...
 

Detailed Description

Core routines used when reading/writing STL files.

Source files

Definition at line 54 of file STLCore.H.

Member Enumeration Documentation

◆ STLFormat

enum STLFormat

Enumeration for the format of data in the stream.

Enumerator
ASCII 

ASCII.

BINARY 

BINARY.

UNKNOWN 

Detect based on (input) content or (output) extension.

Definition at line 61 of file STLCore.H.

Constructor & Destructor Documentation

◆ STLCore()

STLCore ( )
protecteddefault

Default construct.

Member Function Documentation

◆ isBinaryName()

bool isBinaryName ( const fileName filename,
const STLFormat  format 
)
staticprotected

Detect 'stlb' extension as binary when format = UNKNOWN.

Otherwise test if format == BINARY.

Definition at line 66 of file STLCore.C.

References STLCore::BINARY, format(), fileName::hasExt(), and STLCore::UNKNOWN.

Here is the call graph for this function:

◆ detectBinaryHeader()

int detectBinaryHeader ( const fileName filename)
staticprotected

Check contents to detect if the file is a binary STL.

Return the estimated number of triangles or 0 on error.

Definition at line 87 of file STLCore.C.

References Foam::exit(), Foam::FatalError, FatalErrorInFunction, Foam::fileSize(), startsWithSolid(), STLHeaderSize, IOstreamOption::UNCOMPRESSED, and ifstreamPointer::whichCompression().

Here is the call graph for this function:

◆ readBinaryHeader()

std::unique_ptr< std::istream > readBinaryHeader ( const fileName filename,
label &  nTrisEstimated 
)
staticprotected

Read STL binary file header.

Return the opened file stream and estimated number of triangles. The stream is invalid and number of triangles is 0 on error.

Definition at line 147 of file STLCore.C.

References Foam::exit(), Foam::FatalError, FatalErrorInFunction, Foam::fileSize(), ifstreamPointer::release(), STLHeaderSize, IOstreamOption::UNCOMPRESSED, and ifstreamPointer::whichCompression().

Here is the call graph for this function:

◆ writeBinaryHeader()

void writeBinaryHeader ( ostream &  os,
uint32_t  nTris 
)
staticprotected

Write STL binary file and number of triangles to stream.

Definition at line 226 of file STLCore.C.

References os(), and STLHeaderSize.

Here is the call graph for this function:

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