Open CASCADE Technology  7.5.0
Public Member Functions
RWStl_Reader Class Referenceabstract

An abstract class implementing procedure to read STL file. More...

#include <RWStl_Reader.hxx>

Inheritance diagram for RWStl_Reader:
Inheritance graph
[legend]

Public Member Functions

Standard_Boolean Read (const char *theFile, const Message_ProgressRange &theProgress)
 Reads data from STL file (either binary or Ascii). This function supports reading multi-domain STL files formed by concatenation of several "plain" files. The mesh nodes are not merged between domains. Unicode paths can be given in UTF-8 encoding. Format is recognized automatically by analysis of the file header. Returns true if success, false on error or user break. More...
 
Standard_Boolean IsAscii (Standard_IStream &theStream, const bool isSeekgAvailable)
 Guess whether the stream is an Ascii STL file, by analysis of the first bytes (~200). If the stream does not support seekg() then the parameter isSeekgAvailable should be passed as 'false', in this case the function attempts to put back the read symbols to the stream which thus must support ungetc(). Returns true if the stream seems to contain Ascii STL. More...
 
Standard_Boolean ReadBinary (Standard_IStream &theStream, const Message_ProgressRange &theProgress)
 Reads STL data from binary stream. The stream must be opened in binary mode. Stops after reading the number of triangles recorded in the file header. Returns true if success, false on error or user break. More...
 
Standard_Boolean ReadAscii (Standard_IStream &theStream, Standard_ReadLineBuffer &theBuffer, const std::streampos theUntilPos, const Message_ProgressRange &theProgress)
 Reads data from the stream assumed to contain Ascii STL data. The stream can be opened either in binary or in Ascii mode. Reading stops at the position specified by theUntilPos, or end of file is reached, or when keyword "endsolid" is found. Empty lines are not supported and will read to reading failure. If theUntilPos is non-zero, reads not more than until that position. Returns true if success, false on error or user break. More...
 
virtual Standard_Integer AddNode (const gp_XYZ &thePnt)=0
 Callback function to be implemented in descendant. Should create new node with specified coordinates in the target model, and return its ID as integer. More...
 
virtual void AddTriangle (Standard_Integer theN1, Standard_Integer theN2, Standard_Integer theN3)=0
 Callback function to be implemented in descendant. Should create new triangle built on specified nodes in the target model. More...
 
- Public Member Functions inherited from Standard_Transient
 Standard_Transient ()
 Empty constructor. More...
 
 Standard_Transient (const Standard_Transient &)
 Copy constructor – does nothing. More...
 
Standard_Transientoperator= (const Standard_Transient &)
 Assignment operator, needed to avoid copying reference counter. More...
 
virtual ~Standard_Transient ()
 Destructor must be virtual. More...
 
virtual void Delete () const
 Memory deallocator for transient classes. More...
 
virtual const opencascade::handle< Standard_Type > & DynamicType () const
 Returns a type descriptor about this object. More...
 
Standard_Boolean IsInstance (const opencascade::handle< Standard_Type > &theType) const
 Returns a true value if this is an instance of Type. More...
 
Standard_Boolean IsInstance (const Standard_CString theTypeName) const
 Returns a true value if this is an instance of TypeName. More...
 
Standard_Boolean IsKind (const opencascade::handle< Standard_Type > &theType) const
 Returns true if this is an instance of Type or an instance of any class that inherits from Type. Note that multiple inheritance is not supported by OCCT RTTI mechanism. More...
 
Standard_Boolean IsKind (const Standard_CString theTypeName) const
 Returns true if this is an instance of TypeName or an instance of any class that inherits from TypeName. Note that multiple inheritance is not supported by OCCT RTTI mechanism. More...
 
Standard_TransientThis () const
 Returns non-const pointer to this object (like const_cast). For protection against creating handle to objects allocated in stack or call from constructor, it will raise exception Standard_ProgramError if reference counter is zero. More...
 
Standard_Integer GetRefCount () const
 Get the reference counter of this object. More...
 
void IncrementRefCounter () const
 Increments the reference counter of this object. More...
 
Standard_Integer DecrementRefCounter () const
 Decrements the reference counter of this object; returns the decremented value. More...
 

Additional Inherited Members

- Public Types inherited from Standard_Transient
typedef void base_type
 Returns a type descriptor about this object. More...
 
- Static Public Member Functions inherited from Standard_Transient
static const char * get_type_name ()
 Returns a type descriptor about this object. More...
 
static const opencascade::handle< Standard_Type > & get_type_descriptor ()
 Returns type descriptor of Standard_Transient class. More...
 

Detailed Description

An abstract class implementing procedure to read STL file.

This class is not bound to particular data structure and can be used to read the file directly into arbitrary data model. To use it, create descendant class and implement methods addNode() and addTriangle().

Call method Read() to read the file. In the process of reading, the tool will call methods addNode() and addTriangle() to fill the mesh data structure.

The nodes with equal coordinates are merged automatically on the fly.

Member Function Documentation

◆ AddNode()

virtual Standard_Integer RWStl_Reader::AddNode ( const gp_XYZ thePnt)
pure virtual

Callback function to be implemented in descendant. Should create new node with specified coordinates in the target model, and return its ID as integer.

◆ AddTriangle()

virtual void RWStl_Reader::AddTriangle ( Standard_Integer  theN1,
Standard_Integer  theN2,
Standard_Integer  theN3 
)
pure virtual

Callback function to be implemented in descendant. Should create new triangle built on specified nodes in the target model.

◆ IsAscii()

Standard_Boolean RWStl_Reader::IsAscii ( Standard_IStream theStream,
const bool  isSeekgAvailable 
)

Guess whether the stream is an Ascii STL file, by analysis of the first bytes (~200). If the stream does not support seekg() then the parameter isSeekgAvailable should be passed as 'false', in this case the function attempts to put back the read symbols to the stream which thus must support ungetc(). Returns true if the stream seems to contain Ascii STL.

◆ Read()

Standard_Boolean RWStl_Reader::Read ( const char *  theFile,
const Message_ProgressRange theProgress 
)

Reads data from STL file (either binary or Ascii). This function supports reading multi-domain STL files formed by concatenation of several "plain" files. The mesh nodes are not merged between domains. Unicode paths can be given in UTF-8 encoding. Format is recognized automatically by analysis of the file header. Returns true if success, false on error or user break.

◆ ReadAscii()

Standard_Boolean RWStl_Reader::ReadAscii ( Standard_IStream theStream,
Standard_ReadLineBuffer theBuffer,
const std::streampos  theUntilPos,
const Message_ProgressRange theProgress 
)

Reads data from the stream assumed to contain Ascii STL data. The stream can be opened either in binary or in Ascii mode. Reading stops at the position specified by theUntilPos, or end of file is reached, or when keyword "endsolid" is found. Empty lines are not supported and will read to reading failure. If theUntilPos is non-zero, reads not more than until that position. Returns true if success, false on error or user break.

◆ ReadBinary()

Standard_Boolean RWStl_Reader::ReadBinary ( Standard_IStream theStream,
const Message_ProgressRange theProgress 
)

Reads STL data from binary stream. The stream must be opened in binary mode. Stops after reading the number of triangles recorded in the file header. Returns true if success, false on error or user break.


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