1 // Copyright (C) 2014-2020 CEA/DEN, EDF R&D
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_IGESImport.h>
22 #include <TopoDS_Shape.hxx>
25 #include <IGESControl_Reader.hxx>
26 #include <IGESData_IGESModel.hxx>
28 //=============================================================================
32 //=============================================================================
33 std::shared_ptr<GeomAPI_Shape> IGESImport(const std::string& theFileName,
35 std::string& theError)
38 std::cout << "Import IGES from file " << theFileName << std::endl;
41 IGESControl_Reader aReader;
43 IFSelect_ReturnStatus status = aReader.ReadFile( theFileName.c_str() );
45 if (status == IFSelect_RetDone) {
47 std::cout << "ImportIGES : all Geometry Transfer" << std::endl;
49 aReader.ClearShapes();
50 aReader.TransferRoots();
53 std::cout << "ImportIGES : count of shapes produced = " << aReader.NbShapes() << std::endl;
55 aShape = aReader.OneShape();
59 case IFSelect_RetVoid:
60 theError = "Nothing created or No data to process";
62 case IFSelect_RetError:
63 theError = "Error in command or input data";
65 case IFSelect_RetFail:
66 theError = "Execution was run, but has failed";
68 case IFSelect_RetStop:
69 theError = "Execution has been stopped. Quite possible, an exception was raised";
72 theError = "Wrong format of the imported file. Can't import file.";
78 catch( Standard_Failure const& anException) {
79 theError = anException.GetMessageString();
83 std::shared_ptr<GeomAPI_Shape> aGeomShape(new GeomAPI_Shape);
84 aGeomShape->setImpl(new TopoDS_Shape(aShape));