]> SALOME platform Git repositories - modules/med.git/blob - src/MEDMEM/MEDMEM_MedMeshDriver.hxx
Salome HOME
Merge from BR_V5_DEV 16Feb09
[modules/med.git] / src / MEDMEM / MEDMEM_MedMeshDriver.hxx
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 #ifndef MED_MESH_DRIVER_HXX
23 #define MED_MESH_DRIVER_HXX
24
25 #include <MEDMEM.hxx>
26
27 #include <string>
28 #include <vector>
29 #include "MEDMEM_define.hxx"
30 #include "MEDMEM_GenDriver.hxx"
31
32 #include "MEDMEM_STRING.hxx"
33 #include "MEDMEM_Exception.hxx"
34 #include "MEDMEM_Utilities.hxx"
35
36 /*!
37
38   Driver Med for MESH.
39
40   Generic part : implement open and close methods.
41
42 */
43
44 namespace MEDMEM {
45 class MESH;
46 class FAMILY;
47 class GROUP;
48 class CONNECTIVITY;
49 class MEDMEM_EXPORT MED_MESH_DRIVER : public GENDRIVER
50 {
51 protected:
52
53   MESH *         _ptrMesh;
54   mutable string _meshName;
55   int            _meshNum;     // INUTILE ?
56
57
58 public :
59
60   /*!
61     Constructor.
62   */
63   MED_MESH_DRIVER() ;
64   /*!
65     Constructor.
66   */
67   MED_MESH_DRIVER(const string & fileName,
68                   MESH * ptrMesh,
69                   MED_EN::med_mode_acces accessMode) ;
70   /*!
71     Copy constructor.
72   */
73   MED_MESH_DRIVER(const MED_MESH_DRIVER & driver) ;
74
75   /*!
76     Destructor.
77   */
78   virtual ~MED_MESH_DRIVER() ;
79
80   virtual void open() = 0;
81   virtual void close() = 0;
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   virtual void   setMeshName(const string & meshName) ;
92   /*!
93     Get the name of the MESH asked in file.
94   */
95   virtual string getMeshName() const ;
96
97 public:
98   virtual GENDRIVER * copy ( void ) const = 0 ;
99
100 };
101
102 /*!
103
104   Driver Med for MESH : Read only.
105
106   Implement read method.
107
108 */
109
110 class MEDMEM_EXPORT IMED_MESH_RDONLY_DRIVER : public virtual MED_MESH_DRIVER
111 {
112  
113 public :
114   
115   /*!
116     Constructor.
117   */
118   IMED_MESH_RDONLY_DRIVER() ;
119   /*!
120     Constructor.
121   */
122   IMED_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh) ;
123   /*!
124     Copy constructor.
125   */
126   IMED_MESH_RDONLY_DRIVER(const IMED_MESH_RDONLY_DRIVER & driver) ;
127   
128   // CREER UNE METHODE POUR LIRE LA LISTE DES MAILLAGES .....
129   /*!
130     Return a MEDEXCEPTION : it is the read-only driver.
131   */
132   void write( void ) const;
133   virtual void activateFacesComputation() = 0;
134   virtual void desactivateFacesComputation() = 0;
135
136 protected:
137 //   virtual int getCOORDINATE() = 0 ;
138 //   virtual int getCONNECTIVITY() = 0 ;
139 //   virtual int getFAMILY() = 0 ;
140 //   virtual int getNodalConnectivity(CONNECTIVITY * Connectivity) = 0 ;
141   int getDescendingConnectivity(CONNECTIVITY * Connectivity);
142 //   virtual int getNodesFamiliesNumber(int * MEDArrayNodeFamily) = 0 ;
143 //   virtual int getCellsFamiliesNumber(int** Arrays, CONNECTIVITY* Connectivity, MED_EN::medEntityMesh entity) = 0 ;
144   void updateFamily() ;
145   void buildAllGroups(vector<GROUP*> & Groups, vector<FAMILY*> & Families) ;
146 //   virtual void getGRID () = 0 ;
147
148   friend class MED_MESH_RDONLY_DRIVER;
149
150 };
151
152 /*!
153
154   Driver Med for MESH : Write only.
155
156   Implement write method.
157
158 */
159
160 class MEDMEM_EXPORT IMED_MESH_WRONLY_DRIVER : public virtual MED_MESH_DRIVER {
161   
162 public :
163   
164   /*!
165     Constructor.
166   */
167   IMED_MESH_WRONLY_DRIVER() ;
168   /*!
169     Constructor.
170   */
171   IMED_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh, MED_EN::med_mode_acces access=MED_EN::WRONLY) ;
172   /*!
173     Copy constructor.
174   */
175   IMED_MESH_WRONLY_DRIVER(const IMED_MESH_WRONLY_DRIVER & driver) ;
176
177   /*!
178     Destructor.
179   */
180   virtual ~IMED_MESH_WRONLY_DRIVER() ;
181
182   /*!
183     Return a MEDEXCEPTION : it is the write-only driver.
184   */
185   void read ( void );
186
187 // protected:
188 //   virtual int writeCoordinates    ()                           const = 0 ;
189 //   virtual int writeConnectivities (MED_EN::medEntityMesh entity)       const = 0 ;
190 //   virtual int writeFamilyNumbers  ()                           const = 0 ;
191 //   virtual int writeFamilies       (vector<FAMILY*> & families) const = 0 ;
192 //   virtual int writeGRID() const = 0 ;
193
194   friend class MED_MESH_WRONLY_DRIVER;
195 };
196
197
198 /*!
199
200   Driver Med for MESH : Read write.
201   - Use read method from MED_MESH_RDONLY_DRIVER
202   - Use write method from MED_MESH_WRONLY_DRIVER
203
204 */
205
206 class MEDMEM_EXPORT IMED_MESH_RDWR_DRIVER : public virtual IMED_MESH_RDONLY_DRIVER, public virtual IMED_MESH_WRONLY_DRIVER {
207
208 public :
209
210   /*!
211     Constructor.
212   */
213   IMED_MESH_RDWR_DRIVER() ;
214   /*!
215     Constructor.
216   */
217   IMED_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) ;
218   /*!
219     Copy constructor.
220   */
221   IMED_MESH_RDWR_DRIVER(const IMED_MESH_RDWR_DRIVER & driver) ;
222
223   /*!
224     Destructor.
225   */
226   ~IMED_MESH_RDWR_DRIVER() ;
227
228   friend class MED_MESH_RDWR_DRIVER;
229
230 };
231
232 class MEDMEM_EXPORT MED_MESH_RDONLY_DRIVER : public virtual IMED_MESH_RDONLY_DRIVER
233 {
234 public:
235   MED_MESH_RDONLY_DRIVER();
236   MED_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh);
237   MED_MESH_RDONLY_DRIVER(const MED_MESH_RDONLY_DRIVER & driver);
238   ~MED_MESH_RDONLY_DRIVER();
239   void   setMeshName(const string & meshName);
240   string getMeshName() const;
241   void write( void ) const;
242   void activateFacesComputation();
243   void desactivateFacesComputation();
244   void read ( void );
245   void open();
246   void close();
247   virtual void merge ( const GENDRIVER& driver );
248   virtual void setFileName ( const string & fileName) {_concreteMeshDrv->setFileName(fileName); }
249 protected:
250   GENDRIVER * _concreteMeshDrv;
251 //   int getCOORDINATE();
252 //   int getCONNECTIVITY();
253 //   int getFAMILY();
254 //   int getNodalConnectivity(CONNECTIVITY * Connectivity);
255 //   int getDescendingConnectivity(CONNECTIVITY * Connectivity);
256 //   int getNodesFamiliesNumber(int * MEDArrayNodeFamily);
257 //   int getCellsFamiliesNumber(int** Arrays, CONNECTIVITY* Connectivity, MED_EN::medEntityMesh entity);
258 //   void getGRID ();
259   GENDRIVER * copy ( void ) const;
260 };
261
262 class MEDMEM_EXPORT MED_MESH_WRONLY_DRIVER : public virtual IMED_MESH_WRONLY_DRIVER {
263 public :
264   MED_MESH_WRONLY_DRIVER();
265   MED_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh, MED_EN::med_mode_acces access=MED_EN::WRONLY);
266   MED_MESH_WRONLY_DRIVER(const MED_MESH_WRONLY_DRIVER & driver);
267   ~MED_MESH_WRONLY_DRIVER();
268   void   setMeshName(const string & meshName);
269   string getMeshName() const;
270   void read ( void );
271   void write( void ) const;
272   void open();
273   void close();
274   virtual void merge ( const GENDRIVER& driver );
275   virtual void setFileName ( const string & fileName) {_concreteMeshDrv->setFileName(fileName); }
276 protected:
277   GENDRIVER * _concreteMeshDrv;
278 //   int writeCoordinates    ()                           const;
279 //   int writeConnectivities (MED_EN::medEntityMesh entity)       const;
280 //   int writeFamilyNumbers  ()                           const;
281 //   int writeFamilies       (vector<FAMILY*> & families) const;
282 //   int writeGRID() const;
283   GENDRIVER * copy ( void ) const;
284 };
285
286 class MEDMEM_EXPORT MED_MESH_RDWR_DRIVER : public IMED_MESH_RDWR_DRIVER {
287 public :
288   MED_MESH_RDWR_DRIVER();
289   MED_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh);
290   MED_MESH_RDWR_DRIVER(const MED_MESH_RDWR_DRIVER & driver);
291   ~MED_MESH_RDWR_DRIVER();
292   void   setMeshName(const string & meshName);
293   string getMeshName() const;
294   void read ( void );
295   void write( void ) const;
296   void activateFacesComputation();
297   void desactivateFacesComputation();
298   void open();
299   void close();
300   virtual void merge ( const GENDRIVER& driver );
301   virtual void setFileName ( const string & fileName) {_concreteMeshDrv->setFileName(fileName); }
302 protected:
303   GENDRIVER * _concreteMeshDrv;
304 //   int getCOORDINATE();
305 //   int getCONNECTIVITY();
306 //   int getFAMILY();
307 //   int getNodalConnectivity(CONNECTIVITY * Connectivity);
308 //   int getDescendingConnectivity(CONNECTIVITY * Connectivity);
309 //   int getNodesFamiliesNumber(int * MEDArrayNodeFamily);
310 //   int getCellsFamiliesNumber(int** Arrays, CONNECTIVITY* Connectivity, MED_EN::medEntityMesh entity);
311 //   void getGRID ();
312 //   int writeCoordinates    ()                           const;
313 //   int writeConnectivities (MED_EN::medEntityMesh entity)       const;
314 //   int writeFamilyNumbers  ()                           const;
315 //   int writeFamilies       (vector<FAMILY*> & families) const;
316 //   int writeGRID() const;
317   GENDRIVER * copy ( void ) const;
318 };
319
320 }
321
322 #endif /* MED_MESH_DRIVER_HXX */