Salome HOME
Issue #608: Usage of OCCT in interface -- Remove OCCT from *Export/Import interfaces...
[modules/shaper.git] / src / GeomAlgoAPI / GeomAlgoAPI_BREPExport.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:    GEOMALGOAPI_BREPExport.cpp
4 // Created: May 14, 2015
5 // Author:  Sergey POKHODENKO
6
7 #include <GeomAlgoAPI_BREPExport.h>
8
9 #include "GeomAlgoAPI_Tools.h"
10
11 #include <TopoDS_Shape.hxx>
12
13 #include <BRepTools.hxx>
14 #include <BRep_Builder.hxx>
15
16 //=============================================================================
17 /*!
18  *
19  */
20 //=============================================================================
21 bool BREPExport(const std::string& theFileName,
22                 const std::string&,
23                 const std::shared_ptr<GeomAPI_Shape>& theShape,
24                 std::string& theError)
25 {
26   #ifdef _DEBUG
27   std::cout << "Export BREP into file " << theFileName << std::endl;
28   #endif
29
30   if (!theShape.get()) {
31     theError = "BREP Export failed: An invalid argument";
32     return false;
33   }
34
35   // Set "C" numeric locale to save numbers correctly
36   GeomAlgoAPI_Tools::Localizer loc;
37
38   if (!BRepTools::Write(theShape->impl<TopoDS_Shape>(), theFileName.c_str())) {
39     theError = "BREP Export failed";
40     return false;
41   }
42   return true;
43 }