]> SALOME platform Git repositories - modules/med.git/blob - src/MEDMEM/MEDMEM_GibiMeshDriver.hxx
Salome HOME
adding some castem mesh file to test the GIBI driver of Med Memory.
[modules/med.git] / src / MEDMEM / MEDMEM_GibiMeshDriver.hxx
1 #ifndef GIBI_MESH_DRIVER_HXX
2 #define GIBI_MESH_DRIVER_HXX
3
4 #include <string>
5 #include <vector>
6 #include <fstream>
7
8 #include "MEDMEM_define.hxx"
9 #include "MEDMEM_GenDriver.hxx"
10
11 #include "MEDMEM_STRING.hxx"
12 #include "MEDMEM_Exception.hxx"
13 #include "utilities.h"
14
15 /////
16 #include <sstream>
17 #include <iomanip>
18 /////
19
20 class MESH;
21 class FAMILY;
22 class GROUP;
23 class CONNECTIVITY;
24
25 /*!
26
27   Driver GIBI for MESH.
28
29   Generic part : implement the readopen and close methods.
30   
31 */
32
33
34 class GIBI_MESH_DRIVER : public GENDRIVER
35 {
36 protected:
37   
38   MESH *          _ptrMesh;
39   // A VOIR FILE DESCRIPTEUR ? MED_FR::med_idt _medIdt;
40   string          _meshName;
41   /////
42   ifstream _gibi;
43   
44   // tableau de correspondance des types géométriques de CASTEM -> MED
45   static const size_t nb_geometrie_gibi=47;
46   static const medGeometryElement geomGIBItoMED[nb_geometrie_gibi] =  // A COMPLETER
47     {   /*1 */ MED_POINT1 ,/*2 */ MED_SEG2   ,/*3 */ MED_SEG3   ,/*4 */ MED_TRIA3  ,/*5 */ MED_NONE   ,
48         /*6 */ MED_TRIA6  ,/*7 */ MED_NONE   ,/*8 */ MED_QUAD4  ,/*9 */ MED_NONE   ,/*10*/ MED_QUAD8  ,
49         /*11*/ MED_NONE   ,/*12*/ MED_NONE   ,/*13*/ MED_NONE   ,/*14*/ MED_HEXA8  ,/*15*/ MED_HEXA20 ,
50         /*16*/ MED_PENTA6 ,/*17*/ MED_PENTA15,/*18*/ MED_NONE   ,/*19*/ MED_NONE   ,/*20*/ MED_NONE   ,
51         /*21*/ MED_NONE   ,/*22*/ MED_NONE   ,/*23*/ MED_TETRA4 ,/*24*/ MED_TETRA10,/*25*/ MED_PYRA5  ,
52         /*26*/ MED_PYRA13 ,/*27*/ MED_NONE   ,/*28*/ MED_NONE   ,/*29*/ MED_NONE   ,/*30*/ MED_NONE   ,
53         /*31*/ MED_NONE   ,/*32*/ MED_NONE   ,/*33*/ MED_NONE   ,/*34*/ MED_NONE   ,/*35*/ MED_NONE   ,
54         /*36*/ MED_NONE   ,/*37*/ MED_NONE   ,/*38*/ MED_NONE   ,/*39*/ MED_NONE   ,/*40*/ MED_NONE   ,
55         /*41*/ MED_NONE   ,/*42*/ MED_NONE   ,/*43*/ MED_NONE   ,/*44*/ MED_NONE   ,/*45*/ MED_NONE   ,
56         /*46*/ MED_NONE   ,/*47*/ MED_NONE   };
57   /////
58
59 public :
60
61   /*!
62     Constructor.
63   */
64   GIBI_MESH_DRIVER() ;
65   /*!
66     Constructor.
67   */
68   GIBI_MESH_DRIVER(const string & fileName,  
69                   MESH * ptrMesh, 
70                   med_mode_acces accessMode) ;
71   /*!
72     Copy constructor.
73   */
74   GIBI_MESH_DRIVER(const GIBI_MESH_DRIVER & driver) ;
75
76   /*!
77     Destructor.
78   */
79   virtual ~GIBI_MESH_DRIVER() ;
80
81   void open() throw (MEDEXCEPTION);
82   void close() throw (MEDEXCEPTION);
83
84   virtual void write( void ) const = 0 ;
85   virtual void read ( void ) = 0 ;
86
87   /*!
88     Set the name of the MESH asked in file.
89
90     It could be different than the name of the MESH object.
91   */
92   void   setMeshName(const string & meshName) ;
93   /*!
94     Get the name of the MESH asked in file.
95   */
96   string getMeshName() const ;
97
98 private:
99   virtual GENDRIVER * copy ( void ) const = 0 ;
100
101 };
102
103
104 class GIBI_MESH_RDONLY_DRIVER : public virtual GIBI_MESH_DRIVER
105 {
106  
107 public :
108   
109   /*!
110     Constructor.
111   */
112   GIBI_MESH_RDONLY_DRIVER() ;
113   /*!
114     Constructor.
115   */
116   GIBI_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh) ;
117   /*!
118     Copy constructor.
119   */
120   GIBI_MESH_RDONLY_DRIVER(const GIBI_MESH_RDONLY_DRIVER & driver) ;
121
122   /*!
123     Destructor.
124   */
125   virtual ~GIBI_MESH_RDONLY_DRIVER() ;
126   
127   /*!
128     Return a MEDEXCEPTION : it is the read-only driver.
129   */
130   void write( void ) const throw (MEDEXCEPTION);
131   /*!
132     Read MESH in the specified file.
133   */
134   void read ( void ) throw (MEDEXCEPTION);
135
136 private:
137  
138   GENDRIVER * copy ( void ) const ;
139
140 };
141
142 /*!
143
144   Driver Med for MESH : Write only.
145
146   Implement write method.
147
148 */
149
150 class GIBI_MESH_WRONLY_DRIVER : public virtual GIBI_MESH_DRIVER {
151   
152 public :
153   
154   /*!
155     Constructor.
156   */
157   GIBI_MESH_WRONLY_DRIVER() ;
158   /*!
159     Constructor.
160   */
161   GIBI_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh) ;
162   /*!
163     Copy constructor.
164   */
165   GIBI_MESH_WRONLY_DRIVER(const GIBI_MESH_WRONLY_DRIVER & driver) ;
166
167   /*!
168     Destructor.
169   */
170   virtual ~GIBI_MESH_WRONLY_DRIVER() ;
171
172   /*!
173     Write MESH in the specified file.
174   */
175   void write( void ) const throw (MEDEXCEPTION);
176   /*!
177     Return a MEDEXCEPTION : it is the write-only driver.
178   */
179   void read ( void ) throw (MEDEXCEPTION);
180
181 private:
182
183   GENDRIVER * copy ( void ) const ;
184 };
185
186
187 /*!
188
189   Driver GIBI for MESH : Read write.
190   - Use read method from GIBI_MESH_RDONLY_DRIVER
191   - Use write method from GIBI_MESH_WRONLY_DRIVER
192
193 */
194
195 class GIBI_MESH_RDWR_DRIVER : public GIBI_MESH_RDONLY_DRIVER, public GIBI_MESH_WRONLY_DRIVER {
196
197 public :
198
199   /*!
200     Constructor.
201   */
202   GIBI_MESH_RDWR_DRIVER() ;
203   /*!
204     Constructor.
205   */
206   GIBI_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) ;
207   /*!
208     Copy constructor.
209   */
210   GIBI_MESH_RDWR_DRIVER(const GIBI_MESH_RDWR_DRIVER & driver) ;
211
212   /*!
213     Destructor.
214   */
215   ~GIBI_MESH_RDWR_DRIVER() ;
216
217   /*!
218     Write MESH in the specified file.
219   */
220   void write(void) const throw (MEDEXCEPTION);
221   /*!
222     Read MESH in the specified file.
223   */
224   void read (void) throw (MEDEXCEPTION);
225
226 private:
227   GENDRIVER * copy(void) const ;
228
229 };
230
231
232 #endif /* GIBI_MESH_DRIVER_HXX */