IGES and STEP files to STL conversion issue

Im using these two code snippets to convert IGES and STEP files to STL file.

IGES to STL :

IGESControl_Reader reader;
reader.ReadFile(file_in_occ);
cout << "IGES File loaded" << endl;
Handle(TColStd_HSequenceOfTransient) myList = reader.GiveList("iges-faces");
myList->Length();
reader.TransferRoots();
sh = reader.OneShape();

BRepMesh_IncrementalMesh aMesh(sh, 0.1);
sh = aMesh.Shape();

StlAPI_Writer myStlWriter;
myStlWriter.ASCIIMode() = Standard_True;
myStlWriter.Write(sh, file_out_occ);

STEP to STL :

STEPControl_Reader reader;
reader.ReadFile(file_in_occ);
cout << "STEP File loaded" << endl;
reader.TransferRoots();
sh = reader.OneShape();

BRepMesh_IncrementalMesh aMesh(sh, 0.1);
sh = aMesh.Shape();

StlAPI_Writer myStlWriter;
myStlWriter.ASCIIMode() = Standard_True;
myStlWriter.Write(sh, file_out_occ);

The problem here is, for some files, conversion takes a long time and the file size sometimes go close to a GB. Im attaching such a file here.

But when I convert this same file using ImportExport application built from the given sample, the file size is just within 200kb. I expect an output similar to the one from ImportExport application.

Where have I gone wrong. Can someone please guide me to get the expected output.

Thank you

Attachments: 
Kirill Gavrilov's picture

Your model is almost hundred meters in size, while mesh parameters ask for 0.1 mm precision.
> BRepMesh_IncrementalMesh aMesh(sh, 0.1);
I have some doubts that you would like to print a 1:1 replica of the model on 3D printer using generated STL file, so you should reconsider meshing parameters.
When exact quality does not matter, linear deflection is usually computed based on model bounding box dimensions.

giridaran.unilogic_159669's picture

Thank you for your quick reply.
Is there a function to get the bounding box dimensions, so that I can calculate the linear deflection for each model loaded instead of leaving it as a constant