X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGeomAlgoAPI%2FGeomAlgoAPI_XAOImport.cpp;h=5b241497642e6d8c6a15fcbedf5aa8bbd50893e4;hb=9e9e32f010b4174ecd0ba2b016f14fee16775365;hp=4303861eefb6885cad5ef291860ba50480addae2;hpb=6e421e939851e0de46554ae45a3ca0e1f67cd91d;p=modules%2Fshaper.git diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_XAOImport.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_XAOImport.cpp index 4303861ee..5b2414976 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_XAOImport.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_XAOImport.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2019 CEA/DEN, EDF R&D +// Copyright (C) 2014-2023 CEA, EDF // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -66,3 +66,46 @@ std::shared_ptr XAOImport(const std::string& theFileName, aGeomShape->setImpl(new TopoDS_Shape(aShape)); return aGeomShape; } + +//============================================================================= +/*! + * + */ +//============================================================================= +std::shared_ptr XAOImportMem(const std::string& theMemoryBuff, + std::string& theError, + XAO::Xao* theXao) +{ +#ifdef _DEBUG + std::cout << "Import XAO from file " << theFileName << std::endl; +#endif + if (theMemoryBuff.empty() || !theXao) { + theError = "An invalid argument."; + return std::shared_ptr(); + } + + TopoDS_Shape aShape; + try { + if (XAO::XaoExporter::setXML(theMemoryBuff, theXao)) { + XAO::Geometry* aGeometry = theXao->getGeometry(); + XAO::Format aFormat = aGeometry->getFormat(); + if (aFormat == XAO::BREP) { + if (XAO::BrepGeometry* aBrepGeometry = dynamic_cast(aGeometry)) + aShape = aBrepGeometry->getTopoDS_Shape(); + } else { + theError = "Unsupported XAO geometry format:" + XAO::XaoUtils::shapeFormatToString(aFormat); + aShape.Nullify(); + } + } else { + theError = "XAO object was not read successful"; + aShape.Nullify(); + } + } catch (XAO::XAO_Exception& e) { + theError = e.what(); + aShape.Nullify(); + } + + std::shared_ptr aGeomShape(new GeomAPI_Shape); + aGeomShape->setImpl(new TopoDS_Shape(aShape)); + return aGeomShape; +}