Salome HOME
Copyrights update
[modules/med.git] / src / MEDMEM / MEDMEM_MedMeshDriver22.cxx
1 // Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 // 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either 
7 // version 2.1 of the License.
8 // 
9 // This library is distributed in the hope that it will be useful 
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
12 // Lesser General Public License for more details.
13 //
14 // You should have received a copy of the GNU Lesser General Public  
15 // License along with this library; if not, write to the Free Software 
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 //
18 // See http://www.salome-platform.org/
19 //
20 #include "MEDMEM_MedMeshDriver22.hxx"
21
22 #include "MEDMEM_DriversDef.hxx"
23
24 #include "MEDMEM_Family.hxx"
25 #include "MEDMEM_Group.hxx"
26 #include "MEDMEM_Coordinate.hxx"
27 #include "MEDMEM_Connectivity.hxx"
28 #include "MEDMEM_Mesh.hxx"
29 #include "MEDMEM_CellModel.hxx"
30 #include "MEDMEM_Grid.hxx"
31
32 using namespace std;
33 using namespace MED_EN;
34 using namespace MEDMEM;
35
36 namespace med_2_2 {
37   extern "C" {
38     extern med_idt _MEDdatagroupOuvrir(med_idt pid, char *nom);
39     extern med_err _MEDdatagroupFermer(med_idt id);
40   }
41 }
42
43 // Every memory allocation made in the MedDriver members function are desallocated in the Mesh destructor 
44
45 MED_MESH_DRIVER22::MED_MESH_DRIVER22():  _medIdt(MED_INVALID)
46 {
47 }
48
49 MED_MESH_DRIVER22::MED_MESH_DRIVER22(const string & fileName,
50                                      MESH * ptrMesh,
51                                      MED_EN::med_mode_acces accessMode): 
52   _medIdt(MED_INVALID), MED_MESH_DRIVER(fileName,ptrMesh,accessMode)
53 {
54 }
55   
56 MED_MESH_DRIVER22::MED_MESH_DRIVER22(const MED_MESH_DRIVER22 & driver):
57   MED_MESH_DRIVER(driver),_medIdt(driver._medIdt)
58 {
59 }
60
61 MED_MESH_DRIVER22::~MED_MESH_DRIVER22()
62 {
63 }
64
65 void MED_MESH_DRIVER22::open()
66 {
67   const char * LOC = "MED_MESH_DRIVER22::open()" ;
68   BEGIN_OF(LOC);
69
70   MESSAGE(LOC<<" : _fileName.c_str : "<< _fileName.c_str()<<",mode : "<< _accessMode);
71   _medIdt = med_2_2::MEDouvrir( (const_cast <char *> (_fileName.c_str())),(med_2_2::med_mode_acces) _accessMode);
72   MESSAGE(LOC<<" _medIdt : "<< _medIdt );
73   if (_medIdt > 0) 
74     _status = MED_OPENED; 
75   else {
76     _medIdt = MED_INVALID;
77     _status = MED_CLOSED;
78     throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Could not open file "<<_fileName<<" in mode "<<_accessMode));
79   }
80   
81   END_OF(LOC);
82 }
83   
84 void MED_MESH_DRIVER22::close()
85 {
86   const char * LOC = "MED_MESH_DRIVER22::close() " ;
87   BEGIN_OF(LOC);
88   int err = 0;
89   if ( _status == MED_OPENED) {
90     err = med_2_2::MEDfermer(_medIdt);
91     // san -- MED5873 : Calling H5close() here leads to failure of SALOMEDS::StudyManager_i::_SaveAs()
92     // method during study saving process. MEDfermer() seems sufficient for closing a file.
93     //H5close(); // If we call H5close() all the files are closed.
94     if (err != 0)
95       throw MEDEXCEPTION( LOCALIZED(STRING(LOC)
96                                     <<" Error when closing file !"
97                                     )
98                           );
99     MESSAGE(LOC <<": _medIdt= " << _medIdt );
100     MESSAGE(LOC<<": MEDfermer : err    = " << err );
101     _status = MED_CLOSED;
102     _medIdt = MED_INVALID;
103   }
104   END_OF(LOC);
105 }
106
107 //A FAIRE UTILISER LES MAPS...
108 const med_2_2::med_geometrie_element  MED_MESH_DRIVER22::all_cell_type[MED_NBR_GEOMETRIE_MAILLE]=
109   { med_2_2::MED_POINT1,med_2_2::MED_SEG2,med_2_2::MED_SEG3,med_2_2::MED_TRIA3,med_2_2::MED_QUAD4,med_2_2::MED_TRIA6,med_2_2::MED_QUAD8,
110     med_2_2::MED_TETRA4,med_2_2::MED_PYRA5,med_2_2::MED_PENTA6,med_2_2::MED_HEXA8,med_2_2::MED_TETRA10,med_2_2::MED_PYRA13,
111     med_2_2::MED_PENTA15, med_2_2::MED_HEXA20};
112
113 const char * const MED_MESH_DRIVER22::all_cell_type_tab [MED_NBR_GEOMETRIE_MAILLE]=
114   { "MED_POINT1","MED_SEG2","MED_SEG3","MED_TRIA3","MED_QUAD4","MED_TRIA6","MED_QUAD8",
115     "MED_TETRA4","MED_PYRA5","MED_PENTA6","MED_HEXA8","MED_TETRA10","MED_PYRA13",
116     "MED_PENTA15","MED_HEXA20"};
117
118
119 //---------------------------------- RDONLY PART -------------------------------------------------------------
120
121 MED_MESH_RDONLY_DRIVER22::MED_MESH_RDONLY_DRIVER22()
122 {
123 }
124   
125 MED_MESH_RDONLY_DRIVER22::MED_MESH_RDONLY_DRIVER22(const string & fileName,
126                                                    MESH * ptrMesh):
127   IMED_MESH_RDONLY_DRIVER(fileName,ptrMesh),MED_MESH_DRIVER22(fileName,ptrMesh,MED_RDONLY),MED_MESH_DRIVER(fileName,ptrMesh,MED_RDONLY)
128
129   MESSAGE("MED_MESH_RDONLY_DRIVER22::MED_MESH_RDONLY_DRIVER22(const string & fileName, MESH * ptrMesh) has been created");
130 }
131   
132 MED_MESH_RDONLY_DRIVER22::MED_MESH_RDONLY_DRIVER22(const MED_MESH_RDONLY_DRIVER22 & driver): 
133    IMED_MESH_RDONLY_DRIVER(driver),MED_MESH_DRIVER22(driver),MED_MESH_DRIVER(driver)
134 {
135 }
136
137 MED_MESH_RDONLY_DRIVER22::~MED_MESH_RDONLY_DRIVER22()
138 {
139   //MESSAGE("MED_MESH_RDONLY_DRIVER22::~MED_MESH_RDONLY_DRIVER() has been destroyed");
140 }
141   
142 GENDRIVER * MED_MESH_RDONLY_DRIVER22::copy(void) const
143 {
144   return new MED_MESH_RDONLY_DRIVER22(*this);
145 }
146
147 void MED_MESH_RDONLY_DRIVER22::read(void)
148 {
149   const char * LOC = "MED_MESH_RDONLY_DRIVER22::read() : " ;
150   BEGIN_OF(LOC);
151   if (_status!=MED_OPENED)
152     throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The _idt of file " << _fileName << " is : " << _medIdt <<  " (the file is not opened)." )) ;
153
154   _ptrMesh->_name =  _meshName;
155
156   SCRUTE(_ptrMesh->getIsAGrid());
157
158   if (_ptrMesh->getIsAGrid())
159     {
160       getGRID( );
161
162       // always call getFAMILY : families are requiered !!!!
163
164 //        int nbFam = MEDnFam(_medIdt,
165 //                        const_cast <char *> (_meshName.c_str()),
166 //                        0,
167 //                        MED_FR::MED_FAMILLE);
168 //        if (nbFam > 0)
169         {
170 //        getFAMILY();
171     
172           if (getFAMILY()!=MED_VALID)
173             throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERREUR in getFAMILY when the mesh is a grid")) ;
174
175           buildAllGroups(_ptrMesh->_groupNode,_ptrMesh->_familyNode) ;
176         }
177
178       END_OF(LOC);
179       return;
180     }
181
182   if (getCOORDINATE()!=MED_VALID)
183     throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERREUR in getCOORDINATE"  )) ;
184  
185   if (getCONNECTIVITY()!=MED_VALID)
186     throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERREUR in getCOONECTIVITY")) ;
187   
188   if (getFAMILY()!=MED_VALID)
189     throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERREUR in getFAMILY"      )) ;
190
191   updateFamily();
192
193   // we build all groups
194   // on node
195   buildAllGroups(_ptrMesh->_groupNode,_ptrMesh->_familyNode) ;
196   // on cell
197   buildAllGroups(_ptrMesh->_groupCell,_ptrMesh->_familyCell) ;
198
199   if (_ptrMesh->_meshDimension == 3)
200     // on face
201     buildAllGroups(_ptrMesh->_groupFace,_ptrMesh->_familyFace) ;
202   else if (_ptrMesh->_meshDimension == 2)
203     // on edge
204     buildAllGroups(_ptrMesh->_groupEdge,_ptrMesh->_familyEdge) ;
205
206 //   MESSAGE(LOC<<"Checking of CellModel !!!!!!!");
207
208 //   int nbOfTypes =  _ptrMesh->_connectivity->_numberOfTypes;
209 //    for(int i=0;i<nbOfTypes;i++)
210 //      {
211 //        MESSAGE(LOC << _ptrMesh->_connectivity->_type[i]) ;
212 //      }
213
214   END_OF(LOC);
215 }
216
217 //=======================================================================
218 //function : getGRID
219 //purpose  : 
220 //=======================================================================
221
222 void MED_MESH_RDONLY_DRIVER22::getGRID()
223 {
224   const char * LOC = "MED_MESH_RDONLY_DRIVER22::getGRID() : " ;
225   BEGIN_OF(LOC);
226   
227   if (_status!=MED_OPENED)
228     throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "med file is not opened"));
229   
230   GRID * ptrGrid = (GRID *) _ptrMesh;
231     
232   SCRUTE(ptrGrid);
233
234   int err, i;
235
236   int numberOfMeshesInFile = med_2_2::MEDnMaa(_medIdt);
237
238   if (numberOfMeshesInFile == MED_INVALID)
239     throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Problem in File where the mesh " << _meshName << " is supposed to be stored"));
240
241   for (int index = 0; index < numberOfMeshesInFile; index++)
242     {
243       char meshName[MED_TAILLE_NOM+1]="";
244       char meshDescription[MED_TAILLE_DESC+1]="";
245       int meshDim;
246       med_2_2::med_maillage meshType;
247
248       err = med_2_2::MEDmaaInfo(_medIdt, (index+1),meshName, &meshDim,
249                                &meshType, meshDescription) ;
250
251       MESSAGE(LOC<<": Mesh n°"<< (index+1) <<" nammed "<< meshName << " with the description " << meshDescription << " is structured");
252
253       if (_meshName == string(meshName))
254         {
255           _ptrMesh->_description = meshDescription;
256           _ptrMesh->_name = meshName;
257         }
258     }
259
260   MED_EN::med_grid_type gridType = ptrGrid->getGridType();
261
262   MESSAGE(LOC<<": Mesh processed is nammed "<< _ptrMesh->_name << " with the description " << _ptrMesh->_description << " is structured with the type " << gridType);
263
264   // Read the dimension of the mesh <_meshName>
265   int MeshDimension = med_2_2::MEDdimLire(_medIdt, const_cast <char *>
266                                          (_meshName.c_str())) ;
267
268   if (MeshDimension == MED_INVALID)
269     throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The mesh dimension |" <<
270                                  MeshDimension << "| seems to be incorrect " <<
271                                  "for the mesh : |" << _meshName << "|")) ;
272
273   _ptrMesh->_meshDimension = MeshDimension;
274
275   // Read or get the dimension of the space for the mesh <_meshName>
276   int SpaceDimension = MeshDimension;
277
278   int SpaceDimensionRead = med_2_2::MEDdimEspaceLire(_medIdt,
279                                                     const_cast <char *>
280                                                     (_meshName.c_str())) ;
281
282   if (SpaceDimensionRead != MED_INVALID) SpaceDimension = SpaceDimensionRead;
283
284   _ptrMesh->_spaceDimension = SpaceDimension;
285
286   med_2_2::med_repere rep ;
287   string tmp_nom_coord (MED_TAILLE_PNOM22*(_ptrMesh->_spaceDimension)+1,' ');
288   string tmp_unit_coord(MED_TAILLE_PNOM22*(_ptrMesh->_spaceDimension)+1,' ');
289   char * tmp_nom = (const_cast <char *> ( tmp_nom_coord.c_str())  ) ;
290   char * tmp_unit= (const_cast <char *> ( tmp_unit_coord.c_str()) ) ;
291
292   // Read Array length
293   int * ArrayLen[] = { & ptrGrid->_iArrayLength,
294                        & ptrGrid->_jArrayLength,
295                        & ptrGrid->_kArrayLength  };
296
297   MESSAGE(LOC << "The mesh is a " << _ptrMesh->_meshDimension << "D mesh on a " << _ptrMesh->_spaceDimension << "D space");
298
299   int NumberOfNodes;
300
301   //  if (gridType == MED_EN::MED_GRILLE_STANDARD)
302   if (gridType == MED_EN::MED_BODY_FITTED)
303     {
304       int * structure = new int[MeshDimension];
305
306       err = med_2_2::MEDstructureCoordLire(_medIdt,
307                                           const_cast <char *>
308                                           (_ptrMesh->_name.c_str()),
309                                           MeshDimension,structure);
310
311       if (err != MED_VALID)
312         throw MEDEXCEPTION(STRING(LOC) <<"Error in reading the structure of grid : |" << _meshName << "|" ) ;
313       
314       NumberOfNodes = 1;
315
316       for (int idim = 0; idim < MeshDimension; idim++)
317         {
318           MESSAGE(LOC<<"structure dim " << idim << " " << structure[idim]);
319
320           ArrayLen [idim][0] = structure[idim];
321           NumberOfNodes = NumberOfNodes*structure[idim];
322         }
323       
324       delete [] structure;
325
326 //       NumberOfNodes = MED_FR::MEDnEntMaa(_medIdt,
327 //                                       const_cast <char *>
328 //                                       (_ptrMesh->_name.c_str()),
329 //                                       MED_FR::MED_COOR,MED_FR::MED_NOEUD,
330 //                                       (MED_FR::med_geometrie_element) 0,
331 //                                       (MED_FR::med_connectivite) 0);
332
333       if ( NumberOfNodes == MED_INVALID )
334         throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"The number of nodes |" <<
335                                      NumberOfNodes <<
336                                      "| seems to be incorrect "
337                                      << "for the mesh : |" <<
338                                      _meshName << "|" )) ;
339
340       _ptrMesh->_numberOfNodes = NumberOfNodes ;
341
342       // create coordinates and its structure
343       _ptrMesh->_coordinate = new COORDINATE(SpaceDimension,NumberOfNodes,
344                                              MED_EN::MED_FULL_INTERLACE);
345
346       err = MEDcoordLire(_medIdt,
347                          const_cast <char *> (_ptrMesh->_name.c_str()),
348                          _ptrMesh->_spaceDimension,
349                          //const_cast <double *> ( _ptrMesh->_coordinate->_coordinate->get(MED_EN::MED_FULL_INTERLACE) ),
350                          const_cast <double *> ( _ptrMesh->_coordinate->_coordinate.get(MED_EN::MED_FULL_INTERLACE) ),
351                          med_2_2::MED_FULL_INTERLACE,
352                          MED_ALL, // we read all the coordinates
353                          NULL,    // we don't use a profile
354                          0,       // so the profile's size is 0
355                          &rep,tmp_nom,tmp_unit);
356
357       if (err != MED_VALID)
358         throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't read coordinates of the |" <<
359                                      NumberOfNodes << "| nodes for the mesh : |" <<
360                                      _meshName << "| of space dimension |" <<
361                                      SpaceDimension << "| with units names |" <<
362                                      tmp_nom << "| and units |" <<
363                                      tmp_unit << " |")) ;
364
365       ptrGrid->_is_coordinates_filled = true;
366     }
367   else if ((gridType == MED_EN::MED_CARTESIAN) ||
368            (gridType == MED_EN::MED_POLAR))
369     {
370       NumberOfNodes = 1;
371
372       double * Array[] = { (double*) 0, (double*) 0, (double*) 0 };
373
374       for (int idim = 0; idim < _ptrMesh->_meshDimension; ++idim)
375         {
376           med_2_2::med_table table;
377           if (idim == 0) table = med_2_2::MED_COOR_IND1;
378           else if (idim == 1) table = med_2_2::MED_COOR_IND2;
379           else if (idim == 2) table = med_2_2::MED_COOR_IND3;
380
381           int length = med_2_2::MEDnEntMaa(_medIdt,
382                                           const_cast <char *> (_ptrMesh->_name.c_str()),
383                                           table,med_2_2::MED_NOEUD,
384                                           med_2_2::MED_NONE,
385                                           med_2_2::MED_NOD);
386           if ( length <= MED_VALID )
387             throw MEDEXCEPTION(STRING(LOC) <<"The number of nodes |" << length <<
388                                "| seems to be incorrect "
389                                << "for the mesh : |" << _meshName << "|" ) ;
390           
391           ArrayLen [idim][0] = length;
392           NumberOfNodes *= length;
393
394           Array [idim] = new double [ length ];
395
396           err = med_2_2::MEDindicesCoordLire(_medIdt, const_cast <char *>
397                                             (_ptrMesh->_name.c_str()),
398                                             _ptrMesh->_meshDimension,
399                                             Array [idim], length, (idim+1),
400                                             tmp_nom+(idim*MED_TAILLE_PNOM22),
401                                             tmp_unit+(idim*MED_TAILLE_PNOM22));
402
403           if (err != MED_VALID)
404             throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Error in reading coordinates indices " <<
405                                          idim << "of the grid : |" <<
406                                          _meshName << "|" )) ;
407         }
408
409       ptrGrid->_iArray = Array[0];
410       ptrGrid->_jArray = Array[1];
411       ptrGrid->_kArray = Array[2];
412
413       _ptrMesh->_numberOfNodes = NumberOfNodes ;
414     
415       // create coordinates
416       _ptrMesh->_coordinate = new COORDINATE(SpaceDimension,NumberOfNodes,
417                                              MED_EN::MED_FULL_INTERLACE);
418
419       if (gridType == MED_EN::MED_CARTESIAN)
420         rep = med_2_2::MED_CART;
421       else if (gridType == MED_EN::MED_POLAR)
422         {
423           if (SpaceDimension == 2) rep = med_2_2::MED_CYL;
424           else if (SpaceDimension == 3) rep = med_2_2::MED_SPHER;
425         }
426     }
427   else
428     throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<" bad grid type : " << gridType));
429
430   // set coordinate names
431
432   for (i=0; i<_ptrMesh->_spaceDimension; ++i ) {
433     string myStringName(tmp_nom_coord,i*MED_TAILLE_PNOM22,MED_TAILLE_PNOM22) ;
434     string myStringUnit(tmp_unit_coord,i*MED_TAILLE_PNOM22,MED_TAILLE_PNOM22) ;
435     // suppress space at the end
436     int j ;
437     for(j=MED_TAILLE_PNOM22-1;j>=0;j--)
438       if (myStringName[j] != ' ') break ;
439     _ptrMesh->_coordinate->_coordinateName[i]=string(myStringName,0,j+1);
440     for(j=MED_TAILLE_PNOM22-1;j>=0;j--)
441       if (myStringUnit[j] != ' ') break ;
442     _ptrMesh->_coordinate->_coordinateUnit[i]=string(myStringUnit,0,j+1);
443   }
444
445   string coordinateSystem = "UNDEFINED";
446
447   if( rep == med_2_2::MED_CART) coordinateSystem = "CARTESIAN";
448   else if ( rep == med_2_2::MED_CYL) coordinateSystem = "CYLINDRICAL";
449   else if ( rep == med_2_2::MED_SPHER) coordinateSystem = "SPHERICAL";
450
451   _ptrMesh->_coordinate->setCoordinatesSystem(coordinateSystem);
452
453   END_OF(LOC);
454 }
455
456 //=======================================================================
457 //function : getCOORDINATE
458 // A FAIRE : RENVOYER DU VOID
459 //=======================================================================
460 int  MED_MESH_RDONLY_DRIVER22::getCOORDINATE()
461 {
462   const char * LOC = "MED_MESH_RDONLY_DRIVER22::getCOORDINATE() : " ;
463
464   BEGIN_OF(LOC);
465
466   if (_status==MED_OPENED)
467     {
468       int err ;
469       
470   int numberOfMeshesInFile = med_2_2::MEDnMaa(_medIdt);
471
472   if (numberOfMeshesInFile == MED_INVALID)
473     throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Problem in File where the mesh " << _meshName << " is supposed to be stored"));
474
475   for (int index = 0; index < numberOfMeshesInFile; index++)
476     {
477       char meshName[MED_TAILLE_NOM+1]="";
478       char meshDescription[MED_TAILLE_DESC+1]="";
479       int meshDim;
480       med_2_2::med_maillage meshType;
481
482       err = med_2_2::MEDmaaInfo(_medIdt, (index+1), meshName, &meshDim,
483                                &meshType, meshDescription) ;
484
485       MESSAGE(LOC<<": Mesh n°"<< (index+1) <<" nammed "<< meshName << " with the description " << meshDescription << " is structured");
486
487       if (_meshName == string(meshName))
488         {
489           _ptrMesh->_description = meshDescription;
490         }
491     }
492
493
494       // Read the dimension of the mesh <_meshName>
495       int MeshDimension = med_2_2::MEDdimLire(_medIdt, const_cast <char *>
496                                              (_meshName.c_str())) ;
497
498       if ( MeshDimension == MED_INVALID ) 
499         throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The mesh dimension |" <<
500                                      MeshDimension <<
501                                      "| seems to be incorrect " <<
502                                      "for the mesh : |" << _meshName << "|")) ;
503
504       _ptrMesh->_meshDimension = MeshDimension;
505
506       // Read or get the dimension of the space for the mesh <_meshName>
507       int SpaceDimension = MeshDimension;
508
509       int SpaceDimensionRead = med_2_2::MEDdimEspaceLire(_medIdt,
510                                                         const_cast <char *>
511                                                         (_meshName.c_str())) ;
512
513       if (SpaceDimensionRead  != MED_INVALID)
514         SpaceDimension = SpaceDimensionRead;
515
516       _ptrMesh->_spaceDimension = SpaceDimension;
517
518       // Read the number of nodes used in the mesh <_meshName>
519       // to be able to create a COORDINATE object
520       int NumberOfNodes=MEDnEntMaa(_medIdt,
521                                    const_cast <char *> (_meshName.c_str()),
522                                    med_2_2::MED_COOR,
523                                    med_2_2::MED_NOEUD,
524                                    (med_2_2::med_geometrie_element) MED_NONE,
525                                    (med_2_2::med_connectivite)      MED_NONE);
526       if ( NumberOfNodes <= MED_VALID )
527         throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"The number of nodes |" << NumberOfNodes << "| seems to be incorrect "
528                                      << "for the mesh : |" << _meshName << "|" )) ;
529       _ptrMesh->_numberOfNodes = NumberOfNodes ;
530
531       // create a COORDINATE object
532       _ptrMesh->_coordinate = new COORDINATE(SpaceDimension, NumberOfNodes, MED_EN::MED_FULL_INTERLACE);
533       
534       med_2_2::med_repere rep ; // ATTENTION ---> DOIT ETRE INTEGRE DS MESH EF: FAIT NON?
535       string tmp_nom_coord (MED_TAILLE_PNOM22*(_ptrMesh->_spaceDimension)+1,'\0');
536       string tmp_unit_coord(MED_TAILLE_PNOM22*(_ptrMesh->_spaceDimension)+1,'\0');
537       char * tmp_nom = (const_cast <char *> ( tmp_nom_coord.c_str())  ) ;
538       char * tmp_unit= (const_cast <char *> ( tmp_unit_coord.c_str()) ) ;
539
540       err=MEDcoordLire(_medIdt,
541                        const_cast <char *> (_ptrMesh->_name.c_str()),
542                        _ptrMesh->_spaceDimension,
543                        //const_cast <double *> ( _ptrMesh->_coordinate->_coordinate->get(MED_EN::MED_FULL_INTERLACE) ),
544                        const_cast <double *> ( _ptrMesh->_coordinate->_coordinate.get(MED_EN::MED_FULL_INTERLACE) ),
545                        med_2_2::MED_FULL_INTERLACE,
546                        MED_ALL,                      // we read all the coordinates
547                        NULL,                         // we don't use a profile
548                        0,                            // so the profile's size is 0
549                        &rep,tmp_nom,tmp_unit);
550       if (err != MED_VALID)
551         throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't read coordinates of the |" << NumberOfNodes << "| nodes "
552                                      << "for the mesh : |" << _meshName 
553                                      << "| of space dimension |" << SpaceDimension 
554                                      << "| with units names |"   << tmp_nom
555                                      << "| and units |"          << tmp_unit
556                                      << " |")) ;
557       
558
559       for (int i=0;i<_ptrMesh->_spaceDimension;i++) {
560         string myStringName(tmp_nom_coord,i*MED_TAILLE_PNOM22,MED_TAILLE_PNOM22) ;
561         string myStringUnit(tmp_unit_coord,i*MED_TAILLE_PNOM22,MED_TAILLE_PNOM22) ;
562         // suppress space at the end
563         int j ;
564         for(j=MED_TAILLE_PNOM22-1;j>=0;j--)
565           if (myStringName[j] != ' ') break ;
566         _ptrMesh->_coordinate->_coordinateName[i]=string(myStringName,0,j+1);
567         for(j=MED_TAILLE_PNOM22-1;j>=0;j--)
568           if (myStringUnit[j] != ' ') break ;
569         _ptrMesh->_coordinate->_coordinateUnit[i]=string(myStringUnit,0,j+1);
570       }
571
572       // Pourquoi le stocker sous forme de chaîne ?
573       switch (rep)
574         {
575         case med_2_2::MED_CART : 
576           {
577             _ptrMesh->_coordinate->_coordinateSystem = "CARTESIAN";
578             break ;
579           }
580         case med_2_2::MED_CYL :
581           {
582             _ptrMesh->_coordinate->_coordinateSystem = "CYLINDRICAL";
583             break ;
584           }
585         case med_2_2::MED_SPHER :
586           {
587             _ptrMesh->_coordinate->_coordinateSystem = "SPHERICAL";
588             break ;
589           }
590         default :
591           {
592             _ptrMesh->_coordinate->_coordinateSystem = "UNDEFINED"; // ?Erreur ?
593             break ;
594           }
595         }
596
597       // Read the unused optional node Names
598       char * tmp_node_name = new char[NumberOfNodes*MED_TAILLE_PNOM22+1];
599       tmp_node_name[NumberOfNodes]='\0' ;
600       err=MEDnomLire(_medIdt,const_cast <char*> (_ptrMesh->_name.c_str()),
601                      tmp_node_name,NumberOfNodes*MED_TAILLE_PNOM22,med_2_2::MED_NOEUD,
602                      (med_2_2::med_geometrie_element) MED_NONE);
603       if (err == MED_VALID) 
604         MESSAGE(LOC<<"MED_MESH_RDONLY_DRIVER::getNoeuds() : WARNING : Nodes have names but we do not read them !");
605       delete[] tmp_node_name ;
606
607
608       // ??? Read the unused optional node Numbers ???
609       med_2_2::med_int * tmp_node_number = new med_2_2::med_int[NumberOfNodes] ;
610       err=MEDnumLire(_medIdt,const_cast <char*> (_ptrMesh->_name.c_str()),
611                      tmp_node_number,NumberOfNodes,med_2_2::MED_NOEUD,(med_2_2::med_geometrie_element)0);
612       if (err == MED_VALID) {
613         // INFOS(LOC<<"WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING");
614         // INFOS(LOC<<"MED_MESH_RDONLY_DRIVER::getNoeuds() : WARNING : Nodes have numbers but we do not take care of them !");
615         // INFOS(LOC<<"WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING");
616         MESSAGE(LOC<<"MED_MESH_RDONLY_DRIVER::getNoeuds() : Nodes have numbers, we DO TAKE care of them !");
617         _ptrMesh->_coordinate->_nodeNumber.set(NumberOfNodes) ; 
618 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
619         for(med_2_2::med_int i2=0;i2<NumberOfNodes;i2++)
620           _ptrMesh->_coordinate->_nodeNumber[i2]=(int)(tmp_node_number[i2]);
621 #else
622         memcpy((int*)_ptrMesh->_coordinate->_nodeNumber,tmp_node_number,sizeof(int)*NumberOfNodes) ;
623 #endif
624         
625         //////////////////////////////////////////////////////////////////////////////////////
626         ///  Modification pour prise en compte de la numérotation optionnelle des noeuds   ///
627         //////////////////////////////////////////////////////////////////////////////////////
628         ///
629         /// Calcule _optionnalToCanonicNodesNumbers de telle sorte que _optionnalToCanonicNodesNumbers[OptionnalNumber]==CanonicNumber
630         
631 //      _ptrMesh->_arePresentOptionnalNodesNumbers=1;
632 //      for (int canonicNumber=1;canonicNumber<=NumberOfNodes;canonicNumber++) _ptrMesh->_optionnalToCanonicNodesNumbers[tmp_node_number[canonicNumber-1]]=canonicNumber;
633 // ICI RETOUR A LA NORMALE::: AUCUNE PRISE EN COMPTE D'UN NUMEROTATION OPTIONNEL
634         _ptrMesh->_arePresentOptionnalNodesNumbers=0;
635       } 
636       else _ptrMesh->_arePresentOptionnalNodesNumbers=0;
637
638         //////////////////////////////////////////////////////////////////////////////////////
639
640       delete[] tmp_node_number ;
641       
642       END_OF(LOC);
643       return MED_VALID;
644     }
645   return MED_ERROR;
646 }
647
648
649 int MED_MESH_RDONLY_DRIVER22::getCONNECTIVITY() 
650 {
651   const char * LOC = "MED_MESH_RDONLY_DRIVER22::getCONNECTIVITY : " ;
652   BEGIN_OF(LOC);
653
654   if (_status==MED_OPENED)
655     {
656
657       int err = 0 ;
658       // read MED_CELL connectivity
659       CONNECTIVITY * Connectivity     = new CONNECTIVITY(MED_CELL) ;
660       Connectivity->_numberOfNodes    = _ptrMesh->_numberOfNodes ;   // EF : Pourquoi cet attribut est-il dans MESH et non dans COORDINATE ?
661
662       // Try to read nodal connectivity of the cells <Connectivity->_nodal>
663       // then try to read descending connectivity    <Connectivity->_descending>
664       // if neither nodal nor descending connectivity exists
665       // throw an exception.
666       err = getNodalConnectivity(Connectivity) ;
667       if (err!=MED_VALID)
668         {
669           Connectivity->_typeConnectivity = MED_DESCENDING ;
670           err = getDescendingConnectivity(Connectivity) ;
671         }
672       else 
673         getDescendingConnectivity(Connectivity) ; // we read it if there is one
674       
675       if (err!=MED_VALID)
676         {
677           delete Connectivity ;
678           throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "We could not read " <<
679                                        "any Connectivity")) ;
680         }
681
682       if (Connectivity->_entityDimension != _ptrMesh->_meshDimension)
683         MESSAGE(LOC << "Small mesh dimension problem on the med file mounted in memory : diim stored " << _ptrMesh->_meshDimension << " dim computed using the connectivity " << Connectivity->_entityDimension);
684
685       _ptrMesh->_meshDimension = Connectivity->_entityDimension ; 
686
687       // At this point Connectivity->_typeConnectivity is either NODAL or DESCENDING
688       // If both connectivities are found Connectivity->_typeConnectivity is NODAL
689       // If space dimension is 3 
690       // try to read the nodal connectivity of the faces <ConnectivityFace->_nodal> then
691       // try to read the descending connectivity <ConnectivityFace->_descending>
692       // if there is no descending connectivity and the CELLS are
693       // defined in descending mode then throw an exception
694
695       // PROVISOIRE : if we have some face or edge in MED_MAILLE, we don't read more. There could not be have face or edge !!!!
696
697       if(Connectivity->_constituent==NULL) {
698
699       SCRUTE(_ptrMesh->_meshDimension);
700       SCRUTE(Connectivity->_entityDimension);
701       if (_ptrMesh->_meshDimension == 3) {
702         MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DES FACES..." );
703         CONNECTIVITY * ConnectivityFace = new CONNECTIVITY(MED_EN::MED_FACE) ;
704         ConnectivityFace->_typeConnectivity = Connectivity->_typeConnectivity ; // NODAL or DESCENDING
705         SCRUTE(ConnectivityFace->_typeConnectivity);
706         if (Connectivity->_typeConnectivity == MED_DESCENDING) {
707           MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DESCENDANTE DES FACES" );
708           err = getDescendingConnectivity(ConnectivityFace) ;
709           if (err!=MED_VALID)
710             throw MEDEXCEPTION ( LOCALIZED(STRING(LOC) << "No FACE in descending connectivity")) ;
711           getNodalConnectivity(ConnectivityFace) ; // if any !
712         } else {
713           MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE NODALE DES FACES" );
714           err = getNodalConnectivity(ConnectivityFace) ;
715           if (err!=MED_VALID) { // or error ????? we are in NODAL mode.
716             err = getDescendingConnectivity(ConnectivityFace) ;
717           } else
718             getDescendingConnectivity(ConnectivityFace); // if any !
719         }
720         if (err!=MED_VALID) {
721           delete ConnectivityFace ;
722           MESSAGE(LOC<<"No FACE defined.") ;
723         } else {
724           MESSAGE(LOC<<" SAUVEGARDE DE LA CONNECTIVITE DES FACES DANS L'OBJET CONNECTIVITY" );
725           Connectivity->_constituent=ConnectivityFace ; 
726         }
727       }
728
729       // read MED_EDGE connectivity
730       if (_ptrMesh->_meshDimension > 1) { // we are in 3 or 2D 
731         MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DES ARRETES...." );
732         CONNECTIVITY * ConnectivityEdge = new CONNECTIVITY(MED_EDGE) ;
733         ConnectivityEdge->_typeConnectivity = Connectivity->_typeConnectivity ;
734         if (Connectivity->_typeConnectivity == MED_DESCENDING) {
735           MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DESCENDANTE DES ARRETES" );
736           err = getDescendingConnectivity(ConnectivityEdge) ;
737           if (err!=MED_VALID)
738             throw MEDEXCEPTION ( LOCALIZED(STRING(LOC) << "No EDGE in descending connectivity")) ;
739           getNodalConnectivity(ConnectivityEdge) ; // if any !
740         } else {
741           MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE NODALE DES ARRETES" );
742           err = getNodalConnectivity(ConnectivityEdge) ;
743           if (err!=MED_VALID) { // or error ????? we are in NODAL mode.
744             err = getDescendingConnectivity(ConnectivityEdge) ;
745           } else
746             getDescendingConnectivity(ConnectivityEdge) ; // if any !
747         }
748         if (err!=MED_VALID) {
749           delete ConnectivityEdge ;
750           MESSAGE(LOC<<"No EDGE defined.") ;
751         } else {
752           if (_ptrMesh->_meshDimension == 3)
753             if (Connectivity->_constituent != NULL)
754               Connectivity->_constituent->_constituent=ConnectivityEdge ;
755             else
756               throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<< "EDGE defined but there are no FACE !")) ;
757           else { // IN 2D
758             MESSAGE(LOC<<" SAUVEGARDE DE LA CONNECTIVITE DES ARETES DANS L'OBJET CONNECTIVITY" );
759             Connectivity->_constituent=ConnectivityEdge ;
760           }
761         }
762       }
763       }
764       _ptrMesh->_connectivity  = Connectivity ;                                      
765
766       // all right !
767
768       // we have read all connectivity in file, now we must build descending connectivity if necessary !
769
770       // If connectivity descending is defined, we have nothing to do, all constituent are defined !
771       // If connectivity is only nodal, we must rebuild descending if we have some contituent !
772
773       //A FAIRE !!!!
774 //        if (Connectivity->_descending == NULL)
775 //      if (Connectivity->_constituent != NULL){
776 //        // update Connectivity->_constituent
777 //        CONNECTIVITY * myConstituentOld = Connectivity->_constituent ;
778 //        Connectivity->_constituent = (CONNECTIVITY *)NULL ;
779 //        Connectivity->calculateDescendingConnectivity() ;
780           
781 //      }
782       
783       END_OF(LOC);
784       return MED_VALID;
785     }
786   return MED_ERROR;
787 }
788
789 int MED_MESH_RDONLY_DRIVER22::getNodalConnectivity(CONNECTIVITY * Connectivity)
790 {
791   const char * LOC = "MED_MESH_RDONLY_DRIVER22::getNodalConnectivity : " ;
792   BEGIN_OF(LOC);
793
794   int spaceDimension = _ptrMesh->_spaceDimension;
795
796   if (_status==MED_OPENED)
797     {
798       // Get the type of entity to work on (previously set in the Connectivity Object)
799       med_2_2::med_entite_maillage Entity = (med_2_2::med_entite_maillage) Connectivity->getEntity();
800       
801       // Get the number of cells of each type & store it in <tmp_cells_count>.
802       int * tmp_cells_count = new int[MED_NBR_GEOMETRIE_MAILLE] ;
803       int i;
804       for (i=1;i<MED_NBR_GEOMETRIE_MAILLE;i++) 
805         {                       // EF :ON SCANNE DES GEOMETRIES INUTILES, UTILISER LES MAPS
806           tmp_cells_count[i]=MEDnEntMaa(_medIdt,(const_cast <char *> (_ptrMesh->_name.c_str())),
807                                         med_2_2::MED_CONN,(med_2_2::med_entite_maillage) Entity,
808                                         all_cell_type[i],med_2_2::MED_NOD); 
809
810
811           // Get the greatest dimension of the cells : Connectivity->_entityDimension
812           // We suppose there is no cells used as faces in MED 2.2.x , this is forbidden !!!
813           // In version prior to 2.2.x, it is possible
814           if (tmp_cells_count[i]>0) 
815             { 
816               Connectivity->_entityDimension=all_cell_type[i]/100;  
817               Connectivity->_numberOfTypes++;
818             }
819         }
820
821       
822
823       // begin classic geometric types
824       if (Connectivity->_numberOfTypes > 0)
825         {
826           // if MED version < 2.2.x, we read only entity with dimention = Connectivity->_entityDimension. Lesser dimension are face or edge !
827
828       med_int major, minor, release;
829
830       if ( med_2_2::MEDversionLire(_medIdt, &major, &minor, &release) != 0 )
831             {
832               // error : we suppose we have not a good med file !
833               delete[] tmp_cells_count ;
834               return MED_ERROR ;
835             }
836
837           // we get MED version number
838           // If MED version is < 2.2 then the cells which dimension
839           // is lesser than the main dimension ( Connectivity->_entityDimension )
840           // are either faces or edges
841
842           //        string medVersion(version_med);
843           //        int firstNumber = 
844           int * tmpEdgeCount = new int[MED_NBR_GEOMETRIE_MAILLE] ;
845           tmpEdgeCount[0]     = 0 ;
846           int numberOfEdgesTypes = 0;
847           int * tmpFaceCount = new int[MED_NBR_GEOMETRIE_MAILLE] ;
848           tmpFaceCount[0]     = 0 ;
849           int numberOfFacesTypes = 0;
850   
851 //       if ((version_med != "2.2")&(Entity==MED_FR::MED_MAILLE))
852 //      {
853 //        Connectivity->_numberOfTypes=0;
854         
855 //        for ( i=1;i<MED_NBR_GEOMETRIE_MAILLE;i++)
856 //          {
857 //            tmpFaceCount[i]=0;
858 //            tmpEdgeCount[i]=0;
859 //            if (tmp_cells_count[i]!=0)
860 //              {
861 //                int dimension = all_cell_type[i]/100 ;
862 //                if (Connectivity->_entityDimension==dimension) 
863 //                  Connectivity->_numberOfTypes++ ;
864             
865 //                if (dimension == 2)
866 //                  if (Connectivity->_entityDimension==3)
867 //                    {
868 //                      tmpFaceCount[i]=tmp_cells_count[i] ;
869 //                      tmp_cells_count[i]=0 ;
870 //                      numberOfFacesTypes++;
871 //                    }
872 //                if (dimension == 1)
873 //                  if (Connectivity->_entityDimension>dimension)
874 //                    {
875 //                      tmpEdgeCount[i]=tmp_cells_count[i] ;
876 //                      tmp_cells_count[i]=0;
877 //                      numberOfEdgesTypes++ ;
878 //                    }
879 //              }
880 //          }
881 //      }
882         
883       if (Entity==med_2_2::MED_MAILLE)
884         {
885               Connectivity->_numberOfTypes=0;
886         
887               for ( i=1;i<MED_NBR_GEOMETRIE_MAILLE;i++) 
888                 {
889                   tmpFaceCount[i]=0;
890                   tmpEdgeCount[i]=0;
891                   if (tmp_cells_count[i]!=0) 
892                     {
893                       int dimension = all_cell_type[i]/100 ;
894                       if (Connectivity->_entityDimension==dimension) 
895                         Connectivity->_numberOfTypes++ ;
896                 
897                       if (dimension == 2)
898                         if (Connectivity->_entityDimension==3) 
899                           {
900                             tmpFaceCount[i]=tmp_cells_count[i] ;
901                         //tmp_cells_count[i]=0 ;
902                         //Connectivity->_numberOfTypes++ ;
903                             numberOfFacesTypes++;
904                           }
905                       if (dimension == 1)
906                         if (Connectivity->_entityDimension>dimension) 
907                           {
908                             tmpEdgeCount[i]=tmp_cells_count[i] ;
909                         //tmp_cells_count[i]=0;
910                         //Connectivity->_numberOfTypes++ ;
911                             numberOfEdgesTypes++ ;
912                           }
913                     }
914                 }
915             }
916
917           // bloc to read CELL :
918           {
919             // Prepare an array of indexes on the different cell types to create a MEDSKYLINEARRAY
920             // We use <tmp_cells_count> to calculate <Connectivity->_count> then we release it
921             Connectivity->_geometricTypes = new MED_EN::medGeometryElement [Connectivity->_numberOfTypes]   ;  // Double emploi pour des raisons pratiques 
922             Connectivity->_type           = new CELLMODEL                  [Connectivity->_numberOfTypes]   ;  //
923             Connectivity->_count          = new int                        [Connectivity->_numberOfTypes+1] ;
924             Connectivity->_count[0]       = 1;
925             
926             int size = 0 ; 
927             int typeNumber=1 ;
928             int i;
929             for ( i=1;i<MED_NBR_GEOMETRIE_MAILLE;i++)  
930               { // no point1 cell type (?)
931             int dimension = all_cell_type[i]/100 ;
932             if ((tmp_cells_count[i]>0) && (Connectivity->_entityDimension == dimension))
933                   {
934                     Connectivity->_count[typeNumber]=Connectivity->_count[typeNumber-1]+tmp_cells_count[i];
935
936                     CELLMODEL t( (MED_EN::medGeometryElement) MED_MESH_DRIVER22::all_cell_type[i]) ;
937
938                 Connectivity->_type[typeNumber-1] = t ;
939             
940                     Connectivity->_geometricTypes[typeNumber-1]=( MED_EN::medGeometryElement) MED_MESH_DRIVER22::all_cell_type[i] ;
941             
942                     // probleme avec les mailles de dimension < a dimension du maillage :
943                     // Il faut oter le zero a la lecture est le remettre a l'ecriture : ce n'est pas fait !!!!! On interdit ce cas pour l'instant !!!
944
945               
946                     size+=tmp_cells_count[i]*((MED_MESH_DRIVER22::all_cell_type[i])%100) ;
947             
948                     MESSAGE(LOC
949                             << Connectivity->_count[typeNumber]-1 << " cells of type " 
950                             << all_cell_type_tab[i] ); 
951                     typeNumber++;
952                   }
953               }
954         
955             // Creation of the MEDSKYLINEARRAY
956             //Connectivity->_nodal = new MEDSKYLINEARRAY(Connectivity->_count[Connectivity->_numberOfTypes]-1,size) ; 
957             //int * NodalIndex = Connectivity->_nodal->getIndex() ;
958             int * NodalValue = new int[size] ;
959             int * NodalIndex = new int[Connectivity->_count[Connectivity->_numberOfTypes]] ;
960             NodalIndex[0]=1 ;
961         
962             // Fill the MEDSKYLINEARRAY by reading the MED file.
963             int j=0;
964             for ( i=0;i<Connectivity->_numberOfTypes;i++) 
965               {
966                 int multi = 0 ;
967                 med_2_2::med_geometrie_element med_type = (med_2_2::med_geometrie_element) Connectivity->_type[i].getType() ;
968                 //        if ( Connectivity->_type[i].getDimension() < Connectivity->_entityDimension) 
969                 //        if (Connectivity->_entity == MED_CELL)
970                 //          if ( Connectivity->_type[i].getDimension() < _ptrMesh->_spaceDimension) 
971                 //            multi=1;
972           
973                 //        int NumberOfCell = Connectivity->_count[i+1]-Connectivity->_count[i] ;
974                 int NumberOfNodeByCell = Connectivity->_type[i].getNumberOfNodes() ;
975           
976                 // initialise index
977                 for ( j=Connectivity->_count[i]; j<Connectivity->_count[i+1];j++)
978                   NodalIndex[j]=NodalIndex[j-1]+NumberOfNodeByCell ; 
979
980             int tmp_numberOfCells = Connectivity->_count[i+1]-Connectivity->_count[i] ;
981                 int * tmp_ConnectivityArray = new int[(NumberOfNodeByCell+multi)*tmp_numberOfCells];
982           
983                 //        int err=MEDconnLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
984             //                    Connectivity->_entityDimension,tmp_ConnectivityArray,
985                 //                            MED_FR::MED_FULL_INTERLACE,NULL,0,Entity,med_type,MED_FR::MED_NOD);
986             int err=MEDconnLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
987                                 spaceDimension,tmp_ConnectivityArray,
988                                     med_2_2::MED_FULL_INTERLACE,NULL,0,Entity,med_type,med_2_2::MED_NOD);
989
990             if ( err != MED_VALID)
991               {
992                 delete[] tmp_ConnectivityArray;
993                 delete[] tmp_cells_count;
994                 delete[] tmpFaceCount;
995                 delete[] tmpEdgeCount;
996                 MESSAGE(LOC<<": MEDconnLire returns "<<err) ;
997                 return MED_ERROR ;
998               }
999
1000             int * ConnectivityArray = NodalValue + NodalIndex[Connectivity->_count[i]-1]-1 ;
1001
1002             // version originale sans prise en compte des numéros optionnels
1003             //
1004             for ( j=0; j<tmp_numberOfCells; j++) for (int k=0; k<NumberOfNodeByCell; k++) 
1005                   ConnectivityArray[j*NumberOfNodeByCell+k]=tmp_ConnectivityArray[j*(NumberOfNodeByCell+multi)+k] ;
1006
1007             //////////////////////////////////////////////////////////////////////////////
1008             // Modification pour prise en compte de la numérotation optionnelle des noeuds ///
1009             //////////////////////////////////////////////////////////////////////////////
1010             //
1011             // Rénumérote le tableau temporaire tmp_ConnectivityArray en utilisant _optionnalToCanonicNodesNumbers
1012             // Le traitement est identique à la version originelle s'il n'y a pas de numérotation optionnelle
1013                                                      
1014                                                        //       if (_ptrMesh->_arePresentOptionnalNodesNumbers==1) 
1015                                                        //               {
1016                                                        //               for ( j=0; j<tmp_numberOfCells; j++) for (int k=0; k<NumberOfNodeByCell; k++) 
1017                                                        //                       ConnectivityArray[j*NumberOfNodeByCell+k]=_ptrMesh->_optionnalToCanonicNodesNumbers[tmp_ConnectivityArray[j*(NumberOfNodeByCell+multi)+k]] ;
1018                                                        //               }
1019                                                        //       else
1020                                                        //               {
1021                                                        //               for ( j=0; j<tmp_numberOfCells; j++) for (int k=0; k<NumberOfNodeByCell; k++) 
1022                                                        //                       ConnectivityArray[j*NumberOfNodeByCell+k]=tmp_ConnectivityArray[j*(NumberOfNodeByCell+multi)+k] ;
1023                                                        //               }
1024             ////////////////////////////////////////////////////////////////////////////
1025         
1026                                                        delete[] tmp_ConnectivityArray;
1027   
1028               }
1029
1030             Connectivity->_nodal = new MEDSKYLINEARRAY(Connectivity->_count[Connectivity->_numberOfTypes]-1,
1031                                                        size,
1032                                                        NodalIndex,
1033                                                        NodalValue) ; 
1034
1035             delete[] NodalIndex;
1036             delete[] NodalValue;
1037
1038           } // end of bloc to read CELL
1039
1040
1041           // Get Face if any
1042           // ===============
1043      
1044           if (numberOfFacesTypes!=0) 
1045             {
1046
1047               // Create a CONNECTIVITY constituent to put in the top level CONNECTIVITY recursive class
1048               CONNECTIVITY * constituent = new CONNECTIVITY(numberOfFacesTypes,MED_EN::MED_FACE) ;
1049               constituent->_entityDimension = 2 ;
1050               constituent->_count[0]=1 ;
1051
1052               // In order to create the MEDSKYLINEARRAY of the constituent object we need :
1053               // 1:
1054               // To initialize the _count array of the constituent object (containning cumulated face count by geometric type)
1055               // _count[0]=1 and _count[_numberOfTypes] give the size of NodalIndex
1056               // 2:
1057               // To calculate the total number of face nodes whatever the geometric type is.
1058               // The result is the size of the array containning all the nodes : NodalValue
1059               // 3 :
1060               // To calculate the starting indexes of the different face types in NodalValue, 
1061               // this is the NodalIndex array.
1062         
1063               int size       = 0 ; 
1064               int typeNumber = 1 ;
1065               int i;
1066               for ( i=1; i < MED_NBR_GEOMETRIE_MAILLE; i++)
1067                 { // no point1 cell type (?)
1068                   if (tmpFaceCount[i]>0)
1069                     {
1070                       constituent->_count[typeNumber] = constituent->_count[typeNumber-1] + tmpFaceCount[i];
1071                       CELLMODEL t( (MED_EN::medGeometryElement) MED_MESH_DRIVER22::all_cell_type[i]) ;
1072                       constituent->_type[typeNumber-1]=t ;
1073             
1074                       constituent->_geometricTypes[typeNumber-1]=( MED_EN::medGeometryElement) MED_MESH_DRIVER22::all_cell_type[i] ;
1075             
1076                       size+=tmpFaceCount[i]*((MED_MESH_DRIVER22::all_cell_type[i])%100) ;
1077                       typeNumber++;
1078                     }
1079                 }
1080         
1081               // Creation of the MEDSKYLINEARRAY
1082               //constituent->_nodal = new MEDSKYLINEARRAY(constituent->_count[constituent->_numberOfTypes]-1,size) ; 
1083               //int * NodalIndex = constituent->_nodal->getIndex() ;
1084               int * NodalValue = new int[size] ;
1085               int * NodalIndex = new int[constituent->_count[constituent->_numberOfTypes]] ;
1086               NodalIndex[0]=1 ;
1087         
1088               // Fill the MEDSKYLINEARRAY by reading the MED file.
1089               for ( i=0; i<constituent->_numberOfTypes; i++) 
1090                 {
1091                   med_2_2::med_geometrie_element med_type = (med_2_2::med_geometrie_element) constituent->_type[i].getType() ;
1092
1093                   int NumberOfNodeByFace = constituent->_type[i].getNumberOfNodes() ;
1094           
1095                   // initialise NodalIndex
1096                   for (int j=constituent->_count[i]; j<constituent->_count[i+1];j++)
1097                     NodalIndex[j]=NodalIndex[j-1]+NumberOfNodeByFace ; 
1098           
1099           int tmp_numberOfFaces = constituent->_count[i+1]-constituent->_count[i] ;
1100           // Il faut ajouter 1 pour le zero a la lecture !!!
1101           // ATTENTION UNIQUEMENT POUR MED < 2.2.x
1102                   int * tmp_constituentArray = NULL;
1103
1104             MESSAGE(LOC << "Med file version used here " << major << " " << minor << " " << release);
1105
1106             if ((major == 2) && (minor <= 1))
1107                     tmp_constituentArray = new int[(NumberOfNodeByFace+1)*tmp_numberOfFaces] ;
1108             else if ((major == 2) && (minor >= 2))
1109                     {
1110                       tmp_constituentArray = new int[NumberOfNodeByFace*tmp_numberOfFaces] ;
1111             MESSAGE(LOC<<": WE ARE USING MED2.2 so there is no +1 for calculating the size of  tmp_constituentArray !") ;
1112           }
1113
1114                   int err=MEDconnLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
1115                                       Connectivity->_entityDimension,tmp_constituentArray,
1116                                       med_2_2::MED_FULL_INTERLACE,NULL,0,med_2_2::MED_MAILLE,med_type,med_2_2::MED_NOD);
1117
1118                   if ( err != MED_VALID) 
1119                     {
1120                       MESSAGE(LOC<<": MEDconnLire returns "<<err) ;
1121                       delete constituent ;
1122                       delete[] tmp_constituentArray;
1123                       delete[] tmpFaceCount;
1124                       delete[] tmpEdgeCount;
1125                       return MED_ERROR ;
1126                     }
1127
1128                   int * constituentArray = NodalValue + NodalIndex[constituent->_count[i]-1]-1 ;
1129           
1130           // version originale sans prise en compte des numéros optionnels
1131           //    
1132                   int multi = 0; // quand est-ce que multi vaut 1 ?? en MED-fichier < 2.2 ??
1133             MESSAGE(LOC << "Med file version used here " << major << " " << minor << " " << release);
1134
1135             if ((major == 2) && (minor <= 1))
1136               for (int j=0; j<tmp_numberOfFaces; j++)
1137                 for (int k=0; k<NumberOfNodeByFace; k++)
1138                   constituentArray[j*NumberOfNodeByFace+k]=tmp_constituentArray[j*(NumberOfNodeByFace+1)+k] ;
1139             else if ((major == 2) && (minor >= 2))
1140                   for (int j=0; j<tmp_numberOfFaces; j++)
1141                     for (int k=0; k<NumberOfNodeByFace; k++)
1142                   constituentArray[j*NumberOfNodeByFace+k]=tmp_constituentArray[j*(NumberOfNodeByFace+multi)+k] ;
1143
1144                   //////////////////////////////////////////////////////////////////////////////////////
1145                   ///  Modification pour prise en compte de la numérotation optionnelle des noeuds   ///
1146                       //////////////////////////////////////////////////////////////////////////////////////
1147                       ///
1148                       /// Rénumérote le tableau temporaire tmp_constituentArray en utilisant _optionnalToCanonicNodesNumbers
1149                       /// Le traitement est identique à la version originelle s'il n'y a pas de numérotation optionnelle
1150         
1151                       //        if (_ptrMesh->_arePresentOptionnalNodesNumbers) 
1152                       //                {
1153                       //                for (int j=0; j<tmp_numberOfFaces; j++) for (int k=0; k<NumberOfNodeByFace; k++)
1154                       //                        constituentArray[j*NumberOfNodeByFace+k]=_ptrMesh->_optionnalToCanonicNodesNumbers[tmp_constituentArray[j*(NumberOfNodeByFace+1)+k]] ;
1155                       //                }
1156                       //        else
1157                       //                {
1158                       //                for (int j=0; j<tmp_numberOfFaces; j++) for (int k=0; k<NumberOfNodeByFace; k++)
1159                       //                        constituentArray[j*NumberOfNodeByFace+k]=tmp_constituentArray[j*(NumberOfNodeByFace+1)+k] ;
1160                       //                }
1161         
1162                       //////////////////////////////////////////////////////////////////////////////////////
1163           
1164                       delete[] tmp_constituentArray;
1165                 }
1166         
1167               constituent->_nodal = new MEDSKYLINEARRAY(constituent->_count[constituent->_numberOfTypes]-1,
1168                                                         size,
1169                                                         NodalIndex,
1170                                                         NodalValue) ;
1171               delete[] NodalIndex ;
1172               delete[] NodalValue ;
1173
1174
1175               Connectivity->_constituent = constituent ;
1176             }
1177
1178           delete[] tmpFaceCount;
1179
1180
1181           // get Edge if any
1182           // ===============
1183           if (numberOfEdgesTypes!=0) 
1184             {
1185               CONNECTIVITY * constituent = new CONNECTIVITY(numberOfEdgesTypes,MED_EDGE) ;
1186               constituent->_entityDimension = 1 ;
1187               constituent->_count[0]=1 ;
1188
1189               int size = 0 ; 
1190               int typeNumber=1 ;
1191               // if you declare a variable <i> in two <for> initialization statement, 
1192               // compiler gcc2.95.3 says nothing but there are two <i> variables in the same block 
1193               //and the value you get in the common block seems to be the value of the first variable !
1194               int i; 
1195
1196               for ( i=1; i<MED_NBR_GEOMETRIE_MAILLE; i++)  
1197                 { // no point1 cell type (?)
1198                   if (tmpEdgeCount[i]>0) 
1199                     {
1200             
1201                       constituent->_count[typeNumber]=constituent->_count[typeNumber-1]+tmpEdgeCount[i];
1202                       CELLMODEL t( (MED_EN::medGeometryElement) MED_MESH_DRIVER22::all_cell_type[i]) ;
1203                       constituent->_type[typeNumber-1]=t ;
1204             
1205                       constituent->_geometricTypes[typeNumber-1]=( MED_EN::medGeometryElement) MED_MESH_DRIVER22::all_cell_type[i] ;
1206             
1207                       size+=tmpEdgeCount[i]*((MED_MESH_DRIVER22::all_cell_type[i])%100) ;
1208                       typeNumber++;
1209                     }
1210                 }
1211         
1212               // Creation of the MEDSKYLINEARRAY
1213               //constituent->_nodal = new MEDSKYLINEARRAY(constituent->_count[constituent->_numberOfTypes]-1,size) ; 
1214               //int * NodalIndex = constituent->_nodal->getIndex() ;
1215               int * NodalValue = new int[size] ;
1216               int * NodalIndex = new int[constituent->_count[constituent->_numberOfTypes]] ;
1217               NodalIndex[0]=1 ;
1218         
1219               // Fill the MEDSKYLINEARRAY by reading the MED file.
1220               for ( i=0; i<constituent->_numberOfTypes; i++) 
1221                 {
1222                   med_2_2::med_geometrie_element med_type = (med_2_2::med_geometrie_element) constituent->_type[i].getType() ;
1223
1224                   int NumberOfNodeByEdge = constituent->_type[i].getNumberOfNodes() ;
1225           
1226                   // initialise index
1227                   for (int j=constituent->_count[i]; j<constituent->_count[i+1];j++)
1228                     NodalIndex[j]=NodalIndex[j-1]+NumberOfNodeByEdge ; 
1229           
1230                   int tmp_numberOfEdges = constituent->_count[i+1]-constituent->_count[i] ;
1231                   // Il faut ajouter 1 pour le zero a la lecture !!!
1232
1233                   // ATTENTION UNIQUEMENT POUR MED < 2.2.x
1234                   int * tmp_constituentArray = NULL;
1235
1236               MESSAGE(LOC << "Med file version used here " << major << " " << minor << " " << release);
1237
1238               if ((major == 2) && (minor <= 1))
1239                     tmp_constituentArray = new int[(NumberOfNodeByEdge+1)*tmp_numberOfEdges] ;
1240               else if ((major == 2) && (minor >= 2))
1241                     {
1242                       tmp_constituentArray = new int[NumberOfNodeByEdge*tmp_numberOfEdges] ;
1243             MESSAGE(LOC<<": WE ARE USING MED2.2 so there is no +1 for calculating the size of  tmp_constituentArray !") ;
1244           }
1245           
1246                   int err=MEDconnLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
1247                                       spaceDimension,tmp_constituentArray,
1248                                       med_2_2::MED_FULL_INTERLACE,NULL,0,med_2_2::MED_MAILLE,med_type,med_2_2::MED_NOD);
1249                   if ( err != MED_VALID) 
1250                     {
1251                       MESSAGE(LOC<<": MEDconnLire returns "<<err) ;
1252                       delete constituent ;
1253                       delete[] tmp_constituentArray;
1254                       delete[] tmpEdgeCount;
1255                       return MED_ERROR ;
1256                     }
1257
1258                   int * constituentArray = NodalValue + NodalIndex[constituent->_count[i]-1]-1 ;
1259           
1260           // version originale sans prise en compte des numéros optionnels     
1261           //
1262                   int multi = 0; // quand est-ce que multi vaut 1 ?? en MED-fichier < 2.2 ??
1263               MESSAGE(LOC << "Med file version used here " << major << " " << minor << " " << release);
1264
1265               if ((major == 2) && (minor <= 1))
1266                   for (int j=0; j<tmp_numberOfEdges; j++)
1267                     for (int k=0; k<NumberOfNodeByEdge; k++)
1268                     constituentArray[j*NumberOfNodeByEdge+k]=tmp_constituentArray[j*(NumberOfNodeByEdge+multi)+k] ;
1269               else if ((major == 2) && (minor >= 2))
1270                 for (int j=0; j<tmp_numberOfEdges; j++)
1271                   for (int k=0; k<NumberOfNodeByEdge; k++)
1272                     constituentArray[j*NumberOfNodeByEdge+k]=tmp_constituentArray[j*(NumberOfNodeByEdge)+k] ;
1273
1274                   //////////////////////////////////////////////////////////////////////////////////////
1275                   ///  Modification pour prise en compte de la numérotation optionnelle des noeuds   ///
1276                       //////////////////////////////////////////////////////////////////////////////////////
1277                       ///
1278                       /// Rénumérote le tableau temporaire tmp_constituentArray en utilisant _optionnalToCanonicNodesNumbers
1279                       /// Le traitement est identique à la version originelle s'il n'y a pas de numérotation optionnelle
1280         
1281                       //        if (_ptrMesh->_arePresentOptionnalNodesNumbers) 
1282                       //                {
1283                       //                for (int j=0; j<tmp_numberOfEdges; j++) for (int k=0; k<NumberOfNodeByEdge; k++)
1284                       //                        constituentArray[j*NumberOfNodeByEdge+k]=_ptrMesh->_optionnalToCanonicNodesNumbers[tmp_constituentArray[j*(NumberOfNodeByEdge+1)+k]] ;
1285                       //                }
1286                       //        else
1287                       //                {
1288                       //                for (int j=0; j<tmp_numberOfEdges; j++) for (int k=0; k<NumberOfNodeByEdge; k++)
1289                       //                        constituentArray[j*NumberOfNodeByEdge+k]=tmp_constituentArray[j*(NumberOfNodeByEdge+1)+k] ;
1290                       //                }
1291         
1292                       //////////////////////////////////////////////////////////////////////////////////////
1293
1294                       delete[] tmp_constituentArray;
1295                 }
1296
1297               constituent->_nodal = new MEDSKYLINEARRAY(constituent->_count[constituent->_numberOfTypes]-1,
1298                                                         size,
1299                                                         NodalIndex,
1300                                                         NodalValue) ;
1301
1302               delete[] NodalIndex ;
1303               delete[] NodalValue ;
1304
1305               if (Connectivity->_entityDimension == 3) 
1306                 {
1307                   if (Connectivity->_constituent==NULL)
1308                     throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Edges are defined but there are no Faces !"));
1309                   Connectivity->_constituent->_constituent = constituent ;
1310                 } else 
1311                   Connectivity->_constituent = constituent ;
1312             }
1313
1314           delete[] tmpEdgeCount; 
1315
1316       
1317         } // end classic geometric types
1318       delete[] tmp_cells_count;
1319
1320
1321
1322       // Lecture des polygones MED_CELL
1323       int NumberOfPolygons = MEDnEntMaa(_medIdt,
1324                                         const_cast <char *> (_ptrMesh->_name.c_str()),
1325                                         med_2_2::MED_CONN,
1326                                         Entity,
1327                                         med_2_2::MED_POLYGONE,
1328                                         med_2_2::MED_NOD);
1329
1330       // Correction to permit the loading of mesh dimensionned at 2 even
1331       // if it has only MED_POLYGON elements
1332
1333       if (NumberOfPolygons > 0)
1334         {
1335           if (Connectivity->_entityDimension < 2) Connectivity->_entityDimension = 2;
1336         }
1337
1338       if (NumberOfPolygons > 0)
1339         {
1340           // By consequence this exception will never occur
1341           if (Connectivity->_entityDimension == 1)
1342             throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"In a 2D mesh, polygons need at least one 2D cell of a classic geometric type !"));
1343           med_int ConnectivitySize;
1344           med_err err1 = MEDpolygoneInfo(_medIdt,
1345                                          const_cast <char *> (_ptrMesh->_name.c_str()),
1346                                          Entity,
1347                                          med_2_2::MED_NOD,
1348                                          &ConnectivitySize);
1349           if (err1 != MED_VALID)
1350             {
1351               MESSAGE(LOC<<": MEDpolygoneInfo returns "<<err1);
1352               return MED_ERROR;
1353             }
1354       
1355           med_int* PolygonsConnectivity = new med_int[ConnectivitySize];
1356           med_int* PolygonsConnectivityIndex = new med_int[NumberOfPolygons+1];
1357       
1358           med_err err2 = MEDpolygoneConnLire(_medIdt,
1359                                              const_cast <char *> (_ptrMesh->_name.c_str()),
1360                                              PolygonsConnectivityIndex,
1361                                              NumberOfPolygons+1,
1362                                              PolygonsConnectivity,
1363                                              Entity,
1364                                              med_2_2::MED_NOD);
1365           if (err2 != MED_VALID)
1366             {
1367               MESSAGE(LOC<<": MEDpolygoneConnLire returns "<<err2);
1368               return MED_ERROR;
1369             }
1370       
1371           if (Connectivity->_entityDimension == 2) // 2D mesh : polygons in Connectivity
1372             Connectivity->setPolygonsConnectivity(MED_NODAL,(medEntityMesh) Entity,PolygonsConnectivity,PolygonsConnectivityIndex,ConnectivitySize,NumberOfPolygons);
1373           else if (Connectivity->_entityDimension == 3)
1374             {
1375               if (Connectivity->_constituent == NULL) // 3D mesh : polygons in Connectivity->_constituent
1376                 Connectivity->_constituent = new CONNECTIVITY(MED_FACE);
1377               Connectivity->_constituent->setPolygonsConnectivity(MED_NODAL,MED_FACE,PolygonsConnectivity,PolygonsConnectivityIndex,ConnectivitySize,NumberOfPolygons);
1378             }
1379       
1380           delete[] PolygonsConnectivity;
1381           delete[] PolygonsConnectivityIndex;
1382         } // end polygons
1383   
1384
1385
1386       // Lecture des polyedres MED_CELL
1387       med_int NumberOfPolyhedron = MEDnEntMaa(_medIdt,
1388                                               const_cast <char *> (_ptrMesh->_name.c_str()),
1389                                               med_2_2::MED_CONN,
1390                                               Entity,
1391                                               med_2_2::MED_POLYEDRE,
1392                                               med_2_2::MED_NOD);
1393
1394       // Correction to permit the loading of mesh dimensionned at 3 even
1395       // if it has only MED_POLYEDRE elements
1396
1397       if (NumberOfPolyhedron > 0)
1398         {
1399           Connectivity->_entityDimension = 3;
1400         }
1401
1402       if (NumberOfPolyhedron > 0)
1403         {
1404           // By consequence this exception will never occur
1405           if (Connectivity->_entityDimension == 2 || Connectivity->_entityDimension == 1)
1406             throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"In a 3D mesh, polyhedron need at least one 3D cell of a classic geometric type !"));
1407           med_int FacesIndexSize, NumberOfNodes, NumberOfFaces;
1408           med_err err3 = MEDpolyedreInfo(_medIdt,
1409                                          const_cast <char *> (_ptrMesh->_name.c_str()),
1410                                          med_2_2::MED_NOD,
1411                                          &FacesIndexSize,
1412                                          &NumberOfNodes);
1413           NumberOfFaces = FacesIndexSize-1;
1414           if (err3 != MED_VALID)
1415             {
1416               MESSAGE(LOC<<": MEDpolyhedreInfo returns "<<err3);
1417               return MED_ERROR;
1418             }
1419       
1420           med_int* Nodes = new med_int[NumberOfNodes];
1421           med_int* FacesIndex = new med_int[NumberOfFaces+1];
1422           med_int* PolyhedronIndex = new med_int[NumberOfPolyhedron+1];
1423           
1424           med_err err4 = MEDpolyedreConnLire(_medIdt,
1425                                              const_cast <char *> (_ptrMesh->_name.c_str()),
1426                                              PolyhedronIndex,
1427                                              NumberOfPolyhedron+1,
1428                                              FacesIndex,
1429                                              NumberOfFaces+1,
1430                                              Nodes,
1431                                              med_2_2::MED_NOD);
1432           if (err4 != MED_VALID)
1433             {
1434               MESSAGE(LOC<<": MEDpolyedreConnLire returns "<<err4);
1435               return MED_ERROR;
1436             }
1437       
1438           Connectivity->setPolyhedronConnectivity(MED_NODAL,Nodes,PolyhedronIndex,NumberOfNodes,NumberOfPolyhedron,FacesIndex,NumberOfFaces);
1439           
1440           delete[] Nodes;
1441           delete[] FacesIndex;
1442           delete[] PolyhedronIndex;
1443         } // end polyhedron
1444
1445
1446
1447       // If there is no nodal connectivity, we return MED_ERROR !
1448       if (Connectivity->_numberOfTypes == 0 && NumberOfPolygons == 0 && NumberOfPolyhedron == 0)
1449         return MED_ERROR;
1450       else
1451         return MED_VALID;
1452
1453     }
1454   return MED_ERROR;
1455 }
1456
1457 int  MED_MESH_RDONLY_DRIVER22::getFAMILY() 
1458 {
1459   const char * LOC = "MED_MESH_RDONLY_DRIVER22::getFAMILY() : " ;
1460   BEGIN_OF(LOC);
1461
1462   if (_status==MED_OPENED)
1463     {
1464       int err = 0 ;
1465
1466       int * MEDArrayNodeFamily = NULL ;
1467       int ** MEDArrayCellFamily = NULL ;
1468       int ** MEDArrayFaceFamily = NULL ;
1469       int ** MEDArrayEdgeFamily = NULL ;
1470
1471     // NODE :
1472       MEDArrayNodeFamily = new int[_ptrMesh->getNumberOfNodes()] ;
1473
1474       err = getNodesFamiliesNumber(MEDArrayNodeFamily) ;
1475       // error only if (_status!=MED_OPENED), other case exeception !
1476       // CELL
1477
1478       MESSAGE(LOC << "error returned from getNodesFamiliesNumber " << err);
1479
1480       MEDArrayCellFamily = new int* [_ptrMesh->getNumberOfTypesWithPoly(MED_CELL)] ;
1481       // ET SI IL N'Y A PAS DE CELLS ?
1482
1483       medGeometryElement * myTypes = _ptrMesh->getTypesWithPoly(MED_CELL);
1484       for (int i=0;i<_ptrMesh->getNumberOfTypesWithPoly(MED_CELL);i++)
1485         MEDArrayCellFamily[i] = new
1486           int[_ptrMesh->getNumberOfElementsWithPoly(MED_CELL,myTypes[i])] ;
1487
1488       err = getCellsFamiliesNumber(MEDArrayCellFamily,
1489                                    _ptrMesh->_connectivity,MED_CELL) ;
1490       delete [] myTypes;
1491
1492       MESSAGE(LOC << "error returned from getCellsFamiliesNumber for Cells " << err);
1493
1494     if (_ptrMesh->_connectivity->_constituent != NULL)
1495       {
1496         if (_ptrMesh->_connectivity->_constituent->_entity == MED_EN::MED_FACE)
1497           {
1498             // FACE
1499             MEDArrayFaceFamily = new
1500               int* [_ptrMesh->getNumberOfTypesWithPoly(MED_FACE)] ;
1501
1502             myTypes = _ptrMesh->getTypesWithPoly(MED_FACE);
1503             for (int i=0;i<_ptrMesh->getNumberOfTypesWithPoly(MED_FACE);i++)
1504               MEDArrayFaceFamily[i] = new
1505                 int[_ptrMesh->getNumberOfElementsWithPoly(MED_FACE,myTypes[i])] ;
1506
1507             err =
1508               getCellsFamiliesNumber(MEDArrayFaceFamily,
1509                                      _ptrMesh->_connectivity->_constituent,MED_FACE) ;
1510             delete [] myTypes;
1511             MESSAGE(LOC << "error returned from getCellsFamiliesNumber for Faces " << err);
1512           }
1513         else
1514           {
1515             // EDGE in 2D
1516             MEDArrayEdgeFamily = new
1517               int* [_ptrMesh->getNumberOfTypes(MED_EDGE)] ;
1518
1519             const medGeometryElement *myTypes2 = _ptrMesh->getTypes(MED_EDGE);
1520             for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_EDGE);i++)
1521               MEDArrayEdgeFamily[i] = new
1522                 int[_ptrMesh->getNumberOfElements(MED_EDGE,myTypes2[i])] ;
1523
1524             err =
1525               getCellsFamiliesNumber(MEDArrayEdgeFamily,
1526                                      _ptrMesh->_connectivity->_constituent,MED_FACE) ;
1527           
1528             MESSAGE(LOC << "error returned from getCellsFamiliesNumber for Edges in 2D " << err);
1529           }
1530         // EDGE in 3D
1531         if (_ptrMesh->_connectivity->_constituent->_constituent != NULL)
1532           {
1533             MEDArrayEdgeFamily = new
1534               int* [_ptrMesh->getNumberOfTypes(MED_EDGE)] ;
1535
1536             const medGeometryElement *myTypes2 = _ptrMesh->getTypes(MED_EDGE);
1537             for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_EDGE);i++)
1538               MEDArrayEdgeFamily[i] = new
1539                 int[_ptrMesh->getNumberOfElements(MED_EDGE,myTypes2[i])] ;
1540
1541             err =
1542               getCellsFamiliesNumber(MEDArrayEdgeFamily,
1543                                      _ptrMesh->_connectivity->_constituent->_constituent,MED_EDGE);
1544             // we are in 3D !
1545         
1546             MESSAGE(LOC << "error returned from getCellsFamiliesNumber for Edges in 3D " << err);
1547
1548           }
1549       }
1550
1551     int NumberOfFamilies = med_2_2::MEDnFam(_medIdt, const_cast <char *>
1552                                            (_meshName.c_str())) ;
1553
1554     if ( NumberOfFamilies < 1 ) // at least family 0 must exist 
1555       throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"There is no FAMILY, FAMILY 0 must exists" ));
1556
1557     SCRUTE(NumberOfFamilies);
1558
1559     vector<FAMILY*> &NodeFamilyVector = _ptrMesh->_familyNode ;
1560     vector<FAMILY*> &CellFamilyVector = _ptrMesh->_familyCell ;
1561     vector<FAMILY*> &FaceFamilyVector = _ptrMesh->_familyFace ;
1562     vector<FAMILY*> &EdgeFamilyVector = _ptrMesh->_familyEdge ;
1563
1564     int numberOfNodesFamilies = 0 ;
1565     int numberOfCellsFamilies = 0 ;
1566     int numberOfFacesFamilies = 0 ;
1567     int numberOfEdgesFamilies = 0 ;
1568
1569     for (int i=0;i<NumberOfFamilies;i++)
1570       {
1571         int NumberOfAttributes = med_2_2::MEDnAttribut(_medIdt,
1572                                                       const_cast <char *>
1573                                                       (_meshName.c_str()),
1574                                                       (i+1));
1575       
1576       if (NumberOfAttributes < 0) 
1577         throw MEDEXCEPTION("MED_MESH_RDONLY_DRIVER22::getFAMILY() : NumberOfAttributes" );
1578
1579         int NumberOfGroups = med_2_2::MEDnGroupe(_medIdt, const_cast <char *>
1580                                                 (_meshName.c_str()),(i+1)) ;
1581
1582         if (NumberOfGroups < 0)
1583           throw MEDEXCEPTION("MED_MESH_RDONLY_DRIVER22::getFAMILY() : NumberOfGroups" );
1584       
1585         int FamilyIdentifier ;
1586         string FamilyName(MED_TAILLE_NOM,'\0');
1587         int *  AttributesIdentifier = new int[NumberOfAttributes] ;
1588         int *  AttributesValues     = new int[NumberOfAttributes] ;
1589         string AttributesDescription(MED_TAILLE_DESC*NumberOfAttributes,' ') ;
1590         string GroupsNames(MED_TAILLE_LNOM*NumberOfGroups+1,'\0') ;
1591         err = med_2_2::MEDfamInfo(_medIdt,const_cast <char *>
1592                                  (_meshName.c_str()),
1593                                  (i+1),const_cast <char *>
1594                                  (FamilyName.c_str()), &FamilyIdentifier,
1595                                  AttributesIdentifier,AttributesValues,
1596                                  const_cast <char *>
1597                                  (AttributesDescription.c_str()),
1598                                  &NumberOfAttributes, const_cast <char *>
1599                                  (GroupsNames.c_str()),&NumberOfGroups);
1600
1601
1602         SCRUTE(GroupsNames);
1603         SCRUTE(FamilyName);
1604         SCRUTE(err);
1605         SCRUTE(i);
1606
1607       if (err != MED_VALID)
1608         throw MEDEXCEPTION("MED_MESH_RDONLY_DRIVER22::getFAMILY() : ERROR when get FAMILY informations" );
1609
1610         if (FamilyIdentifier != 0 )
1611           {
1612             FAMILY * Family = new FAMILY(_ptrMesh,FamilyIdentifier,FamilyName,
1613                                          NumberOfAttributes,
1614                                          AttributesIdentifier,
1615                                          AttributesValues,
1616                                          AttributesDescription,
1617                                          NumberOfGroups,GroupsNames,
1618                                          MEDArrayNodeFamily,
1619                                          MEDArrayCellFamily,
1620                                          MEDArrayFaceFamily,
1621                                          MEDArrayEdgeFamily) ;
1622
1623             // All good ?
1624             // if nothing found, delete Family
1625
1626             if (Family->getNumberOfTypes() == 0)
1627               {
1628                 MESSAGE(LOC<<"Nothing found for family "<<FamilyName<<
1629                         " : skip");
1630                 delete Family;
1631               }
1632             else
1633               switch (Family->getEntity())
1634                 {
1635                 case MED_EN::MED_NODE :
1636                   NodeFamilyVector.push_back(Family) ;
1637                   numberOfNodesFamilies++ ;
1638                   break ;
1639                 case MED_EN::MED_CELL :
1640                   CellFamilyVector.push_back(Family) ;
1641                   numberOfCellsFamilies++ ;
1642                   break ;
1643                 case MED_EN::MED_FACE :
1644                   FaceFamilyVector.push_back(Family) ;
1645                   numberOfFacesFamilies++ ;
1646                   break ;
1647                 case MED_EN::MED_EDGE :
1648                   EdgeFamilyVector.push_back(Family) ;
1649                   numberOfEdgesFamilies++ ;
1650                   break ;
1651                 }
1652             //  MESSAGE(LOC << (*Family));
1653           }
1654
1655         delete [] AttributesIdentifier ;
1656         delete [] AttributesValues ;
1657       }
1658
1659     if (MEDArrayNodeFamily != NULL)
1660       delete[] MEDArrayNodeFamily ;
1661
1662     if (MEDArrayCellFamily != NULL)
1663       {
1664         for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_CELL);i++)
1665           delete[] MEDArrayCellFamily[i] ;
1666         delete[] MEDArrayCellFamily ;
1667       }
1668
1669     if (MEDArrayFaceFamily != NULL)
1670       {
1671         for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_FACE);i++)
1672           delete[] MEDArrayFaceFamily[i] ;
1673         delete[] MEDArrayFaceFamily ;
1674       }
1675
1676     if (MEDArrayEdgeFamily != NULL)
1677       {
1678         for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_EDGE);i++)
1679           delete[] MEDArrayEdgeFamily[i] ;
1680         delete[] MEDArrayEdgeFamily ;
1681       }
1682
1683     END_OF(LOC);
1684     return MED_VALID ;
1685     }
1686
1687   return MED_ERROR;
1688 }
1689
1690 int  MED_MESH_RDONLY_DRIVER22::getNodesFamiliesNumber(int * MEDArrayNodeFamily)
1691 {
1692   const char * LOC = "MED_MESH_RDONLY_DRIVER22::getNodesFamiliesNumber() : " ;
1693
1694   BEGIN_OF(LOC);
1695
1696   if (_status==MED_OPENED)
1697     {
1698     int err = 0 ;
1699
1700       err = MEDfamLire(_medIdt, const_cast <char *>
1701                        (_ptrMesh->_name.c_str()), MEDArrayNodeFamily,
1702                        _ptrMesh->getNumberOfNodes(), med_2_2::MED_NOEUD,
1703                        (med_2_2::med_geometrie_element) MED_NONE);
1704
1705       if ( err != MED_VALID)
1706         throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "There is no family for the |"<< _ptrMesh->getNumberOfNodes() << "| nodes in mesh |" << _ptrMesh->_name.c_str() << "|"));
1707
1708       END_OF(LOC);
1709       return MED_VALID;
1710     }
1711
1712   return MED_ERROR;
1713 }
1714
1715 int  MED_MESH_RDONLY_DRIVER22::getCellsFamiliesNumber(int **MEDArrayFamily,
1716                                                       CONNECTIVITY *Connectivity,
1717                                                       MED_EN::medEntityMesh entity) 
1718 {
1719   const char * LOC = "MED_MESH_RDONLY_DRIVER22::getCellsFamiliesNumber " ;
1720
1721   BEGIN_OF(LOC);
1722
1723   if (_status==MED_OPENED)
1724     {
1725     int i, err = 0 ;
1726     MED_EN::medGeometryElement *types=Connectivity->getGeometricTypesWithPoly(Connectivity->_entity);
1727     for (i=0;i<Connectivity->getNumberOfTypesWithPoly(Connectivity->_entity);i++)
1728       {
1729         int NumberOfCell=Connectivity->getNumberOfElementsWithPoly(Connectivity->_entity,types[i]);
1730         err=MEDfamLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
1731                        MEDArrayFamily[i],NumberOfCell,
1732                        (med_2_2::med_entite_maillage) Connectivity->_entity,
1733                        (med_2_2::med_geometrie_element)types[i]);
1734         if (err != MED_VALID)
1735           {
1736             err=MEDfamLire(_medIdt,const_cast <char *>
1737                            (_ptrMesh->_name.c_str()),
1738                            MEDArrayFamily[i],NumberOfCell,
1739                            med_2_2::MED_MAILLE,
1740                            (med_2_2::med_geometrie_element)types[i]);
1741             if (err != MED_VALID)
1742               throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Family not found for entity "<<Connectivity->_entity<<" and geometric type "<<Connectivity->_geometricTypes[i]));
1743           }
1744       }
1745     delete [] types;
1746     return MED_VALID;
1747     }
1748   return MED_ERROR;
1749 }
1750
1751 /*--------------------- WRONLY PART -------------------------------*/
1752
1753 MED_MESH_WRONLY_DRIVER22::MED_MESH_WRONLY_DRIVER22()
1754 {
1755 }
1756   
1757 MED_MESH_WRONLY_DRIVER22::MED_MESH_WRONLY_DRIVER22(const string & fileName,
1758                                                    MESH * ptrMesh):
1759   MED_MESH_DRIVER22(fileName,ptrMesh,MED_WRONLY),IMED_MESH_WRONLY_DRIVER(fileName,ptrMesh),MED_MESH_DRIVER(fileName,ptrMesh,MED_WRONLY)
1760 {
1761   MESSAGE("MED_MESH_WRONLY_DRIVER22::MED_MESH_WRONLY_DRIVER22(const string & fileName, MESH * ptrMesh) has been created");
1762 }
1763
1764 MED_MESH_WRONLY_DRIVER22::MED_MESH_WRONLY_DRIVER22(const MED_MESH_WRONLY_DRIVER22 & driver):
1765   IMED_MESH_WRONLY_DRIVER(driver),MED_MESH_DRIVER22(driver),MED_MESH_DRIVER(driver)
1766 {
1767 }
1768
1769 MED_MESH_WRONLY_DRIVER22::~MED_MESH_WRONLY_DRIVER22()
1770 {
1771   //MESSAGE("MED_MESH_WRONLY_DRIVER22::MED_MESH_WRONLY_DRIVER22(const string & fileName, MESH * ptrMesh) has been destroyed");
1772 }
1773
1774 GENDRIVER * MED_MESH_WRONLY_DRIVER22::copy(void) const
1775 {
1776   return new MED_MESH_WRONLY_DRIVER22(*this);
1777 }
1778
1779 void MED_MESH_WRONLY_DRIVER22::write(void) const
1780
1781   const char * LOC = "void MED_MESH_WRONLY_DRIVER22::write(void) const : ";
1782   BEGIN_OF(LOC);
1783
1784   // we must first create mesh !!
1785   MESSAGE(LOC << "MeshName : |" << _meshName << "| FileName : |"<<_fileName<<"| MedIdt : | "<< _medIdt << "|");
1786
1787   if (_status!=MED_OPENED)
1788     throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "File "<<_fileName<<" is not open. Open it before write !"));
1789
1790   if (_ptrMesh->getIsAGrid())
1791   {
1792     if ( writeGRID() != MED_VALID )
1793       throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeGRID()"  )) ;
1794   }
1795   else
1796   {
1797     if (writeCoordinates()!=MED_VALID)
1798       throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeCoordinates()"  )) ;
1799
1800     if (writeConnectivities(MED_EN::MED_CELL)!=MED_VALID)
1801       throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeConnectivities(MED_CELL)"  )) ;
1802     if (writeConnectivities(MED_EN::MED_FACE)!=MED_VALID)
1803       throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeConnectivities(MED_FACE)"  )) ;
1804     if (writeConnectivities(MED_EN::MED_EDGE)!=MED_VALID)
1805       throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeConnectivities(MED_EDGE)"  )) ;
1806   }
1807
1808   if (writeFamilyNumbers() !=MED_VALID)
1809     throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilyNumbers()"  )) ;
1810   
1811
1812   // well we must first write zero family :
1813   if (_status==MED_OPENED) {
1814     int err ;
1815     // test if the family already exists (HDF trick waiting a MED evolution to be replaced)
1816     string dataGroupFam = "/ENS_MAA/"+_meshName+"/FAS/FAMILLE_ZERO/";  
1817     MESSAGE("|"<<dataGroupFam<<"|");
1818     err =med_2_2::_MEDdatagroupOuvrir(_medIdt,const_cast <char *> (dataGroupFam.c_str()) );
1819     if ( err < MED_VALID ) {
1820       SCRUTE(err);
1821
1822       char familyName[MED_TAILLE_NOM+1];
1823       //      strcpy(familyName,"FAMILLE_ZERO");
1824       err = med_2_2::MEDfamCr( _medIdt,
1825                               const_cast <char *> ( _meshName.c_str() ),
1826                               familyName, 0,
1827                               (int*)NULL, (int*)NULL, (char*)NULL, 0,
1828                               (char*)NULL, 0);
1829
1830       SCRUTE(familyName);
1831       
1832       if ( err != MED_VALID) 
1833         throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't create family |FAMILLE_ZERO| with identifier |0| groups names || and  attributes descriptions ||")) ;
1834     }
1835     else
1836       med_2_2::_MEDdatagroupFermer(_medIdt);
1837      
1838   }
1839
1840   MESSAGE(LOC<<"writeFamilies(_ptrMesh->_familyNode)");
1841   if (writeFamilies(_ptrMesh->_familyNode) !=MED_VALID)
1842     throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilies(_ptrMesh->_familyNode)"  )) ;
1843
1844   MESSAGE(LOC<<"writeFamilies(_ptrMesh->_familyCell)");
1845   if (writeFamilies(_ptrMesh->_familyCell) !=MED_VALID)
1846     throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilies(_ptrMesh->_familyCell)"  )) ;
1847
1848   MESSAGE(LOC<<"writeFamilies(_ptrMesh->_familyFace)");
1849   if (writeFamilies(_ptrMesh->_familyFace) !=MED_VALID)
1850     throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilies(_ptrMesh->_familyFace)"  )) ;
1851
1852   MESSAGE(LOC<<"writeFamilies(_ptrMesh->_familyEdge)");
1853   if (writeFamilies(_ptrMesh->_familyEdge) !=MED_VALID)
1854     throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilies(_ptrMesh->_familyEdge)"  )) ;
1855
1856   END_OF(LOC);
1857
1858
1859 //=======================================================================
1860 //function : writeGRID
1861 //purpose  : 
1862 //=======================================================================
1863
1864 int MED_MESH_WRONLY_DRIVER22::writeGRID() const
1865 {
1866   const char * LOC = "MED_MESH_WRONLY_DRIVER22::writeGRID() : " ;
1867   BEGIN_OF(LOC);
1868   
1869   if (_status!=MED_OPENED)
1870   {
1871     MESSAGE (LOC<<" Not open !!!");
1872     return MED_ERROR;
1873   }
1874   GRID * ptrGrid = (GRID*) _ptrMesh;
1875   
1876   med_2_2::med_err err = MED_ERROR;
1877   med_2_2::med_repere rep;
1878   string tmp_name(_ptrMesh->_spaceDimension*MED_TAILLE_PNOM22,' ');
1879   string tmp_unit(_ptrMesh->_spaceDimension*MED_TAILLE_PNOM22,' ');
1880
1881   // Test if the mesh <_meshName> already exists
1882   // If it doesn't exists create it
1883   // If it already exists verify if its space and mesh dimensions are the same
1884   // as <_ptrMesh->_spaceDimension>, <_ptrMesh->_meshDimension> respectively
1885   // rem : <_meshName> is the driver meshName not <ptrMesh->_meshName>
1886
1887   int spaceDimension = med_2_2::MEDdimEspaceLire(_medIdt, const_cast <char *>
1888                                                 (_meshName.c_str()) );
1889
1890   int meshDimension = med_2_2::MEDdimLire(_medIdt, const_cast <char *>
1891                                          (_meshName.c_str()) );
1892
1893
1894   MESSAGE(LOC << "spacedim " << spaceDimension << " meshdim " << meshDimension);
1895
1896   MESSAGE(LOC << "From the mesh spacedim " << _ptrMesh->_spaceDimension << " meshdim " << _ptrMesh->_meshDimension);
1897
1898   if ((spaceDimension <= MED_VALID) && (meshDimension <= MED_VALID))
1899     {
1900       err = MEDmaaCr(_medIdt,
1901                      const_cast <char *> (_meshName.c_str()),
1902                      _ptrMesh->_meshDimension,med_2_2::MED_STRUCTURE,
1903                      const_cast <char *> (_ptrMesh->_description.c_str()));
1904
1905       meshDimension =  _ptrMesh->_meshDimension;
1906
1907       if (err != MED_VALID)
1908         throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Unable to create Grid"));
1909       else 
1910         MESSAGE(LOC<<"Grid "<<_meshName<<" created in file "<<_fileName<<" !");
1911     }
1912   else if ((spaceDimension != _ptrMesh->_spaceDimension)  &&
1913            (meshDimension != _ptrMesh->_meshDimension))
1914     throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Grid |" << _meshName.c_str() <<
1915                                  "| already exists in file |" << _fileName <<
1916                                  "| with space dimension |" << spaceDimension <<
1917                                  "| and mesh dimension |" << meshDimension <<
1918                                  "| but the space dimension and the mesh dimension of the mesh we want to write are respectively |"
1919                                  << _ptrMesh->_spaceDimension <<"|" <<
1920                                  _ptrMesh->_meshDimension <<"|" )) ;
1921
1922   MED_EN::med_grid_type gridType = ptrGrid->getGridType();
1923
1924   err = med_2_2::MEDnatureGrilleEcr(_medIdt,
1925                                    const_cast <char *> (_meshName.c_str()),
1926                                    (med_2_2::med_type_grille) gridType);
1927
1928   if (err != MED_VALID)
1929     throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Unable to write the type of the Grid"));
1930
1931   // Recompose the <_spaceDimension> strings in 1 string 
1932   int lengthString ;
1933   string valueString ;
1934   for (int i=0;i<_ptrMesh->_spaceDimension;i++) {
1935     SCRUTE(i);
1936     valueString = _ptrMesh->_coordinate->_coordinateName[i] ;
1937     lengthString = (MED_TAILLE_PNOM22<valueString.size())?MED_TAILLE_PNOM22:valueString.size() ;
1938     tmp_name.replace(i*MED_TAILLE_PNOM22,i*MED_TAILLE_PNOM22+lengthString,valueString,0,lengthString);
1939     valueString = _ptrMesh->_coordinate->_coordinateUnit[i];
1940     lengthString = (MED_TAILLE_PNOM22<valueString.size())?MED_TAILLE_PNOM22:valueString.size() ;
1941     tmp_unit.replace(i*MED_TAILLE_PNOM22,i*MED_TAILLE_PNOM22+lengthString,valueString,0,lengthString);
1942   }
1943
1944   // Pourquoi le stocker sous forme de chaîne ?
1945   const string & coordinateSystem = _ptrMesh->_coordinate->_coordinateSystem;
1946   if      (coordinateSystem  == "CARTESIAN") 
1947     rep = med_2_2::MED_CART;
1948   else if ( coordinateSystem == "CYLINDRICAL")
1949     rep = med_2_2::MED_CYL;
1950   else if ( coordinateSystem == "SPHERICAL" )
1951     rep = med_2_2::MED_SPHER;
1952   else
1953     throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Grid |" << _meshName.c_str() <<
1954                                  "| doesn't have a valid coordinate system : |" 
1955                                  << _ptrMesh->_coordinate->_coordinateSystem
1956                                  << "|" )) ;  
1957
1958   med_2_2::med_int ArrayLen[] = { (med_2_2::med_int) ptrGrid->_iArrayLength,
1959                      (med_2_2::med_int) ptrGrid->_jArrayLength,
1960                      (med_2_2::med_int) ptrGrid->_kArrayLength  };
1961   
1962   // Write node coordinates for MED_BODY_FITTED grid
1963   if (gridType == MED_EN::MED_BODY_FITTED)
1964     {
1965       // Write Coordinates and families
1966 //       double * coo = const_cast <double *>
1967 //      (_ptrMesh->_coordinate->getCoordinates(MED_EN::MED_FULL_INTERLACE));
1968
1969       err = MEDcoordEcr(_medIdt, const_cast <char *> (_meshName.c_str()),
1970                         _ptrMesh->_spaceDimension, 
1971                         //const_cast <double *> ( _ptrMesh->_coordinate->_coordinate->get(MED_EN::MED_FULL_INTERLACE) ), 
1972                         const_cast <double *> ( _ptrMesh->_coordinate->_coordinate.get(MED_EN::MED_FULL_INTERLACE) ), 
1973                         med_2_2::MED_FULL_INTERLACE, _ptrMesh->_numberOfNodes,
1974                         //  _ptrMesh->_coordinate->_numberOfNodes
1975                         rep, const_cast <char *> (tmp_name.c_str()), 
1976                         const_cast <char *> (tmp_unit.c_str()));
1977
1978       if (err != MED_VALID) 
1979         throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write coordinates of the grid |" << _meshName.c_str() << "| in file |" << _fileName
1980                                      << "| with dimension |"  << _ptrMesh->_spaceDimension <<"| and" 
1981                                      << " with units names |"  << tmp_name
1982                                      << "| and units |"       << tmp_unit
1983                                      << " |")) ;
1984
1985       int* structure = new int [meshDimension];
1986
1987       for (int idim = 0; idim < meshDimension; ++idim)
1988         structure[idim] = ArrayLen [idim];
1989  
1990
1991       err = med_2_2::MEDstructureCoordEcr(_medIdt, const_cast <char *>
1992                                          (_meshName.c_str()), meshDimension,
1993                                          structure);
1994
1995       if (err != MED_VALID)
1996         throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"error in writing the structure of the grid |" << _meshName.c_str()));
1997
1998       delete structure;
1999     }
2000   else if ((gridType == MED_EN::MED_CARTESIAN) ||
2001            (gridType == MED_EN::MED_POLAR))
2002     {
2003       // Write Arrays of Cartesian or Polar Grid
2004
2005       double * Array[] = { ptrGrid->_iArray,
2006                            ptrGrid->_jArray,
2007                            ptrGrid->_kArray };
2008
2009       for (int idim = 0; idim < _ptrMesh->_meshDimension; ++idim)
2010         {
2011           string str_name = string (tmp_name,idim*MED_TAILLE_PNOM22,
2012                                     MED_TAILLE_PNOM22);
2013           string str_unit = string (tmp_unit,idim*MED_TAILLE_PNOM22,
2014                                     MED_TAILLE_PNOM22);
2015
2016           err = med_2_2::MEDindicesCoordEcr(_medIdt, const_cast <char *>
2017                                            (_ptrMesh->_name.c_str()),
2018                                            _ptrMesh->_meshDimension,
2019                                            Array[idim], ArrayLen[idim],
2020                                            (idim+1), const_cast <char *>
2021                                            (str_name.c_str()),
2022                                            const_cast <char *>
2023                                            (str_unit.c_str()));
2024
2025           if (err != MED_VALID)
2026             throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<
2027                                          "Can't write grid coordinates for " <<
2028                                          idim << "-th dimention"));
2029         }
2030   } // end Write  Cartesian or Polar Grid
2031
2032   END_OF(LOC);
2033   return MED_VALID;
2034 }
2035
2036 //=======================================================================
2037 //function : writeCoordinates
2038 //purpose  : 
2039 //=======================================================================
2040
2041 int MED_MESH_WRONLY_DRIVER22::writeCoordinates() const {
2042  
2043   const char * LOC = "int MED_MESH_WRONLY_DRIVER22::writeCoordinates() const : ";
2044   BEGIN_OF(LOC);
2045
2046   med_2_2::med_err err = MED_ERROR;
2047   med_2_2::med_repere rep;
2048   string tmp_name(_ptrMesh->_spaceDimension*MED_TAILLE_PNOM22,' ');
2049   string tmp_unit(_ptrMesh->_spaceDimension*MED_TAILLE_PNOM22,' ');
2050     
2051   // Recompose the <_spaceDimension> strings in 1 string 
2052   int lengthString ;
2053   string valueString ;
2054   for (int i=0;i<_ptrMesh->_spaceDimension;i++) {
2055     valueString = _ptrMesh->_coordinate->_coordinateName[i] ;
2056     lengthString = (MED_TAILLE_PNOM22<valueString.size())?MED_TAILLE_PNOM22:valueString.size() ;
2057     tmp_name.replace(i*MED_TAILLE_PNOM22,i*MED_TAILLE_PNOM22+lengthString,valueString,0,lengthString);
2058     valueString = _ptrMesh->_coordinate->_coordinateUnit[i];
2059     lengthString = (MED_TAILLE_PNOM22<valueString.size())?MED_TAILLE_PNOM22:valueString.size() ;
2060     tmp_unit.replace(i*MED_TAILLE_PNOM22,i*MED_TAILLE_PNOM22+lengthString,valueString,0,lengthString);
2061   }
2062
2063   // Test if the mesh <_meshName> already exists
2064   // If it doesn't exists create it
2065   // If it already exists verify if its space and mesh dimensions are the same
2066   // as <_ptrMesh->_spaceDimension>, <_ptrMesh->_meshDimension> respectively
2067   // rem : <_meshName> is the driver meshName not <ptrMesh->_meshName>
2068
2069   int spaceDimension = med_2_2::MEDdimEspaceLire(_medIdt, const_cast <char *>
2070                                                 (_meshName.c_str()));
2071
2072   int meshDimension = med_2_2::MEDdimLire(_medIdt, const_cast <char *>
2073                                          (_meshName.c_str()) );
2074
2075   if ((spaceDimension != MED_VALID) && (meshDimension != MED_VALID))
2076     {
2077       err = MEDmaaCr(_medIdt, const_cast <char *> (_meshName.c_str()),
2078                      _ptrMesh->_meshDimension, med_2_2::MED_NON_STRUCTURE,
2079                      const_cast <char *> (_ptrMesh->_description.c_str()));
2080
2081       if (err != MED_VALID)
2082         throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Unable to create Mesh : |" << _meshName << "|"));
2083       else 
2084         MESSAGE(LOC<<"Mesh "<<_meshName<<" created in file "<<_fileName<<" !");
2085     }
2086   else if ((spaceDimension != _ptrMesh->_spaceDimension)  &&
2087            (meshDimension != _ptrMesh->_meshDimension))
2088     throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Mesh |" << _meshName.c_str() <<
2089                                  "| already exists in file |" << _fileName <<
2090                                  "| with space dimension |" << spaceDimension <<
2091                                  "| and mesh dimension |" << meshDimension <<
2092                                  "| but the space dimension and the mesh dimension of the mesh we want to write are respectively |"
2093                                  << _ptrMesh->_spaceDimension <<"|" <<
2094                                  _ptrMesh->_meshDimension << "|")) ;
2095     
2096   // Pourquoi le stocker sous forme de chaîne ?
2097   const string & coordinateSystem = _ptrMesh->_coordinate->_coordinateSystem;
2098   if      (coordinateSystem  == "CARTESIAN") 
2099     rep = med_2_2::MED_CART;
2100   else if ( coordinateSystem == "CYLINDRICAL")
2101     rep = med_2_2::MED_CYL;
2102   else if ( coordinateSystem == "SPHERICAL" )
2103     rep = med_2_2::MED_SPHER;
2104   else
2105     throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Mesh |" << _meshName.c_str() << "| doesn't have a valid coordinate system : |" 
2106                                  << _ptrMesh->_coordinate->_coordinateSystem
2107                                  << "|" )) ;  
2108       
2109 //   err = MEDcoordEcr(_medIdt, const_cast <char *> (_meshName.c_str()),
2110 //                  _ptrMesh->_spaceDimension, 
2111 //                  //const_cast <double *> ( _ptrMesh->_coordinate->_coordinate->get(MED_EN::MED_FULL_INTERLACE) ), 
2112 //                  const_cast <double *> ( _ptrMesh->_coordinate->_coordinate.get(MED_EN::MED_FULL_INTERLACE) ), 
2113 //                  MED_FR::MED_FULL_INTERLACE, 
2114 //                  _ptrMesh->_numberOfNodes,                 //  _ptrMesh->_coordinate->_numberOfNodes
2115 //                  MED_FR::MED_LECTURE_ECRITURE,    
2116 //                  rep,
2117 //                  const_cast <char *> (tmp_name.c_str()), 
2118 //                  const_cast <char *> (tmp_unit.c_str()) 
2119 //                  );
2120
2121   err = MEDcoordEcr(_medIdt, const_cast <char *> (_meshName.c_str()),
2122                     _ptrMesh->_spaceDimension, 
2123                     //const_cast <double *> ( _ptrMesh->_coordinate->_coordinate->get(MED_EN::MED_FULL_INTERLACE) ), 
2124                     const_cast <double *> ( _ptrMesh->_coordinate->_coordinate.get(MED_EN::MED_FULL_INTERLACE) ), 
2125                     med_2_2::MED_FULL_INTERLACE, _ptrMesh->_numberOfNodes,
2126                     //  _ptrMesh->_coordinate->_numberOfNodes
2127                     rep, const_cast <char *> (tmp_name.c_str()), 
2128                     const_cast <char *> (tmp_unit.c_str()));
2129
2130   if (err<0) 
2131     throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write coordinates of mesh |" << _meshName.c_str() << "| in file |" << _fileName
2132                                  << "| with dimension |"  << _ptrMesh->_spaceDimension <<"| and" 
2133                                  << " with units names |"  << tmp_name
2134                                  << "| and units |"       << tmp_unit
2135                                  << " |")) ;    
2136     
2137
2138        //////////////////////////////////////////////////////////////////////////////////////
2139        ///  Modification pour prise en compte de la numérotation optionnelle des noeuds   ///
2140        //////////////////////////////////////////////////////////////////////////////////////
2141        ///
2142        /// Ecrit les numéros optionnels des noeuds
2143        /// Le traitement est identique à la version originelle s'il n'y a pas de numérotation optionnelle
2144
2145
2146       if (_ptrMesh->_arePresentOptionnalNodesNumbers==1) {
2147         
2148         err =  MEDnumEcr(_medIdt, const_cast <char *> (_meshName.c_str()),
2149                          const_cast <med_int *> (_ptrMesh->_coordinate->getNodesNumbers() ), 
2150                          _ptrMesh->_numberOfNodes, med_2_2::MED_NOEUD,
2151                          med_2_2::med_geometrie_element(0) );
2152
2153         if (err != MED_VALID) 
2154           throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write optionnal numbers of mesh |" << 
2155                                        _meshName.c_str() << "| in file |" <<
2156                                        _fileName  << " |")) ;
2157       }
2158       //////////////////////////////////////////////////////////////////////////////////////
2159
2160   END_OF(LOC);
2161     
2162   return MED_VALID;
2163 }
2164
2165
2166
2167
2168 int MED_MESH_WRONLY_DRIVER22::writeConnectivities(medEntityMesh entity) const 
2169 {
2170   const char * LOC="int MED_MESH_WRONLY_DRIVER22::writeConnectivities() const : ";
2171   BEGIN_OF(LOC);
2172
2173   med_2_2::med_err err;
2174   
2175   // REM SI LA METHODE EST APPELEE DIRECTEMENT ET QUE LE MAILLAGE N'EST PAS CREE IL Y A PB !
2176   // PG : IMPOSSIBLE : LA METHODE EST PRIVEE !
2177     
2178   // A FAIRE : A tester surtout dans les methodes de MESH.
2179   //    if ( _ptrMesh->_connectivity == (CONNECTIVITY *) MED_INVALID )
2180   if ( _ptrMesh->_connectivity == (CONNECTIVITY *) NULL )
2181     throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The connectivity is not defined in the MESH object ")) ;
2182
2183
2184   // Nodal connectivity for classic geometric types
2185   if   ( _ptrMesh->existConnectivity(MED_NODAL,entity) ) 
2186     {
2187
2188       int numberOfTypes           = _ptrMesh->getNumberOfTypes (entity) ;
2189       const medGeometryElement  * types = _ptrMesh->getTypes         (entity) ;
2190
2191       for (int i=0; i<numberOfTypes; i++) 
2192         {
2193
2194           int    numberOfElements = _ptrMesh->getNumberOfElements (entity,types[i]);
2195           const int * connectivity      = _ptrMesh->getConnectivity     (MED_EN::MED_FULL_INTERLACE, 
2196                                                                          MED_NODAL, entity, types[i]); // ?? et SI MED_NODAL n'existe pas, recalcul auto ??
2197       
2198           // Pour l'instant la class utilise le multi.....
2199           int multi = 0 ;
2200           //      if (entity==MED_EN::MED_CELL)
2201           //        if ( (types[i]/ 100) < _ptrMesh->_spaceDimension) 
2202           //          multi=1 ;
2203           int numberOfNodes = types[i]%100 ;
2204           int * connectivityArray = new int[numberOfElements*(numberOfNodes+multi)];
2205       
2206           // version originale sans prise en compte des numéros optionnels 
2207           //     
2208           for (int j=0 ; j<numberOfElements; j++) 
2209             {
2210               for (int k=0; k<numberOfNodes; k++)
2211                 connectivityArray[j*(numberOfNodes+multi)+k]=connectivity[j*numberOfNodes+k] ;
2212
2213               if (multi>0) connectivityArray[j*(numberOfNodes+multi)+numberOfNodes]=0;
2214             }
2215       
2216           //////////////////////////////////////////////////////////////////////////////////////
2217           ///  Modification pour prise en compte de la numérotation optionnelle des noeuds   ///
2218               //////////////////////////////////////////////////////////////////////////////////////
2219               ///
2220               /// Dénumérote les sommets des mailles pour leur rendre leurs numéros optionnels
2221               /// Le traitement est identique à la version originelle s'il n'y a pas de numérotation optionnelle
2222
2223               //        if (_ptrMesh->_arePresentOptionnalNodesNumbers==1) 
2224               //                {
2225               //                const int * nodesNumbers = _ptrMesh->_coordinate->getNodesNumbers();
2226               //                for (int j=0 ; j<numberOfElements; j++) 
2227               //                        {
2228               //                        for (int k=0; k<numberOfNodes; k++) connectivityArray[j*(numberOfNodes+multi)+k]=nodesNumbers[connectivity[j*numberOfNodes+k]-1] ;
2229               //                        if (multi>0) connectivityArray[j*(numberOfNodes+multi)+numberOfNodes]=0;
2230               //                        }
2231               //                }
2232               //        else
2233               //                {
2234               //                for (int j=0 ; j<numberOfElements; j++) 
2235               //                        {
2236               //                        for (int k=0; k<numberOfNodes; k++) connectivityArray[j*(numberOfNodes+multi)+k]=connectivity[j*numberOfNodes+k] ;
2237               //                        if (multi>0) connectivityArray[j*(numberOfNodes+multi)+numberOfNodes]=0;
2238               //                        }
2239               //                }
2240
2241               //////////////////////////////////////////////////////////////////////////////////////
2242       
2243               //       err = MEDconnEcr( _medIdt, const_cast <char *> ( _meshName.c_str()), _ptrMesh->_spaceDimension,
2244               //                        connectivityArray, MED_FR::MED_FULL_INTERLACE , numberOfElements,
2245               //                        MED_FR::MED_LECTURE_ECRITURE,
2246               //                        (MED_FR::med_entite_maillage  ) entity, 
2247               //                        (MED_FR::med_geometrie_element) types[i], MED_FR::MED_NOD );
2248
2249               //          err = MEDconnEcr(_medIdt, const_cast <char *> ( _meshName.c_str()),
2250               //                           _ptrMesh->_spaceDimension, connectivityArray,
2251               //                           MED_FR::MED_FULL_INTERLACE , numberOfElements,
2252               //                           (MED_FR::med_entite_maillage  ) entity, 
2253               //                           (MED_FR::med_geometrie_element) types[i],
2254               //                           med_2_2::MED_NOD);
2255               
2256               err = MEDconnEcr(_medIdt, const_cast <char *> ( _meshName.c_str()),
2257                                _ptrMesh->_spaceDimension, connectivityArray,
2258                                med_2_2::MED_FULL_INTERLACE , numberOfElements,
2259                                (med_2_2::med_entite_maillage  ) MED_CELL, 
2260                                (med_2_2::med_geometrie_element) types[i],
2261                                med_2_2::MED_NOD);
2262
2263               delete[] connectivityArray ;
2264
2265               if (err<0) // ETENDRE LES EXPLICATIONS
2266                 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write connectivities of mesh |" << _meshName.c_str() << "| in file |" << _fileName
2267                                              << "| with dimension |"  << _ptrMesh->_spaceDimension <<"| and" 
2268                                              ));
2269         }
2270
2271     }
2272
2273
2274   // Polygons writing
2275   if (_ptrMesh->existPolygonsConnectivity(MED_NODAL,entity))
2276     {
2277       err = MEDpolygoneConnEcr(_medIdt,
2278                                const_cast <char *> (_meshName.c_str()),
2279                                const_cast <med_int*> (_ptrMesh->getPolygonsConnectivityIndex(MED_NODAL,entity)),
2280                                _ptrMesh->getNumberOfPolygons()+1,
2281                                const_cast <med_int*> (_ptrMesh->getPolygonsConnectivity(MED_NODAL,entity)),
2282                                (med_2_2::med_entite_maillage) entity,
2283                                med_2_2::MED_NOD);
2284
2285       if (err<0)
2286         throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write polygons nodal connectivities of mesh |" <<  _meshName.c_str() << "| in file |" << _fileName
2287                                              << "| with dimension |"  << _ptrMesh->_spaceDimension <<"| and" 
2288                                              ));
2289     }
2290
2291
2292   // Polyhedron writing
2293   if (_ptrMesh->existPolyhedronConnectivity(MED_NODAL,entity))
2294     {
2295       err = MEDpolyedreConnEcr(_medIdt,
2296                                const_cast <char *> (_meshName.c_str()),
2297                                const_cast <med_int*> (_ptrMesh->getPolyhedronIndex(MED_NODAL)),
2298                                _ptrMesh->getNumberOfPolyhedron()+1,
2299                                const_cast <med_int*> (_ptrMesh->getPolyhedronFacesIndex()),
2300                                _ptrMesh->getNumberOfPolyhedronFaces()+1,
2301                                const_cast <med_int*> (_ptrMesh->getPolyhedronConnectivity(MED_NODAL)),
2302                                med_2_2::MED_NOD);
2303
2304       if (err<0)
2305         throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write polyhedron nodal connectivities of mesh |" << _meshName.c_str() << "| in file |" << _fileName
2306                                      << "| with dimension |"  << _ptrMesh->_spaceDimension <<"| and" 
2307                                              ));
2308     }
2309
2310
2311   // Descending connectivity for classic geometric types
2312   if   ( _ptrMesh->existConnectivity(MED_DESCENDING,entity) )
2313     {
2314       
2315       int numberOfTypes           = _ptrMesh->getNumberOfTypes (entity) ;
2316       const medGeometryElement  * types = _ptrMesh->getTypes         (entity) ;
2317       
2318       for (int i=0; i<numberOfTypes; i++)
2319         {
2320         
2321           int    numberOfElements = _ptrMesh->getNumberOfElements (entity,types[i]);
2322           const int * connectivity = _ptrMesh->getConnectivity(MED_EN::MED_FULL_INTERLACE, MED_DESCENDING, entity, types[i]); 
2323       
2324       // Pour l'instant la class utilise le multi.....
2325           //       err = MED_FR::MEDconnEcr( _medIdt,
2326           //                            const_cast <char *> ( _meshName.c_str()),
2327           //                            _ptrMesh->_spaceDimension,
2328           //                            const_cast <int *> (connectivity),
2329           //                            MED_FR::MED_FULL_INTERLACE,
2330           //                            numberOfElements,
2331           //                            MED_FR::MED_LECTURE_ECRITURE,
2332           //                            (MED_FR::med_entite_maillage  ) entity, 
2333           //                            (MED_FR::med_geometrie_element) types[i],
2334           //                            MED_FR::MED_DESC );
2335
2336           err = med_2_2::MEDconnEcr(_medIdt,
2337                                 const_cast <char *> ( _meshName.c_str()),
2338                                 _ptrMesh->_spaceDimension,
2339                                 const_cast <int *> (connectivity),
2340                                 med_2_2::MED_FULL_INTERLACE,
2341                                 numberOfElements,
2342                                 (med_2_2::med_entite_maillage  ) entity, 
2343                                 (med_2_2::med_geometrie_element) types[i],
2344                                 med_2_2::MED_DESC );
2345         
2346           if (err<0) // ETENDRE LES EXPLICATIONS
2347             throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write connectivities of mesh |" << _meshName.c_str() << "| in file |" << _fileName
2348                                          << "| with dimension |"  << _ptrMesh->_spaceDimension <<"| and" 
2349                                          )) ;
2350             
2351         }
2352     }
2353
2354
2355   // Polygons writing
2356   if (_ptrMesh->existPolygonsConnectivity(MED_DESCENDING,entity))
2357     {
2358       err = MEDpolygoneConnEcr(_medIdt,
2359                                const_cast <char *> (_meshName.c_str()),
2360                                const_cast <med_int*> (_ptrMesh->getPolygonsConnectivityIndex(MED_DESCENDING,entity)),
2361                                _ptrMesh->getNumberOfPolygons()+1,
2362                                const_cast <med_int*> (_ptrMesh->getPolygonsConnectivity(MED_DESCENDING,entity)),
2363                                (med_2_2::med_entite_maillage) entity,
2364                                med_2_2::MED_DESC);
2365
2366       if (err<0)
2367         throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write polygons descending connectivities of mesh |" <<  _meshName.c_str() << "| in file |" << _fileName
2368                                              << "| with dimension |"  << _ptrMesh->_spaceDimension <<"| and" 
2369                                              ));
2370     }
2371
2372
2373   // Polyhedron writing
2374   if (_ptrMesh->existPolyhedronConnectivity(MED_DESCENDING,entity))
2375     {
2376       med_int NumberOfFaces = _ptrMesh->getPolyhedronIndex(MED_DESCENDING)[_ptrMesh->getNumberOfPolyhedron()]-1;
2377       vector<med_int> FacesGeometricTypes(NumberOfFaces,MED_POLYGON); // by default all polyhedron faces are polygons
2378
2379       err = MEDpolyedreConnEcr(_medIdt,
2380                                const_cast <char *> (_meshName.c_str()),
2381                                const_cast <med_int*> (_ptrMesh->getPolyhedronIndex(MED_DESCENDING)),
2382                                _ptrMesh->getNumberOfPolyhedron()+1,
2383                                &FacesGeometricTypes[0],
2384                                NumberOfFaces,
2385                                const_cast <med_int*> (_ptrMesh->getPolyhedronConnectivity(MED_DESCENDING)),
2386                                med_2_2::MED_DESC);
2387
2388       if (err<0)
2389         throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write polyhedron descending connectivities of mesh |" << _meshName.c_str() << "| in file |" << _fileName
2390                                              << "| with dimension |"  << _ptrMesh->_spaceDimension <<"| and" 
2391                                              ));
2392     }
2393
2394
2395   END_OF(LOC);
2396   return MED_VALID;
2397 }
2398
2399 int MED_MESH_WRONLY_DRIVER22::writeFamilyNumbers() const {
2400   
2401   const char * LOC="int MED_MESH_WRONLY_DRIVER22::writeFamilyNumbers() const : ";
2402   BEGIN_OF(LOC);
2403
2404   med_2_2::med_err err;
2405   
2406   // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArrayNodeFamily DOIT ETRE ENLEVER DE LA CLASSE MESH
2407
2408   { // Node related block
2409     
2410     // We build the array from the families list objects :
2411     int NumberOfNodes = _ptrMesh->getNumberOfNodes() ;
2412     int * MEDArrayNodeFamily = new int[NumberOfNodes] ;
2413     // family 0 by default
2414     for (int i=0; i<NumberOfNodes; i++)
2415       MEDArrayNodeFamily[i]=0;
2416     //vector<FAMILY*> myFamilies = _ptrMesh->getFamilies(MED_NODE);
2417     vector<FAMILY*> * myFamilies = &_ptrMesh->_familyNode;
2418     int NumberOfNodesFamilies = myFamilies->size() ;
2419     //bool ToDestroy = false;
2420     if (0 == NumberOfNodesFamilies) {
2421       //ToDestroy = true ;
2422       vector<GROUP*> myGroups = _ptrMesh->getGroups(MED_NODE);
2423       int NumberOfGroups = myGroups.size() ;
2424       // build families from groups
2425       for (int i=0; i<NumberOfGroups; i++) {
2426         SUPPORT * mySupport = myGroups[i] ;
2427         FAMILY* myFamily = new FAMILY(*mySupport);
2428         myFamily->setIdentifier(i+1);
2429         myFamilies->push_back(myFamily);
2430       }
2431       NumberOfNodesFamilies=myFamilies->size() ;
2432     }
2433     for (int i=0 ; i<NumberOfNodesFamilies; i++) {
2434       //SCRUTE(i);
2435       //SCRUTE(myFamilies[i]->getName());
2436       int FamilyIdentifier = (*myFamilies)[i]->getIdentifier() ;
2437       int TotalNumber = (*myFamilies)[i]->getNumberOfElements(MED_ALL_ELEMENTS) ;
2438       if ((*myFamilies)[i]->isOnAllElements())
2439         for (int j=0; j<TotalNumber; j++)
2440           MEDArrayNodeFamily[j]=FamilyIdentifier;
2441       else {
2442         const int * Number = (*myFamilies)[i]->getNumber(MED_ALL_ELEMENTS) ;
2443         for (int j=0; j<TotalNumber; j++)
2444           MEDArrayNodeFamily[Number[j]-1]=FamilyIdentifier ;
2445       }
2446     }
2447
2448     for(int j=0; j<NumberOfNodes; j++) {
2449       SCRUTE(MEDArrayNodeFamily[j]);
2450     }
2451
2452 //     if ( !_ptrMesh->getIsAGrid() )
2453
2454       err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
2455                     MEDArrayNodeFamily, NumberOfNodes, med_2_2::MED_NOEUD,
2456                     (med_2_2::med_geometrie_element) MED_NONE);
2457
2458 //     else
2459 //       err = MEDfamGridEcr(_medIdt,
2460 //                        const_cast <char *> (_ptrMesh->_name.c_str()),
2461 //                        MEDArrayNodeFamily,
2462 //                        NumberOfNodes,
2463 //                        MED_FR::MED_LECTURE_ECRITURE,
2464 //                        MED_FR::MED_NOEUD);
2465
2466     if ( err != MED_VALID) 
2467       throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write node family for the |"<< NumberOfNodes
2468                                    << "| nodes in mesh |" 
2469                                    << _ptrMesh->_name.c_str() << "|" ));
2470     delete[] MEDArrayNodeFamily;
2471     //if (true == ToDestroy)
2472     //  for (int i=0; i<NumberOfNodesFamilies; i++)
2473     //    delete myFamilies[i];
2474   }
2475     
2476   { // CELLS RELATED BLOCK
2477     medEntityMesh entity=MED_EN::MED_CELL;
2478     // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArray____Family DOIT ETRE ENLEVER DE LA CLASSE MESH
2479     if  ( ( _ptrMesh->existConnectivity(MED_NODAL,entity) )|( _ptrMesh->existConnectivity(MED_DESCENDING,entity) ) ) { 
2480
2481       int numberOfTypes           = _ptrMesh->getNumberOfTypes (entity) ;
2482       const medGeometryElement  * types = _ptrMesh->getTypes         (entity) ;
2483
2484       // We build the array from the families list objects :
2485       int NumberOfElements = _ptrMesh->getNumberOfElements(entity, MED_ALL_ELEMENTS);
2486       int * MEDArrayFamily = new int[NumberOfElements] ;
2487       // family 0 by default
2488       for (int i=0; i<NumberOfElements; i++)
2489         MEDArrayFamily[i]=0;
2490       //vector<FAMILY*> myFamilies = _ptrMesh->getFamilies(entity);
2491       vector<FAMILY*> * myFamilies = &_ptrMesh->_familyCell ;
2492       int NumberOfFamilies = myFamilies->size() ;
2493       //bool ToDestroy = false;
2494       if (0 == NumberOfFamilies) {
2495         //ToDestroy = true ;
2496         vector<GROUP*> myGroups = _ptrMesh->getGroups(entity);
2497         int NumberOfGroups = myGroups.size() ;
2498         // build families from groups
2499         for (int i=0; i<NumberOfGroups; i++) {
2500           SCRUTE( myGroups[i]->getName() );
2501           SUPPORT * mySupport = myGroups[i] ;
2502           FAMILY* myFamily = new FAMILY(*mySupport);
2503           myFamily->setIdentifier(-i-1);
2504           myFamilies->push_back(myFamily);
2505         }
2506         NumberOfFamilies=myFamilies->size() ;
2507       }
2508       for (int i=0 ; i<NumberOfFamilies; i++) {
2509         int FamilyIdentifier = (*myFamilies)[i]->getIdentifier() ;
2510         int TotalNumber = (*myFamilies)[i]->getNumberOfElements(MED_ALL_ELEMENTS) ;
2511         if ((*myFamilies)[i]->isOnAllElements())
2512           for (int ii=0; ii<TotalNumber; ii++)
2513             MEDArrayFamily[ii]=FamilyIdentifier;
2514         else {
2515           const int * Number = (*myFamilies)[i]->getNumber(MED_ALL_ELEMENTS) ;
2516           for (int ii=0; ii<TotalNumber; ii++)
2517             MEDArrayFamily[Number[ii]-1]=FamilyIdentifier ;
2518         }
2519       }
2520
2521       const int * typeCount = _ptrMesh->getGlobalNumberingIndex(entity) ;
2522 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
2523         int lgth=NumberOfElements;
2524         med_2_2::med_int *temp=new med_2_2::med_int[lgth];
2525         for(int i2=0;i2<lgth;i2++)
2526           temp[i2]=(med_2_2::med_int) (MEDArrayFamily[i2]);
2527 #endif
2528       for (int i=0; i<numberOfTypes; i++) {
2529 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
2530         err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
2531                         temp+typeCount[i]-1,typeCount[i+1]-typeCount[i],
2532                         med_2_2::MED_REMP ,
2533                         (med_2_2::med_entite_maillage) entity,
2534                         (med_2_2::med_geometrie_element) types[i]
2535 );
2536 #else
2537         err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
2538                         (MEDArrayFamily+typeCount[i]-1),
2539                         (typeCount[i+1]-typeCount[i]),
2540                         (med_2_2::med_entite_maillage) entity,
2541                         (med_2_2::med_geometrie_element) types[i]); 
2542
2543         MESSAGE("OK "<<i);
2544         if ( err != MED_VALID) 
2545           throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write family for the |"<< _ptrMesh->getNumberOfElements(entity, types[i])
2546                                        << "| cells of geometric type |" << geoNames[types[i]] <<"|in mesh |"      
2547                                        << _ptrMesh->_name.c_str() << "|" ));   
2548       }
2549 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
2550       delete [] temp;
2551 #endif
2552       delete[] MEDArrayFamily ;
2553       //if (true == ToDestroy) {
2554       //  int NumberOfFamilies = myFamilies->size();
2555       //  for (int i=0; i<NumberOfFamilies; i++)
2556       //    delete myFamilies[i];
2557       //}
2558     }
2559   }
2560
2561   { // FACE RELATED BLOCK
2562     medEntityMesh entity=MED_EN::MED_FACE;
2563     // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArray____Family DOIT ETRE ENLEVER DE LA CLASSE MESH
2564     if  ( ( _ptrMesh->existConnectivity(MED_NODAL,entity) )|( _ptrMesh->existConnectivity(MED_DESCENDING,entity) ) ) { 
2565
2566       int numberOfTypes           = _ptrMesh->getNumberOfTypes (entity) ;
2567       const medGeometryElement  * types = _ptrMesh->getTypes         (entity) ;
2568       SCRUTE(numberOfTypes);
2569       
2570       int numberOfElements = _ptrMesh->getNumberOfElements(entity, MED_ALL_ELEMENTS) ;
2571       int * familyArray = new int[numberOfElements] ;
2572       for (int i=0;i<numberOfElements;i++)
2573         familyArray[i]=0;
2574
2575       int numberOfFamilies = _ptrMesh->getNumberOfFamilies(entity) ;
2576       //vector<FAMILY*> myFamilies = _ptrMesh->getFamilies(entity) ;
2577       vector<FAMILY*> * myFamilies = &_ptrMesh->_familyFace ;
2578       //bool ToDestroy = false;
2579       if (0 == numberOfFamilies) {
2580         //ToDestroy = true ;
2581         vector<GROUP*> myGroups = _ptrMesh->getGroups(entity);
2582         int NumberOfGroups = myGroups.size() ;
2583         // build families from groups
2584         for (int i=0; i<NumberOfGroups; i++) {
2585           SCRUTE( myGroups[i]->getName() );
2586           SUPPORT * mySupport = myGroups[i] ;
2587           FAMILY* myFamily = new FAMILY(*mySupport);
2588           myFamily->setIdentifier(-i-1000);
2589           myFamilies->push_back(myFamily);
2590         }
2591         numberOfFamilies=myFamilies->size() ;
2592       }
2593       for (int i=0;i<numberOfFamilies;i++) {
2594         int familyNumber = (*myFamilies)[i]->getIdentifier() ;
2595         int numberOfFamilyElements = (*myFamilies)[i]->getNumberOfElements(MED_ALL_ELEMENTS) ;
2596         if ((*myFamilies)[i]->isOnAllElements())
2597           for (int ii=0; ii<numberOfFamilyElements; ii++)
2598             familyArray[ii]=familyNumber;
2599         else {
2600           const int * myFamilyElements = (*myFamilies)[i]->getNumber(MED_ALL_ELEMENTS) ;
2601           for (int ii=0;ii<numberOfFamilyElements;ii++)
2602             familyArray[myFamilyElements[ii]-1]=familyNumber;
2603         }
2604       }
2605
2606       const int * typeCount = _ptrMesh->getGlobalNumberingIndex(entity) ;
2607 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
2608         int lgth=numberOfElements;
2609         med_2_2::med_int *temp=new med_2_2::med_int[lgth];
2610         for(int i2=0;i2<lgth;i2++)
2611           temp[i2]=(med_2_2::med_int) (familyArray[i2]);
2612 #endif
2613       for (int i=0; i<numberOfTypes; i++) {
2614         int typeNumberOfElements = typeCount[i+1] - typeCount[i] ;
2615
2616         err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
2617                         familyArray+typeCount[i]-1, typeNumberOfElements,
2618                         (med_2_2::med_entite_maillage) entity,
2619                         (med_2_2::med_geometrie_element) types[i]); 
2620 #endif
2621         if ( err != MED_VALID) 
2622           throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write family for the |"<< _ptrMesh->getNumberOfElements(entity, types[i])
2623                                        << "| faces of geometric type |" << geoNames[types[i]] <<"|in mesh |"      
2624                                        << _ptrMesh->_name.c_str() << "|" ));   
2625       }
2626 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
2627       delete [] temp;
2628 #endif
2629       delete[] familyArray ;
2630       //if (true == ToDestroy) {
2631       //  int NumberOfFamilies = myFamilies->size();
2632       //    for (int i=0; i<NumberOfFamilies; i++)
2633       //      delete myFamilies[i];
2634       //}
2635     }
2636   }
2637
2638   { // EDGE RELATED BLOCK
2639     //medEntityMesh entity=MED_EN::MED_FACE;
2640     medEntityMesh entity=MED_EN::MED_EDGE;
2641     // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArray____Family DOIT ETRE ENLEVER DE LA CLASSE MESH
2642     if  ( ( _ptrMesh->existConnectivity(MED_NODAL,entity) )|( _ptrMesh->existConnectivity(MED_DESCENDING,entity) ) ) { 
2643
2644       int numberOfTypes           = _ptrMesh->getNumberOfTypes (entity) ;
2645       const medGeometryElement  * types = _ptrMesh->getTypes         (entity) ;
2646       
2647       int numberOfElements = _ptrMesh->getNumberOfElements(entity, MED_ALL_ELEMENTS) ;
2648       int * familyArray = new int[numberOfElements] ;
2649       for (int i=0;i<numberOfElements;i++)
2650         familyArray[i]=0;
2651
2652       int numberOfFamilies = _ptrMesh->getNumberOfFamilies(entity) ;
2653       //vector<FAMILY*> myFamilies = _ptrMesh->getFamilies(entity) ;
2654       vector<FAMILY*> * myFamilies = &_ptrMesh->_familyEdge ;
2655       //bool ToDestroy = false;
2656       if (0 == numberOfFamilies) {
2657         //ToDestroy = true ;
2658         vector<GROUP*> myGroups = _ptrMesh->getGroups(entity);
2659         int NumberOfGroups = myGroups.size() ;
2660         // build families from groups
2661         for (int i=0; i<NumberOfGroups; i++) {
2662           SCRUTE( myGroups[i]->getName() );
2663           SUPPORT * mySupport = myGroups[i] ;
2664           FAMILY* myFamily = new FAMILY(*mySupport);
2665           myFamily->setIdentifier(-i-2000);
2666           myFamilies->push_back(myFamily);
2667         }
2668         numberOfFamilies=myFamilies->size() ;
2669       }
2670       for (int i=0;i<numberOfFamilies;i++) {
2671         int familyNumber = (*myFamilies)[i]->getIdentifier() ;
2672         int numberOfFamilyElements = (*myFamilies)[i]->getNumberOfElements(MED_ALL_ELEMENTS) ;
2673         if ((*myFamilies)[i]->isOnAllElements())
2674           for (int ii=0; ii<numberOfFamilyElements; ii++)
2675             familyArray[ii]=familyNumber;
2676         else {
2677           const int * myFamilyElements = (*myFamilies)[i]->getNumber(MED_ALL_ELEMENTS) ;
2678           for (int ii=0;ii<numberOfFamilyElements;ii++)
2679             familyArray[myFamilyElements[ii]-1]=familyNumber;
2680         }
2681       }
2682
2683       const int * typeCount = _ptrMesh->getGlobalNumberingIndex(entity) ;
2684 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
2685         int lgth=numberOfElements;
2686         med_2_2::med_int *temp=new med_2_2::med_int[lgth];
2687         for(int i2=0;i2<lgth;i2++)
2688           temp[i2]=(med_2_2::med_int) (familyArray[i2]);
2689 #endif
2690       for (int i=0; i<numberOfTypes; i++) {
2691         int typeNumberOfElements = typeCount[i+1] - typeCount[i] ;
2692
2693         err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
2694                         familyArray+typeCount[i]-1, typeNumberOfElements,
2695                         (med_2_2::med_entite_maillage) entity,
2696                         (med_2_2::med_geometrie_element) types[i]); 
2697
2698         if ( err != MED_VALID) 
2699           throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write family for the |"<< _ptrMesh->getNumberOfElements(entity, types[i])
2700                                        << "| edges of geometric type |" << geoNames[types[i]] <<"|in mesh |"      
2701                                        << _ptrMesh->_name.c_str() << "|" ));   
2702       }
2703 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
2704       delete [] temp;
2705 #endif
2706       delete[] familyArray ;
2707       //if (true == ToDestroy) {
2708       //  int NumberOfFamilies = myFamilies->size();
2709       //  for (int i=0; i<NumberOfFamilies; i++)
2710       //    delete myFamilies[i];
2711       //}
2712     }
2713   }
2714     
2715   END_OF(LOC);
2716   return MED_VALID;
2717 }
2718
2719 int MED_MESH_WRONLY_DRIVER22::writeFamilies(vector<FAMILY*> & families ) const
2720 {
2721   
2722   const char * LOC="int MED_MESH_WRONLY_DRIVER22::writeFamilies(vector<FAMILY*> families) const : ";
2723   BEGIN_OF(LOC);
2724
2725   med_2_2::med_err err;
2726   
2727   MESSAGE(LOC<<" families.size() :"<<families.size());
2728
2729   for (unsigned int i=0; i< families.size(); i++) {
2730
2731     int      numberOfAttributes         = families[i]->getNumberOfAttributes ();
2732     string   attributesDescriptions     = "";
2733
2734     // Recompose the attributes descriptions arg for MED
2735     for (int j=0; j < numberOfAttributes; j++) {
2736         
2737       string attributeDescription = families[i]->getAttributeDescription(j+1);
2738         
2739       if ( attributeDescription.size() > MED_TAILLE_DESC )
2740         throw MEDEXCEPTION( LOCALIZED(STRING(LOC) << "The size of the attribute description n° |" << j+1 << "| of the family |" << families[i]->getName()
2741                                       << "| with identifier |" << families[i]->getIdentifier()  << "| is |" 
2742                                       <<  attributeDescription.size()  <<"| and is more than |" <<  MED_TAILLE_DESC << "|")) ;
2743         
2744       attributesDescriptions += attributeDescription;
2745     }
2746       
2747
2748     int      numberOfGroups  = families[i]->getNumberOfGroups();
2749     string   groupsNames(numberOfGroups*MED_TAILLE_LNOM,'\0') ;
2750     // Recompose the groups names arg for MED
2751     for (int j=0; j < numberOfGroups; j++) {
2752
2753       string groupName = families[i]->getGroupName(j+1);
2754        
2755       if ( groupName.size() > MED_TAILLE_LNOM )
2756         throw MEDEXCEPTION( LOCALIZED(STRING(LOC) << "The size of the group name  n° |" << j+1 << "| of the family |" << families[i]->getName()
2757                                       << "| with identifier |" << families[i]->getIdentifier()  << "| is |" 
2758                                       <<  groupName.size()  <<"| and is more than |" << MED_TAILLE_LNOM << "|")) ;
2759         
2760
2761       int length = min(MED_TAILLE_LNOM,(int)groupName.size());
2762       groupsNames.replace(j*MED_TAILLE_LNOM,length, groupName,0,length);
2763       
2764     }
2765
2766     // test if the family already exists (HDF trick waiting a MED evolution to be replaced)
2767
2768     string dataGroupFam;
2769     if (families[i]->getEntity() == MED_NODE)
2770       dataGroupFam = "/ENS_MAA/"+_meshName+"/FAS/NOEUD/"+families[i]->getName()+"/";  
2771     else
2772       dataGroupFam = "/ENS_MAA/"+_meshName+"/FAS/ELEM/"+families[i]->getName()+"/"; 
2773
2774     SCRUTE("|"<<dataGroupFam<<"|");
2775     err = med_2_2::_MEDdatagroupOuvrir(_medIdt,const_cast <char *> (dataGroupFam.c_str()) ) ;
2776     if ( err < MED_VALID ) {
2777       SCRUTE(err);
2778
2779       MESSAGE(LOC<<"families[i]->getName().c_str() : "<<families[i]->getName().c_str());
2780       MESSAGE(LOC<<"_meshName.c_str() : "<<_meshName.c_str());
2781       MESSAGE(LOC<<"families[i]->getIdentifier() : "<<families[i]->getIdentifier());
2782       MESSAGE(LOC<<"numberOfAttributes : "<<numberOfAttributes);
2783         
2784       //MESSAGE(LOC<<"families[i]->getAttributesIdentifiers() : "<<families[i]->getAttributesIdentifiers()[0]);
2785       //MESSAGE(LOC<<"families[i]->getAttributesValues() : "<<families[i]->getAttributesValues()[0]);
2786       MESSAGE(LOC<<"attributesDescriptions.c_str() : "<<attributesDescriptions.c_str());
2787       MESSAGE(LOC<<"numberOfGroups : "<<numberOfGroups);
2788       MESSAGE(LOC<<"groupsNames.c_str() : "<<groupsNames.c_str());
2789 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
2790       int lgth=families[i]->getNumberOfAttributes();
2791       med_2_2::med_int *  AttributesIdentifier2 = new med_2_2::med_int[lgth] ;
2792       med_2_2::med_int *  AttributesValues2     = new med_2_2::med_int[lgth] ;
2793       for(med_2_2::med_int i2=0;i2<lgth;i2++)
2794         {
2795           AttributesIdentifier2[i2]=(med_2_2::med_int)(families[i]->getAttributesIdentifiers()[i2]);
2796           AttributesValues2[i2]=(med_2_2::med_int)(families[i]->getAttributesValues()[i2]);
2797         }
2798       err = med_2_2::MEDfamCr( _medIdt, 
2799                               const_cast <char *> ( _meshName.c_str() ),
2800                               const_cast <char *> ( families[i]->getName().c_str() ),
2801                               families[i]->getIdentifier(), 
2802                               AttributesIdentifier2,
2803                               AttributesValues2,
2804                               const_cast <char *> (attributesDescriptions.c_str()), 
2805                               numberOfAttributes,  
2806                               const_cast <char *> (groupsNames.c_str()), 
2807                               numberOfGroups);
2808       delete [] AttributesIdentifier2;
2809       delete [] AttributesValues2;
2810 #else
2811       err = med_2_2::MEDfamCr( _medIdt, 
2812                               const_cast <char *> ( _meshName.c_str() ),
2813                               const_cast <char *> ( families[i]->getName().c_str() ),
2814                               families[i]->getIdentifier(), 
2815                               families[i]->getAttributesIdentifiers(),
2816                               families[i]->getAttributesValues(),
2817                               const_cast <char *> (attributesDescriptions.c_str()), 
2818                               numberOfAttributes,  
2819                               const_cast <char *> (groupsNames.c_str()), 
2820                               numberOfGroups);
2821 #endif
2822       SCRUTE(err);
2823       if ( err != MED_VALID) 
2824         throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't create family |" << families[i]->getName()
2825                                      << "| with identifier |" << families[i]->getIdentifier()  << "| groups names |" 
2826                                      << groupsNames  <<"| and  attributes descriptions |" << attributesDescriptions << "|")) ;
2827     }
2828     else
2829       med_2_2::_MEDdatagroupFermer(_medIdt);
2830
2831
2832   }
2833
2834   END_OF(LOC);
2835     
2836   return MED_VALID;
2837 }
2838
2839
2840 // A FAIRE POUR LES NOEUDS ET LES ELEMENTS ret = MEDfamEcr(
2841
2842
2843
2844 /*--------------------- RDWR PART -------------------------------*/
2845
2846 MED_MESH_RDWR_DRIVER22::MED_MESH_RDWR_DRIVER22()
2847 {
2848 }
2849
2850 MED_MESH_RDWR_DRIVER22::MED_MESH_RDWR_DRIVER22(const string & fileName,
2851                                                MESH * ptrMesh):
2852   MED_MESH_DRIVER(fileName,ptrMesh,MED_RDWR),
2853   IMED_MESH_RDONLY_DRIVER(fileName,ptrMesh),
2854   IMED_MESH_WRONLY_DRIVER(fileName,ptrMesh),
2855   IMED_MESH_RDWR_DRIVER(fileName,ptrMesh),
2856   MED_MESH_DRIVER22(fileName,ptrMesh,MED_RDWR),
2857   MED_MESH_RDONLY_DRIVER22(fileName,ptrMesh),
2858   MED_MESH_WRONLY_DRIVER22(fileName,ptrMesh)
2859 {
2860   MESSAGE("MED_MESH_RDWR_DRIVER22::MED_MESH_RDWR_DRIVER22(const string & fileName, MESH * ptrMesh) has been created");
2861 }
2862
2863 MED_MESH_RDWR_DRIVER22::MED_MESH_RDWR_DRIVER22(const MED_MESH_RDWR_DRIVER22 & driver):
2864   MED_MESH_DRIVER(driver),
2865   IMED_MESH_RDONLY_DRIVER(driver),
2866   IMED_MESH_WRONLY_DRIVER(driver),
2867   IMED_MESH_RDWR_DRIVER(driver),
2868   MED_MESH_DRIVER22(driver),
2869   MED_MESH_RDONLY_DRIVER22(driver),
2870   MED_MESH_WRONLY_DRIVER22(driver)
2871 {
2872 }
2873
2874 MED_MESH_RDWR_DRIVER22::~MED_MESH_RDWR_DRIVER22() {
2875   //MESSAGE("MED_MESH_RDWR_DRIVER22::MED_MESH_RDWR_DRIVER22(const string & fileName, MESH * ptrMesh) has been destroyed");
2876
2877   
2878 GENDRIVER * MED_MESH_RDWR_DRIVER22::copy(void) const
2879 {
2880   return new MED_MESH_RDWR_DRIVER22(*this);
2881 }
2882
2883 void MED_MESH_RDWR_DRIVER22::write(void) const
2884 {
2885   MED_MESH_WRONLY_DRIVER22::write();
2886 }
2887 void MED_MESH_RDWR_DRIVER22::read (void)
2888 {
2889   MED_MESH_RDONLY_DRIVER22::read();
2890 }
2891