]> SALOME platform Git repositories - modules/geom.git/blob - src/IGESImport/IGESImport.cxx
Salome HOME
840f2583525684e96ed1eeef051ad960fa056a2a
[modules/geom.git] / src / IGESImport / IGESImport.cxx
1 // File:        IGESImport.cxx
2 // Created:     Wed May 19 14:36:35 2004
3 // Author:      Pavel TELKOV
4 //              <ptv@mutex.nnov.opencascade.com>
5
6 #include "utilities.h"
7
8 #include <IFSelect_ReturnStatus.hxx>
9 #include <IGESControl_Reader.hxx>
10
11 #include <TCollection_AsciiString.hxx>
12 #include <TopoDS_Shape.hxx>
13
14 #ifdef WNT
15 #include <SALOME_WNT.hxx>
16 #else
17 #define SALOME_WNT_EXPORT
18 #endif
19
20 //=============================================================================
21 /*!
22  *
23  */
24 //=============================================================================
25
26 extern "C"
27 {
28 SALOME_WNT_EXPORT
29   TopoDS_Shape Import (const TCollection_AsciiString& theFileName,
30                        TCollection_AsciiString&       theError)
31   {
32     IGESControl_Reader aReader;
33     TopoDS_Shape aResShape;
34     try {
35       IFSelect_ReturnStatus status = aReader.ReadFile(theFileName.ToCString());
36
37       if (status == IFSelect_RetDone) {
38         MESSAGE("ImportIGES : all Geometry Transfer");
39         //OCC 5.1.2 porting
40         //     aReader.Clear();
41         //     aReader.TransferRoots(false);
42         aReader.ClearShapes();
43         aReader.TransferRoots();
44
45         MESSAGE("ImportIGES : count of shapes produced = " << aReader.NbShapes());
46         aResShape = aReader.OneShape();
47
48       } else {
49 //        switch (status) {
50 //        case IFSelect_RetVoid:
51 //          theError = "Nothing created or No data to process";
52 //          break;
53 //        case IFSelect_RetError:
54 //          theError = "Error in command or input data";
55 //          break;
56 //        case IFSelect_RetFail:
57 //          theError = "Execution was run, but has failed";
58 //          break;
59 //        case IFSelect_RetStop:
60 //          theError = "Execution has been stopped. Quite possible, an exception was raised";
61 //          break;
62 //        default:
63 //          break;
64 //        }
65         theError = "Wrong format of the imported file. Can't import file.";
66         aResShape.Nullify();
67       }
68     }
69     catch(Standard_Failure) {
70       Handle(Standard_Failure) aFail = Standard_Failure::Caught();
71       theError = aFail->GetMessageString();
72       aResShape.Nullify();
73     }
74     return aResShape;
75   }
76 }