X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGeomAlgoAPI%2FGeomAlgoAPI_XAOExport.cpp;h=73e17a19a341d8fd7b6d48fde4e9c5f5ded6c604;hb=4c86b629d1bf8daa737f90b64e934c7bd22f6525;hp=be12b80aae2189e55d8616869693aedc5ff639f5;hpb=380f01e1fce1a012267d604a1190d04bf4659447;p=modules%2Fshaper.git diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_XAOExport.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_XAOExport.cpp index be12b80aa..73e17a19a 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_XAOExport.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_XAOExport.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2020 CEA/DEN, EDF R&D +// Copyright (C) 2014-2024 CEA, EDF // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -55,7 +55,8 @@ bool SetShapeToXAO(const std::shared_ptr& theShape, //============================================================================= bool XAOExport(const std::string& theFileName, XAO::Xao* theXao, - std::string& theError) + std::string& theError, + const std::string& theShapeFileName) { #ifdef _DEBUG std::cout << "Export XAO into file " << theFileName << std::endl; @@ -72,7 +73,7 @@ bool XAOExport(const std::string& theFileName, bool aWasFree = aShape.Free(); // make top level topology free, same as imported if (!aWasFree) aShape.Free(Standard_True); - XAO::XaoExporter::saveToFile(theXao, theFileName, ""); + XAO::XaoExporter::saveToFile(theXao, theFileName, theShapeFileName); if (!aWasFree) aShape.Free(Standard_False); } catch (XAO::XAO_Exception& e) { @@ -81,3 +82,40 @@ bool XAOExport(const std::string& theFileName, } return true; } + +//============================================================================= +/*! + * + */ +//============================================================================= +const std::string XAOExportMem(XAO::Xao* theXao, + std::string& theError) +{ + std::string aRetBuff (""); + +#ifdef _DEBUG + std::cout << "Export XAO into memory buffer " << std::endl; +#endif + + if (!theXao) { + theError = "An invalid argument."; + return aRetBuff; + } + + try { + XAO::BrepGeometry* aGeometry = dynamic_cast(theXao->getGeometry()); + TopoDS_Shape aShape = aGeometry->getTopoDS_Shape(); + bool aWasFree = aShape.Free(); // make top level topology free, same as imported + if (!aWasFree) + aShape.Free(Standard_True); + + aRetBuff = XAO::XaoExporter::saveToXml(theXao); + + if (!aWasFree) + aShape.Free(Standard_False); + } catch (XAO::XAO_Exception& e) { + theError = e.what(); + return aRetBuff; + } + return aRetBuff; +}