Salome HOME
f0cb68c8b9443dec63b9f5c2c1113fcff749b44b
[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 //=============================================================================
15 /*!
16  *
17  */
18 //=============================================================================
19
20 extern "C"
21 {
22 #ifdef WNT
23   __declspec(__dllexport)
24 #endif
25   TopoDS_Shape Import (const TCollection_AsciiString& theFileName,
26                        TCollection_AsciiString&       theError)
27   {
28     IGESControl_Reader aReader;
29     TopoDS_Shape aResShape;
30     try {
31       IFSelect_ReturnStatus status = aReader.ReadFile(theFileName.ToCString());
32
33       if (status == IFSelect_RetDone) {
34         MESSAGE("ImportIGES : all Geometry Transfer");
35         //OCC 5.1.2 porting
36         //     aReader.Clear();
37         //     aReader.TransferRoots(false);
38         aReader.ClearShapes();
39         aReader.TransferRoots();
40
41         MESSAGE("ImportIGES : count of shapes produced = " << aReader.NbShapes());
42         aResShape = aReader.OneShape();
43
44       } else {
45 //        switch (status) {
46 //        case IFSelect_RetVoid:
47 //          theError = "Nothing created or No data to process";
48 //          break;
49 //        case IFSelect_RetError:
50 //          theError = "Error in command or input data";
51 //          break;
52 //        case IFSelect_RetFail:
53 //          theError = "Execution was run, but has failed";
54 //          break;
55 //        case IFSelect_RetStop:
56 //          theError = "Execution has been stopped. Quite possible, an exception was raised";
57 //          break;
58 //        default:
59 //          break;
60 //        }
61         theError = "Wrong format of the imported file. Can't import file.";
62         aResShape.Nullify();
63       }
64     }
65     catch(Standard_Failure) {
66       Handle(Standard_Failure) aFail = Standard_Failure::Caught();
67       theError = aFail->GetMessageString();
68       aResShape.Nullify();
69     }
70     return aResShape;
71   }
72 }