Problem with StlAPI_Writer in OCC 7.0.0

How to fix problem with StlAPI_Writer in OCC 7.0.0 ?

Version 6.8.0 worked perfect for code

void  shape_write_stl ( const TopoDS_Shape& s, Standard_CString filepath )
    StlAPI_Writer writer;
    StlAPI_ErrorStatus Error = writer.Write( s, filepath );


But version 7.0.0 saving text in stl file "STL binary file, created with Open CASCADE Technology" or "solid shape, STL ascii file, created with Open CASCADE Technology endsolid shape" AND THAT'S ALL! No any problems with TopoDS_Shape cause worked for same shapes in 6.8.0... Also writer.Write returns result StlAPI_StatusOK 


Forum supervisor's picture

Since version 6.9.0, STL writer relies on triangulation stored in the shape for exporting STL data (see Release Notes of OCCT 6.9.0, issue 25357).
This allows better control over  the quality of the triangulation (in previous versions shape was triangulated by STL writer internally).
Use BRepMesh_IncrementalMesh to build triangulation before calling StlAPI_Writer.


Anatoly Vivchar's picture

Added lines 

BRepMesh_IncrementalMesh Mesh( s, 0.01 );


before writer.Write...

All works. Thank You!!!

Ravi Chandra Moturi's picture

As suggested above I had used BRepMesh_IncrementalMesh() before calling StlAPI_Writer.But the code is exiting saying segmentation fault.Further debugging shown me its causing in the line StlAPI_Writer.Write().

Opencascade version used is 7.0.0

Could you suggest a fix.

seaghost_143690's picture

I'm experiencing same issue, but only for older step file AP203