1 // Copyright (C) 2014-2020 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include <GeomAlgoAPI_XAOExport.h>
22 #include "GeomAlgoAPI_Tools.h"
24 #include <TopoDS_Shape.hxx>
26 #include <XAO_XaoExporter.hxx>
27 #include <XAO_BrepGeometry.hxx>
29 //=============================================================================
30 bool SetShapeToXAO(const std::shared_ptr<GeomAPI_Shape>& theShape,
32 std::string& theError)
34 if (!theShape.get() || !theXao) {
35 theError = "An invalid argument.";
39 TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
41 XAO::BrepGeometry* aGeometry = new XAO::BrepGeometry;
42 theXao->setGeometry(aGeometry);
43 aGeometry->setTopoDS_Shape(aShape);
44 } catch (XAO::XAO_Exception& e) {
51 //=============================================================================
55 //=============================================================================
56 bool XAOExport(const std::string& theFileName,
58 std::string& theError)
61 std::cout << "Export XAO into file " << theFileName << std::endl;
64 if (theFileName.empty() || !theXao) {
65 theError = "An invalid argument.";
70 XAO::BrepGeometry* aGeometry = dynamic_cast<XAO::BrepGeometry*>(theXao->getGeometry());
71 TopoDS_Shape aShape = aGeometry->getTopoDS_Shape();
72 bool aWasFree = aShape.Free(); // make top level topology free, same as imported
74 aShape.Free(Standard_True);
75 XAO::XaoExporter::saveToFile(theXao, theFileName, "");
77 aShape.Free(Standard_False);
78 } catch (XAO::XAO_Exception& e) {