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