]> SALOME platform Git repositories - modules/shaper.git/blob - src/GeomAlgoAPI/GeomAlgoAPI_STEPExport.cpp
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 namespace STEPExport {
17
18 bool Export(const std::string& theFileName,
19             const std::string& theFormatName,
20             const TopoDS_Shape& theShape,
21             std::string& theError)
22 {
23   #ifdef _DEBUG
24   std::cout << "Export STEP into file " << theFileName << std::endl;
25   #endif
26
27   try
28   {
29     // Set "C" numeric locale to save numbers correctly
30     GeomAlgoAPI_Tools::Localizer loc;
31
32     IFSelect_ReturnStatus status ;
33     //VRV: OCC 4.0 migration
34     STEPControl_Writer aWriter;
35     Interface_Static::SetCVal("xstep.cascade.unit","M");
36     Interface_Static::SetCVal("write.step.unit", "M");
37     Interface_Static::SetIVal("write.step.nonmanifold", 1);
38     status = aWriter.Transfer( theShape, STEPControl_AsIs );
39     //VRV: OCC 4.0 migration
40     if( status == IFSelect_RetDone )
41       status = aWriter.Write( theFileName.c_str() );
42
43     // Return previous locale
44     if( status == IFSelect_RetDone )
45       return true;
46   }
47   catch (Standard_Failure)
48   {
49     theError = "Exception catched in STEPExport";
50   }
51   return false;
52 }
53
54 } // namespace STEPExport