1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: GEOMALGOAPI_XAOImport.cpp
4 // Created: Nov 25, 2015
5 // Author: Sergey POKHODENKO
7 #include <GeomAlgoAPI_XAOImport.h>
9 #include <TopoDS_Shape.hxx>
11 #include <XAO_XaoExporter.hxx>
12 #include <XAO_BrepGeometry.hxx>
14 //=============================================================================
18 //=============================================================================
19 std::shared_ptr<GeomAPI_Shape> XAOImport(const std::string& theFileName,
20 std::string& theError,
24 std::cout << "Import XAO from file " << theFileName << std::endl;
26 if (theFileName.empty() || !theXao) {
27 theError = "An invalid argument.";
28 return std::shared_ptr<GeomAPI_Shape>();
33 if (XAO::XaoExporter::readFromFile(theFileName, theXao)) {
34 XAO::Geometry* aGeometry = theXao->getGeometry();
35 XAO::Format aFormat = aGeometry->getFormat();
36 if (aFormat == XAO::BREP) {
37 if (XAO::BrepGeometry* aBrepGeometry = dynamic_cast<XAO::BrepGeometry*>(aGeometry))
38 aShape = aBrepGeometry->getTopoDS_Shape();
40 theError = "Unsupported XAO geometry format:" + XAO::XaoUtils::shapeFormatToString(aFormat);
44 theError = "XAO object was not read successful";
47 } catch (XAO::XAO_Exception& e) {
52 std::shared_ptr<GeomAPI_Shape> aGeomShape(new GeomAPI_Shape);
53 aGeomShape->setImpl(new TopoDS_Shape(aShape));