Salome HOME
Merge from BR_V5_DEV 16Feb09
[modules/med.git] / src / MEDMEM / MEDMEM_MedMeshDriver21.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_DRIVER21_HXX
23 #define MED_MESH_DRIVER21_HXX
24
25 #include "MEDMEM.hxx"
26
27 #include "MEDMEM_MedMeshDriver.hxx"
28 #include "MEDMEM_define.hxx"
29 #include "MEDMEM_Compatibility21_22.hxx"
30
31 /*!
32
33   Driver Med for MESH.
34
35   Generic part : implement open and close methods.
36
37 */
38
39 namespace MEDMEM {
40 class MESH;
41 class FAMILY;
42 class GROUP;
43 class CONNECTIVITY;
44
45 class MEDMEM_EXPORT MED_MESH_DRIVER21 : public virtual MED_MESH_DRIVER
46 {
47 protected:
48
49   med_2_1::med_idt        _medIdt;
50
51 public :
52
53   // all MED cell type
54   static const med_2_1::med_geometrie_element all_cell_type[MED_NBR_GEOMETRIE_MAILLE];
55   
56   static const char * const all_cell_type_tab [MED_NBR_GEOMETRIE_MAILLE];
57
58   /*!
59     Constructor.
60   */
61   MED_MESH_DRIVER21() ;
62  /*!
63     Constructor.
64   */
65   MED_MESH_DRIVER21(const string & fileName,
66                     MESH * ptrMesh,
67                     MED_EN::med_mode_acces accessMode) ;
68   /*!
69     Copy constructor.
70   */
71   MED_MESH_DRIVER21(const MED_MESH_DRIVER21 & driver) ;
72
73   /*!
74     Destructor.
75   */
76   virtual ~MED_MESH_DRIVER21() ;
77
78   void open();
79   void close();
80 };
81
82 /*!
83
84   Driver Med for MESH : Read only.
85
86   Implement read method.
87
88 */
89
90 class MEDMEM_EXPORT MED_MESH_RDONLY_DRIVER21 : public virtual IMED_MESH_RDONLY_DRIVER,
91                                                public virtual MED_MESH_DRIVER21
92 {
93 public:
94
95   /*!
96     Constructor.
97   */
98   MED_MESH_RDONLY_DRIVER21() ;
99   /*!
100     Constructor.
101   */
102   MED_MESH_RDONLY_DRIVER21(const string & fileName, MESH * ptrMesh) ;
103   /*!
104     Copy constructor.
105   */
106   MED_MESH_RDONLY_DRIVER21(const MED_MESH_RDONLY_DRIVER21 & driver) ;
107
108   /*!
109     Destructor.
110   */
111   virtual ~MED_MESH_RDONLY_DRIVER21() ;
112   void read(void);
113   void activateFacesComputation() { _computeFaces=true; }
114   void desactivateFacesComputation() { _computeFaces=false; }
115
116 private:
117   int getCOORDINATE();
118   int getCONNECTIVITY();
119   int getFAMILY();
120   int getNodalConnectivity(CONNECTIVITY * Connectivity) ;
121   int getNodesFamiliesNumber(int * MEDArrayNodeFamily) ;
122   int getCellsFamiliesNumber(int** Arrays, CONNECTIVITY* Connectivity, MED_EN::medEntityMesh entity) ;
123   void getGRID ();
124
125   GENDRIVER * copy ( void ) const ;
126
127 private:
128   bool _computeFaces;
129 };
130
131 /*!
132
133   Driver Med for MESH : Write only.
134
135   Implement write method.
136
137 */
138
139 class MEDMEM_EXPORT MED_MESH_WRONLY_DRIVER21 : public virtual IMED_MESH_WRONLY_DRIVER, public virtual MED_MESH_DRIVER21 {
140   
141 public :
142   
143   /*!
144     Constructor.
145   */
146   MED_MESH_WRONLY_DRIVER21() ;
147   /*!
148     Constructor.
149   */
150   MED_MESH_WRONLY_DRIVER21(const string & fileName, MESH * ptrMesh) ;
151   /*!
152     Copy constructor.
153   */
154   MED_MESH_WRONLY_DRIVER21(const MED_MESH_WRONLY_DRIVER21 & driver) ;
155
156   /*!
157     Destructor.
158   */
159   virtual ~MED_MESH_WRONLY_DRIVER21() ;
160
161   /*!
162     Write MESH in the specified file.
163   */
164   void write( void ) const;
165
166 private:
167   int writeCoordinates    ()                           const;
168   int writeConnectivities (MED_EN::medEntityMesh entity)       const;
169   int writeFamilyNumbers  ()                           const;
170   int writeFamilies       (vector<FAMILY*> & families) const;
171   int writeGRID() const;
172
173   GENDRIVER * copy ( void ) const ;
174 };
175
176
177 /*!
178
179   Driver Med for MESH : Read write.
180   - Use read method from MED_MESH_RDONLY_DRIVER
181   - Use write method from MED_MESH_WRONLY_DRIVER
182
183 */
184
185 class MEDMEM_EXPORT MED_MESH_RDWR_DRIVER21 : public IMED_MESH_RDWR_DRIVER, public MED_MESH_RDONLY_DRIVER21, public MED_MESH_WRONLY_DRIVER21 {
186
187 public :
188
189   /*!
190     Constructor.
191   */
192   MED_MESH_RDWR_DRIVER21() ;
193   /*!
194     Constructor.
195   */
196   MED_MESH_RDWR_DRIVER21(const string & fileName, MESH * ptrMesh) ;
197   /*!
198     Copy constructor.
199   */
200   MED_MESH_RDWR_DRIVER21(const MED_MESH_RDWR_DRIVER21 & driver) ;
201
202   /*!
203     Destructor.
204   */
205   ~MED_MESH_RDWR_DRIVER21() ;
206
207   /*!
208     Write MESH in the specified file.
209   */
210   void write(void) const;
211   /*!
212     Read MESH in the specified file.
213   */
214   void read (void);
215
216 private:
217   GENDRIVER * copy(void) const ;
218
219 };
220 }
221
222 #endif /* MED_MESH_DRIVER21_HXX */