1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: GEOMALGOAPI_IGESImport.cpp
4 // Created: May 14, 2015
5 // Author: Sergey POKHODENKO
7 #include <GeomAlgoAPI_IGESImport.h>
9 #include <TopoDS_Shape.hxx>
12 #include <IGESControl_Reader.hxx>
13 #include <IGESData_IGESModel.hxx>
15 //=============================================================================
19 //=============================================================================
20 std::shared_ptr<GeomAPI_Shape> IGESImport(const std::string& theFileName,
22 std::string& theError)
25 std::cout << "Import IGES from file " << theFileName << std::endl;
28 IGESControl_Reader aReader;
30 IFSelect_ReturnStatus status = aReader.ReadFile( theFileName.c_str() );
32 if (status == IFSelect_RetDone) {
34 std::cout << "ImportIGES : all Geometry Transfer" << std::endl;
36 aReader.ClearShapes();
37 aReader.TransferRoots();
40 std::cout << "ImportIGES : count of shapes produced = " << aReader.NbShapes() << std::endl;
42 aShape = aReader.OneShape();
46 case IFSelect_RetVoid:
47 theError = "Nothing created or No data to process";
49 case IFSelect_RetError:
50 theError = "Error in command or input data";
52 case IFSelect_RetFail:
53 theError = "Execution was run, but has failed";
55 case IFSelect_RetStop:
56 theError = "Execution has been stopped. Quite possible, an exception was raised";
59 theError = "Wrong format of the imported file. Can't import file.";
65 catch( Standard_Failure ) {
66 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
67 theError = aFail->GetMessageString();
71 std::shared_ptr<GeomAPI_Shape> aGeomShape(new GeomAPI_Shape);
72 aGeomShape->setImpl(new TopoDS_Shape(aShape));