]> SALOME platform Git repositories - modules/geom.git/blob - src/IGESExport/IGESExport.cxx
Salome HOME
PAL12003: Problem when importing IGS geometry. Export to IGES 5.3 (supporting BRep...
[modules/geom.git] / src / IGESExport / IGESExport.cxx
1 // File:        IGESExport.cxx
2 // Created:     Wed May 19 14:49:45 2004
3 // Author:      Pavel TELKOV
4 //              <ptv@mutex.nnov.opencascade.com>
5
6 #include "utilities.h"
7
8 #include <IGESControl_Controller.hxx>
9 #include <IGESControl_Writer.hxx>
10 #include <Interface_Static.hxx>
11
12 #include <TCollection_AsciiString.hxx>
13 #include <TopoDS_Shape.hxx>
14
15 //=============================================================================
16 /*!
17  *
18  */
19 //=============================================================================
20
21 extern "C"
22 {
23 #ifdef WNT
24   __declspec(__dllexport)
25 #endif
26   int Export(const TopoDS_Shape& theShape,
27              const TCollection_AsciiString& theFileName,
28              const TCollection_AsciiString& theFormatName)
29   {
30     MESSAGE("Export IGES into file " << theFileName.ToCString());
31     try 
32     {
33       // define, whether to write only faces (5.1 IGES format)
34       // or shells and solids also (5.3 IGES format)
35       int aBrepMode = 0;
36       if (theFormatName.IsEqual("IGES_5_3"))
37         aBrepMode = 1;
38
39       // initialize writer
40       IGESControl_Controller::Init();
41       //IGESControl_Writer ICW (Interface_Static::CVal("write.iges.unit"),
42       //                        Interface_Static::IVal("write.iges.brep.mode"));
43       IGESControl_Writer ICW (Interface_Static::CVal("write.iges.unit"), aBrepMode);
44         
45       // perform shape writing
46       ICW.AddShape( theShape );
47       ICW.ComputeModel();
48       if ( ICW.Write( theFileName.ToCString() ) )
49         return 1;
50     }
51     catch(Standard_Failure) 
52     {
53       //THROW_SALOME_CORBA_EXCEPTION("Exception catched in IGESExport", SALOME::BAD_PARAM);
54     }
55     return 0;
56   }
57 }