]> SALOME platform Git repositories - modules/shaper.git/blob - src/GeomAlgoAPI/GeomAlgoAPI_IGESImport.cpp
Salome HOME
Fix some header comments in files
[modules/shaper.git] / src / GeomAlgoAPI / GeomAlgoAPI_IGESImport.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:    GEOMALGOAPI_IGESImport.cpp
4 // Created: May 14, 2015
5 // Author:  Sergey POKHODENKO
6
7 #include <GeomAlgoAPI_IGESImport.h>
8
9 // OOCT includes
10 #include <IGESControl_Reader.hxx>
11 #include <IGESData_IGESModel.hxx>
12
13 //=============================================================================
14 /*!
15  *
16  */
17 //=============================================================================
18 TopoDS_Shape IGESImport(const std::string& theFileName,
19                         const std::string&,
20                         std::string& theError)
21 {
22   #ifdef _DEBUG
23   std::cout << "Import IGES from file " << theFileName << std::endl;
24   #endif
25   TopoDS_Shape aResShape;
26   IGESControl_Reader aReader;
27   try {
28     IFSelect_ReturnStatus status = aReader.ReadFile( theFileName.c_str() );
29
30     if (status == IFSelect_RetDone) {
31       #ifdef _DEBUG
32       std::cout << "ImportIGES : all Geometry Transfer" << std::endl;
33       #endif
34       aReader.ClearShapes();
35       aReader.TransferRoots();
36
37       #ifdef _DEBUG
38       std::cout << "ImportIGES : count of shapes produced = " << aReader.NbShapes() << std::endl;
39       #endif
40       aResShape = aReader.OneShape();
41     }
42     else {
43       switch (status) {
44         case IFSelect_RetVoid:
45           theError = "Nothing created or No data to process";
46           break;
47         case IFSelect_RetError:
48           theError = "Error in command or input data";
49           break;
50         case IFSelect_RetFail:
51           theError = "Execution was run, but has failed";
52           break;
53         case IFSelect_RetStop:
54           theError = "Execution has been stopped. Quite possible, an exception was raised";
55           break;
56         default:
57           theError = "Wrong format of the imported file. Can't import file.";
58           break;
59       }
60       aResShape.Nullify();
61     }
62   }
63   catch( Standard_Failure ) {
64     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
65     theError = aFail->GetMessageString();
66     aResShape.Nullify();
67   }
68
69   return aResShape;
70 }