OpenCascade.js
API ReferenceDataExchangeTKDESTL

StlAPI

OCCT package StlAPI: StlAPI, StlAPI_Reader, StlAPI_Writer.

StlAPI

Offers the API for STL data manipulation.

Constructors(1)

Static methods(2)

  • Write(theShape: TopoDS_Shape, theFile: string, theAsciiMode?: boolean): boolean

    Convert and write shape to STL format. File is written in binary if aAsciiMode is False otherwise it is written in Ascii (by default).

    Parameters (3)
    • theShape
    • theFile
    • theAsciiMode
  • Read(theShape: TopoDS_Shape, aFile: string): boolean

    Legacy interface. Read STL file and create a shape composed of triangular faces, one per facet. This approach is very inefficient, especially for large files. Consider reading STL file to Poly_Triangulation object instead (see class RWStl).

    Deprecated
    Parameters (2)
    • theShape
      Mutated in place; read the updated value from this argument after the call.
    • aFile

StlAPI_Reader

Reading from stereolithography format. Reads STL file and creates a shape composed of triangular faces, one per facet. IMPORTANT: This approach is very inefficient, especially for large files. IMPORTANT: Consider reading STL file to Poly_Triangulation object instead (see class RWStl).

Constructors(1)

Instance methods(1)

  • Read(theShape: TopoDS_Shape, theFileName: string): boolean

    Reads STL data from stream to the TopoDS_Shape (each triangle is converted to the face).

    Parameters (2)
    • theShape
      result shape Mutated in place; read the updated value from this argument after the call.
    • theFileName
    Returns

    True if reading is successful

StlAPI_Writer

This class creates and writes STL files from Open CASCADE shapes. An STL file can be written to an existing STL file or to a new one.

Constructors(1)

Instance methods(2)

  • ASCIIMode(): boolean

    Returns the address to the flag defining the mode for writing the file. This address may be used to either read or change the flag. If the mode returns True (default value) the generated file is an ASCII file. If the mode returns False, the generated file is a binary file.

  • Write(theShape: TopoDS_Shape, theFileName: string, theProgress: Message_ProgressRange): boolean

    Converts a given shape to STL format and writes it to file with a given filename.

    Parameters (3)
    • theShape
    • theFileName
    • theProgress
    Returns

    the error state.