Tue, 07/14/2020 - 13:03
My aim is to convert a IGES file to STL file and I tried running the below code and I got the following output in CMD. But the conversion did not happen and the STL file was not created. How should I use this StlAPI_Writer?
I also tried BRepMesh_IncrementalMesh and tried using the RWStl.hxx to write a stl file, but this function expects a Poly_Triangulation_mesh. How should I convert a TopoDS_Shape to triangulationMesh?
Please let me know what went wrong here and what should be done to make it right.
#include "IGESControl_Reader.hxx"
#include "TColStd_HSequenceOfTransient.hxx"
#include "TopoDS_Shape.hxx"
#include <StlAPI_Writer.hxx>
#include <stdio.h>
int main()
{
IGESControl_Reader myIgesReader;
Standard_Integer nIgesFaces, nTransFaces;
myIgesReader.ReadFile("H:\\New_Model\\LBend.IGS");
Handle(TColStd_HSequenceOfTransient) myList = myIgesReader.GiveList("iges-faces");
TopoDS_Shape sh = myIgesReader.OneShape();
myIgesReader.PrintTransferInfo(IFSelect_FailAndWarn, IFSelect_GeneralInfo);
StlAPI_Writer StlOut;
Standard_Boolean a = StlOut.Write(sh, "H:\\New_Model\\LBend.stl");
return 0;
}
Output:
Total number of loaded entities 135.
********************************************************************************
General statistics for transfer :
Number of selected IGES entities : 135
Number of roots IGES entities : 0
Number of CasCade resulting Shapes : 0
Number of warnings : 0
Number of fails : 0
Press any key to continue . . .
Thank you.
Tue, 07/14/2020 - 14:45
Meanwhile, I also tried adding this code snip after creating a shape.
BRepMesh_IncrementalMesh Mesh(sh,0.0001);
Mesh.Perform();
StlAPI_Writer Stl_Out = StlAPI_Writer();
Stl_Out.ASCIIMode() = Standard_True;
Stl_Out.Write(sh,"H:\\Newfolder\\SWout.STL");
But still there is no file created.