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