1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: GEOMALGOAPI_STEPExport.cpp
4 // Created: May 14, 2015
5 // Author: Sergey POKHODENKO
7 #include <GeomAlgoAPI_STEPExport.h>
9 #include "GeomAlgoAPI_Tools.h"
11 #include <TopoDS_Shape.hxx>
14 #include <IFSelect_ReturnStatus.hxx>
15 #include <STEPControl_Writer.hxx>
16 #include <Interface_Static.hxx>
18 bool STEPExport(const std::string& theFileName,
19 const std::string& theFormatName,
20 const std::shared_ptr<GeomAPI_Shape>& theShape,
21 std::string& theError)
24 std::cout << "Export STEP into file " << theFileName << std::endl;
27 if (!theShape.get()) {
28 theError = "STEP Export failed: An invalid argument";
34 // Set "C" numeric locale to save numbers correctly
35 GeomAlgoAPI_Tools::Localizer loc;
37 IFSelect_ReturnStatus status ;
38 //VRV: OCC 4.0 migration
39 STEPControl_Writer aWriter;
40 Interface_Static::SetCVal("xstep.cascade.unit","M");
41 Interface_Static::SetCVal("write.step.unit", "M");
42 Interface_Static::SetIVal("write.step.nonmanifold", 1);
43 status = aWriter.Transfer(theShape->impl<TopoDS_Shape>(), STEPControl_AsIs);
44 //VRV: OCC 4.0 migration
45 if( status == IFSelect_RetDone )
46 status = aWriter.Write(theFileName.c_str());
48 // Return previous locale
49 if( status == IFSelect_RetDone )
52 catch (Standard_Failure)
54 theError = "Exception catched in STEPExport";