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