1 // Copyright (C) 2014-2024 CEA, EDF
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,
59 const std::string& theShapeFileName)
62 std::cout << "Export XAO into file " << theFileName << std::endl;
65 if (theFileName.empty() || !theXao) {
66 theError = "An invalid argument.";
71 XAO::BrepGeometry* aGeometry = dynamic_cast<XAO::BrepGeometry*>(theXao->getGeometry());
72 TopoDS_Shape aShape = aGeometry->getTopoDS_Shape();
73 bool aWasFree = aShape.Free(); // make top level topology free, same as imported
75 aShape.Free(Standard_True);
76 XAO::XaoExporter::saveToFile(theXao, theFileName, theShapeFileName);
78 aShape.Free(Standard_False);
79 } catch (XAO::XAO_Exception& e) {
86 //=============================================================================
90 //=============================================================================
91 const std::string XAOExportMem(XAO::Xao* theXao,
92 std::string& theError)
94 std::string aRetBuff ("");
97 std::cout << "Export XAO into memory buffer " << std::endl;
101 theError = "An invalid argument.";
106 XAO::BrepGeometry* aGeometry = dynamic_cast<XAO::BrepGeometry*>(theXao->getGeometry());
107 TopoDS_Shape aShape = aGeometry->getTopoDS_Shape();
108 bool aWasFree = aShape.Free(); // make top level topology free, same as imported
110 aShape.Free(Standard_True);
112 aRetBuff = XAO::XaoExporter::saveToXml(theXao);
115 aShape.Free(Standard_False);
116 } catch (XAO::XAO_Exception& e) {