Salome HOME
Issue #608: Usage of OCCT in interface -- Remove OCCT from *Export interfaces --...
[modules/shaper.git] / src / GeomAlgoAPI / GeomAlgoAPI_STEPExport.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:    GEOMALGOAPI_STEPExport.cpp
4 // Created: May 14, 2015
5 // Author:  Sergey POKHODENKO
6
7 #include <GeomAlgoAPI_STEPExport.h>
8
9 #include "GeomAlgoAPI_Tools.h"
10
11 // OOCT includes
12 #include <IFSelect_ReturnStatus.hxx>
13 #include <STEPControl_Writer.hxx>
14 #include <Interface_Static.hxx>
15
16 bool STEPExport(const std::string& theFileName,
17                 const std::string& theFormatName,
18                 const TopoDS_Shape& theShape,
19                 std::string& theError)
20 {
21   #ifdef _DEBUG
22   std::cout << "Export STEP into file " << theFileName << std::endl;
23   #endif
24
25   try
26   {
27     // Set "C" numeric locale to save numbers correctly
28     GeomAlgoAPI_Tools::Localizer loc;
29
30     IFSelect_ReturnStatus status ;
31     //VRV: OCC 4.0 migration
32     STEPControl_Writer aWriter;
33     Interface_Static::SetCVal("xstep.cascade.unit","M");
34     Interface_Static::SetCVal("write.step.unit", "M");
35     Interface_Static::SetIVal("write.step.nonmanifold", 1);
36     status = aWriter.Transfer( theShape, STEPControl_AsIs );
37     //VRV: OCC 4.0 migration
38     if( status == IFSelect_RetDone )
39       status = aWriter.Write( theFileName.c_str() );
40
41     // Return previous locale
42     if( status == IFSelect_RetDone )
43       return true;
44   }
45   catch (Standard_Failure)
46   {
47     theError = "Exception catched in STEPExport";
48   }
49   return false;
50 }