RWStl
OCCT package RWStl: RWStl, RWStl_Reader.
RWStl
This class provides methods to read and write triangulation from / to the STL files.
Constructors(1)
- constructor(): RWStl
Static methods(2)
- ReadFile(theFile: string, theMergeAngle: number, theProgress: Message_ProgressRange): Poly_Triangulation
Read specified STL file and returns its content as triangulation.
Parameters (3)theFile—file path to readtheMergeAngle—maximum angle in radians between triangles to merge equal nodes; M_PI/2 means ignore angletheProgress—progress indicator
Returnsresult triangulation or NULL in case of error
- ReadFile(theFile: string, theMergeAngle: number, theTriangList: NCollection_Sequence_handle_Poly_Triangulation, theProgress: Message_ProgressRange): void
Read specified STL file and fills triangulation list for multi-domain case.
Parameters (4)theFile—file path to readtheMergeAngle—maximum angle in radians between triangles to merge equal nodes; M_PI/2 means ignore angletheTriangList—triangulation list for multi-domain case Mutated in place; read the updated value from this argument after the call.theProgress—progress indicator
RWStl_Reader
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.
Static methods(2)
- get_type_name(): string
Instance methods(9)
- Read(theFile: string, theProgress: Message_ProgressRange): boolean
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.
Parameters (2)theFiletheProgress
Callback function to be implemented in descendant. Should create new node with specified coordinates in the target model, and return its ID as integer.
Parameters (1)thePnt
- AddTriangle(theN1: number, theN2: number, theN3: number): void
Callback function to be implemented in descendant. Should create new triangle built on specified nodes in the target model.
Parameters (3)theN1theN2theN3
- AddSolid(): void
Callback function to be implemented in descendant. Should create a new triangulation for a solid in multi-domain case.
- MergeAngle(): number
Return merge tolerance; M_PI/2 by default - all nodes are merged regardless angle between triangles.
- SetMergeAngle(theAngleRad: number): void
Set merge angle in radians. Specify something like M_PI/4 (45 degrees) to avoid merge nodes between triangles at sharp corners.
Parameters (1)theAngleRad
- MergeTolerance(): number
Return linear merge tolerance; 0.0 by default (only 3D points with exactly matching coordinates are merged).
- SetMergeTolerance(theTolerance: number): void
Set linear merge tolerance.
Parameters (1)theTolerance