]> SALOME platform Git repositories - modules/shaper.git/blob - src/GeomAlgoAPI/GeomAlgoAPI_XAOExport.cpp
Salome HOME
Make XAO export
[modules/shaper.git] / src / GeomAlgoAPI / GeomAlgoAPI_XAOExport.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:    GEOMALGOAPI_XAOExport.cpp
4 // Created: Nov 27, 2015
5 // Author:  Sergey POKHODENKO
6
7 #include <GeomAlgoAPI_XAOExport.h>
8
9 #include "GeomAlgoAPI_Tools.h"
10
11 #include <TopoDS_Shape.hxx>
12
13 #include <XAO_XaoExporter.hxx>
14 #include <XAO_BrepGeometry.hxx>
15
16 //=============================================================================
17 /*!
18  *
19  */
20 //=============================================================================
21 bool XAOExport(const std::string& theFileName,
22                const std::shared_ptr<GeomAPI_Shape>& theShape,
23                XAO::Xao* theXao,
24                std::string& theError)
25 {
26   #ifdef _DEBUG
27   std::cout << "Export XAO into file " << theFileName << std::endl;
28   #endif
29
30   if (theFileName.empty() || !theShape.get() || !theXao) {
31     theError = "An invalid argument.";
32     return false;
33   }
34
35   TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
36   try {
37     XAO::BrepGeometry* aGeometry = new XAO::BrepGeometry;
38     theXao->setGeometry(aGeometry);
39     aGeometry->setTopoDS_Shape(aShape);
40     XAO::XaoExporter::saveToFile(theXao, theFileName);
41   } catch (XAO::XAO_Exception& e) {
42     theError = e.what();
43     return false;
44   }
45   return true;
46 }