Salome HOME
Issue #529 : 4.07. Import IGES, export to BREP, STEP, IGES - Remove redundant code...
[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 // OOCT includes
6 #include <IFSelect_ReturnStatus.hxx>
7 #include <STEPControl_Writer.hxx>
8 #include <Interface_Static.hxx>
9
10 namespace STEPExport {
11
12 bool Export(const TCollection_AsciiString& theFileName,
13             const TCollection_AsciiString& theFormatName,
14             const TopoDS_Shape& theShape,
15             TCollection_AsciiString& theError)
16 {
17   #ifdef _DEBUG
18   std::cout << "Export STEP into file " << theFileName.ToCString() << std::endl;
19   #endif
20
21   try
22   {
23 //    // Set "C" numeric locale to save numbers correctly
24 //    Kernel_Utils::Localizer loc;
25
26     IFSelect_ReturnStatus status ;
27     //VRV: OCC 4.0 migration
28     STEPControl_Writer aWriter;
29     Interface_Static::SetCVal("xstep.cascade.unit","M");
30     Interface_Static::SetCVal("write.step.unit", "M");
31     Interface_Static::SetIVal("write.step.nonmanifold", 1);
32     status = aWriter.Transfer( theShape, STEPControl_AsIs );
33     //VRV: OCC 4.0 migration
34     if( status == IFSelect_RetDone )
35       status = aWriter.Write( theFileName.ToCString() );
36
37     // Return previous locale
38     if( status == IFSelect_RetDone )
39       return true;
40   }
41   catch (Standard_Failure)
42   {
43     theError = "Exception catched in STEPExport";
44   }
45   return false;
46 }
47
48 } // namespace STEPExport