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