-// Copyright (C) 2014-2021 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
aGeomShape->setImpl(new TopoDS_Shape(aShape));
return aGeomShape;
}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+std::shared_ptr<GeomAPI_Shape> 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<GeomAPI_Shape>();
+ }
+
+ 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<XAO::BrepGeometry*>(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<GeomAPI_Shape> aGeomShape(new GeomAPI_Shape);
+ aGeomShape->setImpl(new TopoDS_Shape(aShape));
+ return aGeomShape;
+}