]> SALOME platform Git repositories - modules/med.git/blob - src/MEDMEM/MEDMEM_MedMeshDriver.hxx
Salome HOME
Fix problem of make distcheck
[modules/med.git] / src / MEDMEM / MEDMEM_MedMeshDriver.hxx
1 // Copyright (C) 2007-2012  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
23 #ifndef MED_MESH_DRIVER_HXX
24 #define MED_MESH_DRIVER_HXX
25
26 #include <MEDMEM.hxx>
27
28 #include <string>
29 #include <vector>
30 #include "MEDMEM_define.hxx"
31 #include "MEDMEM_GenDriver.hxx"
32
33 #include "MEDMEM_STRING.hxx"
34 #include "MEDMEM_Exception.hxx"
35 #include "MEDMEM_Utilities.hxx"
36
37 /*!
38
39   Driver Med for MESH.
40
41   Generic part : implement open and close methods.
42
43 */
44
45 namespace MEDMEM {
46 class GMESH;
47 class FAMILY;
48 class GROUP;
49 class CONNECTIVITY;
50 class MEDMEM_EXPORT MED_MESH_DRIVER : public GENDRIVER
51 {
52 protected:
53
54   GMESH *             _ptrMesh;
55   mutable std::string _meshName;
56   med_2_3::med_idt    _medIdt ;
57   
58
59
60 public :
61
62   // all MED cell type
63   static const med_2_3::med_geometry_type all_cell_type[MED_N_CELL_GEO_FIXED_CON];
64   
65   static const char * const all_cell_type_tab [MED_N_CELL_GEO_FIXED_CON];
66
67   /*!
68     Constructor.
69   */
70   MED_MESH_DRIVER() ;
71   /*!
72     Constructor.
73   */
74   MED_MESH_DRIVER(const std::string &    fileName,
75                   GMESH *                ptrMesh,
76                   MED_EN::med_mode_acces accessMode) ;
77   /*!
78     Copy constructor.
79   */
80   MED_MESH_DRIVER(const MED_MESH_DRIVER & driver) ;
81
82   /*!
83     Destructor.
84   */
85   virtual ~MED_MESH_DRIVER() ;
86
87   virtual void open();
88   virtual void close();
89
90   virtual void write( void ) const = 0 ;
91   virtual void read ( void ) = 0 ;
92
93   /*!
94     Set the name of the MESH asked in file.
95
96     It could be different than the name of the MESH object.
97   */
98   virtual void   setMeshName(const std::string & meshName) ;
99   /*!
100     Get the name of the MESH asked in file.
101   */
102   virtual std::string getMeshName() const ;
103
104 public:
105   virtual GENDRIVER * copy ( void ) const = 0 ;
106
107 };
108
109 /*!
110
111   Driver Med for MESH : Read only.
112
113   Implement read method.
114
115 */
116
117 class MEDMEM_EXPORT MED_MESH_RDONLY_DRIVER : public virtual MED_MESH_DRIVER
118 {
119  
120 public :
121   
122   /*!
123     Constructor.
124   */
125   MED_MESH_RDONLY_DRIVER() ;
126   /*!
127     Constructor.
128   */
129   MED_MESH_RDONLY_DRIVER(const std::string & fileName, GMESH * ptrMesh) ;
130   /*!
131     Copy constructor.
132   */
133   MED_MESH_RDONLY_DRIVER(const MED_MESH_RDONLY_DRIVER & driver) ;
134   /*!
135     Destructor.
136   */
137   virtual ~MED_MESH_RDONLY_DRIVER() ;
138
139    /*!
140      Return a MEDEXCEPTION : it is the read-only driver.
141    */
142   void write( void ) const;
143   /*!
144     Read MESH in the specified file.
145   */
146   void read ( void );
147   /*!
148    *  This method activate global faces computation from SCRATCH if a family on FACE exists in the MED file.
149    *  This implies a complete renumbering of FACES. This is the default behaviour of this driver.
150    */
151   void activateFacesComputation() { _computeFaces=true; }
152   /*!
153    *  This method desactivate global face computation.
154    *  That is to say that FACES described in file are supposed to
155    *  be correct and complete. The consequence is that reading is much faster. Use with care !
156    */
157   void desactivateFacesComputation() { _computeFaces=false; }
158
159 protected:
160   int getDescendingConnectivity(CONNECTIVITY * Connectivity);
161   void updateFamily() ;
162   void buildAllGroups(std::vector<GROUP*> & Groups, std::vector<FAMILY*> & Families) ;
163
164 private:
165   int getCOORDINATE();
166   int getCONNECTIVITY();
167   int getFAMILY();
168   int getNodalConnectivity(CONNECTIVITY * Connectivity) ;
169   int getNodesFamiliesNumber(int * MEDArrayNodeFamily) ;
170   int getCellsFamiliesNumber(int** Arrays, /*CONNECTIVITY* Connectivity, */MED_EN::medEntityMesh entity) ;
171   void getGRID ();
172
173   GENDRIVER * copy ( void ) const ;
174   virtual void merge ( const GENDRIVER& driver );
175
176 private:
177   bool _computeFaces;
178 };
179
180 /*!
181
182   Driver Med for MESH : Write only.
183
184   Implement write method.
185
186 */
187
188 class MEDMEM_EXPORT MED_MESH_WRONLY_DRIVER : public virtual MED_MESH_DRIVER
189 {
190 public :
191   
192   /*!
193     Constructor.
194   */
195   MED_MESH_WRONLY_DRIVER() ;
196   /*!
197     Constructor.
198   */
199   MED_MESH_WRONLY_DRIVER(const std::string &    fileName,
200                          GMESH *                ptrMesh,
201                          MED_EN::med_mode_acces access=MED_EN::WRONLY) ;
202   /*!
203     Copy constructor.
204   */
205   MED_MESH_WRONLY_DRIVER(const MED_MESH_WRONLY_DRIVER & driver) ;
206
207   /*!
208     Destructor.
209   */
210   virtual ~MED_MESH_WRONLY_DRIVER() ;
211
212   /*!
213     Return a MEDEXCEPTION : it is the write-only driver.
214   */
215   void read ( void );
216
217   /*!
218     Write MESH in the specified file.
219   */
220   void write( void ) const;
221
222 private:
223   int writeCoordinates    ()                           const;
224   int writeConnectivities (MED_EN::medEntityMesh entity)       const;
225   void groupFamilyConverter(const std::vector<GROUP*>& groups,
226                             std::vector<FAMILY*>&      families) const;
227   int writeFamilyNumbers  ()                           const;
228   int writeFamilies       (std::vector<FAMILY*> & families) const;
229   int writeGRID() const;
230
231   GENDRIVER * copy ( void ) const ;
232 };
233
234
235 /*!
236
237   Driver Med for MESH : Read write.
238   - Use read method from MED_MESH_RDONLY_DRIVER
239   - Use write method from MED_MESH_WRONLY_DRIVER
240
241 */
242
243 class MEDMEM_EXPORT MED_MESH_RDWR_DRIVER : public virtual MED_MESH_RDONLY_DRIVER, public virtual MED_MESH_WRONLY_DRIVER {
244
245 public :
246
247   /*!
248     Constructor.
249   */
250   MED_MESH_RDWR_DRIVER() ;
251   /*!
252     Constructor.
253   */
254   MED_MESH_RDWR_DRIVER(const std::string & fileName, GMESH * ptrMesh) ;
255   /*!
256     Copy constructor.
257   */
258   MED_MESH_RDWR_DRIVER(const MED_MESH_RDWR_DRIVER & driver) ;
259
260   /*!
261     Destructor.
262   */
263   ~MED_MESH_RDWR_DRIVER() ;
264
265   /*!
266     Write MESH in the specified file.
267   */
268   void write(void) const;
269   /*!
270     Read MESH in the specified file.
271   */
272   void read (void);
273
274 private:
275   GENDRIVER * copy(void) const ;
276
277 };
278
279 }
280
281 #endif /* MED_MESH_DRIVER_HXX */