Open CASCADE Technology Reference Manual 8.0.0
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes
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

 RWStl_Reader ()
 Default constructor.
 
bool 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.
 
bool 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.
 
bool 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.
 
bool 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.
 
virtual int 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.
 
virtual void AddTriangle (int theN1, int theN2, int theN3)=0
 Callback function to be implemented in descendant. Should create new triangle built on specified nodes in the target model.
 
virtual void AddSolid ()
 Callback function to be implemented in descendant. Should create a new triangulation for a solid in multi-domain case.
 
double MergeAngle () const
 Return merge tolerance; M_PI/2 by default - all nodes are merged regardless angle between triangles.
 
void SetMergeAngle (double theAngleRad)
 Set merge angle in radians. Specify something like M_PI/4 (45 degrees) to avoid merge nodes between triangles at sharp corners.
 
double MergeTolerance () const
 Return linear merge tolerance; 0.0 by default (only 3D points with exactly matching coordinates are merged).
 
void SetMergeTolerance (double theTolerance)
 Set linear merge tolerance.
 
- Public Member Functions inherited from Standard_Transient
 Standard_Transient ()
 Empty constructor.
 
 Standard_Transient (const Standard_Transient &)
 Copy constructor – does nothing.
 
Standard_Transientoperator= (const Standard_Transient &)
 Assignment operator, needed to avoid copying reference counter.
 
virtual ~Standard_Transient ()=default
 Destructor must be virtual.
 
virtual const opencascade::handle< Standard_Type > & DynamicType () const
 Returns a type descriptor about this object.
 
bool IsInstance (const opencascade::handle< Standard_Type > &theType) const
 Returns a true value if this is an instance of Type.
 
bool IsInstance (const char *const theTypeName) const
 Returns a true value if this is an instance of TypeName.
 
bool 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.
 
bool IsKind (const char *const 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.
 
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.
 
int GetRefCount () const noexcept
 Get the reference counter of this object.
 
void IncrementRefCounter () noexcept
 Increments the reference counter of this object. Uses relaxed memory ordering since incrementing only requires atomicity, not synchronization with other memory operations.
 
int DecrementRefCounter () noexcept
 Decrements the reference counter of this object; returns the decremented value. Uses release ordering for the decrement to ensure all writes to the object are visible before the count reaches zero. An acquire fence is added only when the count reaches zero, ensuring proper synchronization before deletion. This is more efficient than using acq_rel for every decrement.
 
virtual void Delete () const
 Memory deallocator for transient classes.
 

Protected Attributes

double myMergeAngle
 
double myMergeTolearance
 

Additional Inherited Members

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

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.

Constructor & Destructor Documentation

◆ RWStl_Reader()

RWStl_Reader::RWStl_Reader ( )

Default constructor.

Member Function Documentation

◆ AddNode()

virtual int 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.

◆ AddSolid()

virtual void RWStl_Reader::AddSolid ( )
inlinevirtual

Callback function to be implemented in descendant. Should create a new triangulation for a solid in multi-domain case.

◆ AddTriangle()

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

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

◆ IsAscii()

bool 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.

◆ MergeAngle()

double RWStl_Reader::MergeAngle ( ) const
inline

Return merge tolerance; M_PI/2 by default - all nodes are merged regardless angle between triangles.

◆ MergeTolerance()

double RWStl_Reader::MergeTolerance ( ) const
inline

Return linear merge tolerance; 0.0 by default (only 3D points with exactly matching coordinates are merged).

◆ Read()

bool 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()

bool 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()

bool 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.

◆ SetMergeAngle()

void RWStl_Reader::SetMergeAngle ( double theAngleRad)
inline

Set merge angle in radians. Specify something like M_PI/4 (45 degrees) to avoid merge nodes between triangles at sharp corners.

◆ SetMergeTolerance()

void RWStl_Reader::SetMergeTolerance ( double theTolerance)
inline

Set linear merge tolerance.

Field Documentation

◆ myMergeAngle

double RWStl_Reader::myMergeAngle
protected

◆ myMergeTolearance

double RWStl_Reader::myMergeTolearance
protected

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