Salome HOME
Issue #1834: Fix length of lines
[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 bool SetShapeToXAO(const std::shared_ptr<GeomAPI_Shape>& theShape,
18                    XAO::Xao* theXao,
19                    std::string& theError)
20 {
21   if (!theShape.get() || !theXao) {
22     theError = "An invalid argument.";
23     return false;
24   }
25
26   TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
27   try {
28     XAO::BrepGeometry* aGeometry = new XAO::BrepGeometry;
29     theXao->setGeometry(aGeometry);
30     aGeometry->setTopoDS_Shape(aShape);
31   } catch (XAO::XAO_Exception& e) {
32     theError = e.what();
33     return false;
34   }
35   return true;
36 }
37
38 //=============================================================================
39 /*!
40  *
41  */
42 //=============================================================================
43 bool XAOExport(const std::string& theFileName,
44                XAO::Xao* theXao,
45                std::string& theError)
46 {
47   #ifdef _DEBUG
48   std::cout << "Export XAO into file " << theFileName << std::endl;
49   #endif
50
51   if (theFileName.empty() || !theXao) {
52     theError = "An invalid argument.";
53     return false;
54   }
55
56   try {
57     XAO::XaoExporter::saveToFile(theXao, theFileName);
58   } catch (XAO::XAO_Exception& e) {
59     theError = e.what();
60     return false;
61   }
62   return true;
63 }