Salome HOME
DCQ : Merge with Ecole Ete a6.
[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];
46   /////
47
48 public :
49
50   /*!
51     Constructor.
52   */
53   GIBI_MESH_DRIVER() ;
54   /*!
55     Constructor.
56   */
57   GIBI_MESH_DRIVER(const string & fileName,  
58                   MESH * ptrMesh, 
59                   med_mode_acces accessMode) ;
60   /*!
61     Copy constructor.
62   */
63   GIBI_MESH_DRIVER(const GIBI_MESH_DRIVER & driver) ;
64
65   /*!
66     Destructor.
67   */
68   virtual ~GIBI_MESH_DRIVER() ;
69
70   void open() throw (MEDEXCEPTION);
71   void close() throw (MEDEXCEPTION);
72
73   virtual void write( void ) const = 0 ;
74   virtual void read ( void ) = 0 ;
75
76   /*!
77     Set the name of the MESH asked in file.
78
79     It could be different than the name of the MESH object.
80   */
81   void   setMeshName(const string & meshName) ;
82   /*!
83     Get the name of the MESH asked in file.
84   */
85   string getMeshName() const ;
86
87 private:
88   virtual GENDRIVER * copy ( void ) const = 0 ;
89
90 };
91
92
93 class GIBI_MESH_RDONLY_DRIVER : public virtual GIBI_MESH_DRIVER
94 {
95  
96 public :
97   
98   /*!
99     Constructor.
100   */
101   GIBI_MESH_RDONLY_DRIVER() ;
102   /*!
103     Constructor.
104   */
105   GIBI_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh) ;
106   /*!
107     Copy constructor.
108   */
109   GIBI_MESH_RDONLY_DRIVER(const GIBI_MESH_RDONLY_DRIVER & driver) ;
110
111   /*!
112     Destructor.
113   */
114   virtual ~GIBI_MESH_RDONLY_DRIVER() ;
115   
116   /*!
117     Return a MEDEXCEPTION : it is the read-only driver.
118   */
119   void write( void ) const throw (MEDEXCEPTION);
120   /*!
121     Read MESH in the specified file.
122   */
123   void read ( void ) throw (MEDEXCEPTION);
124
125 private:
126  
127   GENDRIVER * copy ( void ) const ;
128
129 };
130
131 /*!
132
133   Driver Med for MESH : Write only.
134
135   Implement write method.
136
137 */
138
139 class GIBI_MESH_WRONLY_DRIVER : public virtual GIBI_MESH_DRIVER {
140   
141 public :
142   
143   /*!
144     Constructor.
145   */
146   GIBI_MESH_WRONLY_DRIVER() ;
147   /*!
148     Constructor.
149   */
150   GIBI_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh) ;
151   /*!
152     Copy constructor.
153   */
154   GIBI_MESH_WRONLY_DRIVER(const GIBI_MESH_WRONLY_DRIVER & driver) ;
155
156   /*!
157     Destructor.
158   */
159   virtual ~GIBI_MESH_WRONLY_DRIVER() ;
160
161   /*!
162     Write MESH in the specified file.
163   */
164   void write( void ) const throw (MEDEXCEPTION);
165   /*!
166     Return a MEDEXCEPTION : it is the write-only driver.
167   */
168   void read ( void ) throw (MEDEXCEPTION);
169
170 private:
171
172   GENDRIVER * copy ( void ) const ;
173 };
174
175
176 /*!
177
178   Driver GIBI for MESH : Read write.
179   - Use read method from GIBI_MESH_RDONLY_DRIVER
180   - Use write method from GIBI_MESH_WRONLY_DRIVER
181
182 */
183
184 class GIBI_MESH_RDWR_DRIVER : public GIBI_MESH_RDONLY_DRIVER, public GIBI_MESH_WRONLY_DRIVER {
185
186 public :
187
188   /*!
189     Constructor.
190   */
191   GIBI_MESH_RDWR_DRIVER() ;
192   /*!
193     Constructor.
194   */
195   GIBI_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) ;
196   /*!
197     Copy constructor.
198   */
199   GIBI_MESH_RDWR_DRIVER(const GIBI_MESH_RDWR_DRIVER & driver) ;
200
201   /*!
202     Destructor.
203   */
204   ~GIBI_MESH_RDWR_DRIVER() ;
205
206   /*!
207     Write MESH in the specified file.
208   */
209   void write(void) const throw (MEDEXCEPTION);
210   /*!
211     Read MESH in the specified file.
212   */
213   void read (void) throw (MEDEXCEPTION);
214
215 private:
216   GENDRIVER * copy(void) const ;
217
218 };
219 };
220
221
222 #endif /* GIBI_MESH_DRIVER_HXX */