1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 #include <GeomAlgoAPI_IGESImport.h>
6 #include <IGESControl_Reader.hxx>
7 #include <IGESData_IGESModel.hxx>
9 //=============================================================================
13 //=============================================================================
15 namespace IGESImport {
16 TopoDS_Shape Import(const TCollection_AsciiString& theFileName,
17 const TCollection_AsciiString&,
18 TCollection_AsciiString& theError, const TDF_Label&)
21 std::cout << "Import IGES from file " << theFileName << std::endl;
23 TopoDS_Shape aResShape;
25 // bool anIsIgnoreUnits = false;
27 IGESControl_Reader aReader;
29 IFSelect_ReturnStatus status = aReader.ReadFile( theFileName.ToCString() );
31 if (status == IFSelect_RetDone) {
32 // if( anIsIgnoreUnits ) {
33 // // need re-scale a model, set UnitFlag to 'meter'
34 // Handle(IGESData_IGESModel) aModel =
35 // Handle(IGESData_IGESModel)::DownCast( aReader.Model() );
36 // if( !aModel.IsNull() ) {
37 // IGESData_GlobalSection aGS = aModel->GlobalSection();
38 // aGS.SetUnitFlag(6);
39 // aModel->SetGlobalSection(aGS);
44 std::cout << "ImportIGES : all Geometry Transfer" << std::endl;
46 aReader.ClearShapes();
47 aReader.TransferRoots();
50 std::cout << "ImportIGES : count of shapes produced = " << aReader.NbShapes() << std::endl;
52 aResShape = aReader.OneShape();
56 case IFSelect_RetVoid:
57 theError = "Nothing created or No data to process";
59 case IFSelect_RetError:
60 theError = "Error in command or input data";
62 case IFSelect_RetFail:
63 theError = "Execution was run, but has failed";
65 case IFSelect_RetStop:
66 theError = "Execution has been stopped. Quite possible, an exception was raised";
69 theError = "Wrong format of the imported file. Can't import file.";
75 catch( Standard_Failure ) {
76 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
77 theError = aFail->GetMessageString();