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