]> SALOME platform Git repositories - modules/med.git/blob - src/MEDMEM/MEDMEM_MedMeshDriver22.cxx
Salome HOME
updating in the main trunk (only from NB and AG) for a pre building of
[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   return MED_ERROR;
1413 }
1414
1415 int  MED_MESH_RDONLY_DRIVER22::getFAMILY() 
1416 {
1417   const char * LOC = "MED_MESH_RDONLY_DRIVER22::getFAMILY() : " ;
1418   BEGIN_OF(LOC);
1419
1420   if (_status==MED_OPENED)
1421     {
1422       int err = 0 ;
1423
1424       int * MEDArrayNodeFamily = NULL ;
1425       int ** MEDArrayCellFamily = NULL ;
1426       int ** MEDArrayFaceFamily = NULL ;
1427       int ** MEDArrayEdgeFamily = NULL ;
1428
1429     // NODE :
1430       MEDArrayNodeFamily = new int[_ptrMesh->getNumberOfNodes()] ;
1431
1432       err = getNodesFamiliesNumber(MEDArrayNodeFamily) ;
1433       // error only if (_status!=MED_OPENED), other case exeception !
1434       // CELL
1435
1436       MESSAGE(LOC << "error returned from getNodesFamiliesNumber " << err);
1437
1438       MEDArrayCellFamily = new int* [_ptrMesh->getNumberOfTypesWithPoly(MED_CELL)] ;
1439       // ET SI IL N'Y A PAS DE CELLS ?
1440
1441       medGeometryElement * myTypes = _ptrMesh->getTypesWithPoly(MED_CELL);
1442       for (int i=0;i<_ptrMesh->getNumberOfTypesWithPoly(MED_CELL);i++)
1443         MEDArrayCellFamily[i] = new
1444           int[_ptrMesh->getNumberOfElementsWithPoly(MED_CELL,myTypes[i])] ;
1445
1446       err = getCellsFamiliesNumber(MEDArrayCellFamily,
1447                                    _ptrMesh->_connectivity,MED_CELL) ;
1448       delete [] myTypes;
1449
1450       MESSAGE(LOC << "error returned from getCellsFamiliesNumber for Cells " << err);
1451
1452     if (_ptrMesh->_connectivity->_constituent != NULL)
1453       {
1454         if (_ptrMesh->_connectivity->_constituent->_entity == MED_EN::MED_FACE)
1455           {
1456             // FACE
1457             MEDArrayFaceFamily = new
1458               int* [_ptrMesh->getNumberOfTypesWithPoly(MED_FACE)] ;
1459
1460             myTypes = _ptrMesh->getTypesWithPoly(MED_FACE);
1461             for (int i=0;i<_ptrMesh->getNumberOfTypesWithPoly(MED_FACE);i++)
1462               MEDArrayFaceFamily[i] = new
1463                 int[_ptrMesh->getNumberOfElementsWithPoly(MED_FACE,myTypes[i])] ;
1464
1465             err =
1466               getCellsFamiliesNumber(MEDArrayFaceFamily,
1467                                      _ptrMesh->_connectivity->_constituent,MED_FACE) ;
1468             delete [] myTypes;
1469             MESSAGE(LOC << "error returned from getCellsFamiliesNumber for Faces " << err);
1470           }
1471         else
1472           {
1473             // EDGE in 2D
1474             MEDArrayEdgeFamily = new
1475               int* [_ptrMesh->getNumberOfTypes(MED_EDGE)] ;
1476
1477             const medGeometryElement *myTypes2 = _ptrMesh->getTypes(MED_EDGE);
1478             for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_EDGE);i++)
1479               MEDArrayEdgeFamily[i] = new
1480                 int[_ptrMesh->getNumberOfElements(MED_EDGE,myTypes2[i])] ;
1481
1482             err =
1483               getCellsFamiliesNumber(MEDArrayEdgeFamily,
1484                                      _ptrMesh->_connectivity->_constituent,MED_FACE) ;
1485           
1486             MESSAGE(LOC << "error returned from getCellsFamiliesNumber for Edges in 2D " << err);
1487           }
1488         // EDGE in 3D
1489         if (_ptrMesh->_connectivity->_constituent->_constituent != NULL)
1490           {
1491             MEDArrayEdgeFamily = new
1492               int* [_ptrMesh->getNumberOfTypes(MED_EDGE)] ;
1493
1494             const medGeometryElement *myTypes2 = _ptrMesh->getTypes(MED_EDGE);
1495             for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_EDGE);i++)
1496               MEDArrayEdgeFamily[i] = new
1497                 int[_ptrMesh->getNumberOfElements(MED_EDGE,myTypes2[i])] ;
1498
1499             err =
1500               getCellsFamiliesNumber(MEDArrayEdgeFamily,
1501                                      _ptrMesh->_connectivity->_constituent->_constituent,MED_EDGE);
1502             // we are in 3D !
1503         
1504             MESSAGE(LOC << "error returned from getCellsFamiliesNumber for Edges in 3D " << err);
1505
1506           }
1507       }
1508
1509     int NumberOfFamilies = med_2_2::MEDnFam(_medIdt, const_cast <char *>
1510                                            (_meshName.c_str())) ;
1511
1512     if ( NumberOfFamilies < 1 ) // at least family 0 must exist 
1513       throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"There is no FAMILY, FAMILY 0 must exists" ));
1514
1515     SCRUTE(NumberOfFamilies);
1516
1517     vector<FAMILY*> &NodeFamilyVector = _ptrMesh->_familyNode ;
1518     vector<FAMILY*> &CellFamilyVector = _ptrMesh->_familyCell ;
1519     vector<FAMILY*> &FaceFamilyVector = _ptrMesh->_familyFace ;
1520     vector<FAMILY*> &EdgeFamilyVector = _ptrMesh->_familyEdge ;
1521
1522     int numberOfNodesFamilies = 0 ;
1523     int numberOfCellsFamilies = 0 ;
1524     int numberOfFacesFamilies = 0 ;
1525     int numberOfEdgesFamilies = 0 ;
1526
1527     for (int i=0;i<NumberOfFamilies;i++)
1528       {
1529         int NumberOfAttributes = med_2_2::MEDnAttribut(_medIdt,
1530                                                       const_cast <char *>
1531                                                       (_meshName.c_str()),
1532                                                       (i+1));
1533       
1534       if (NumberOfAttributes < 0) 
1535         throw MEDEXCEPTION("MED_MESH_RDONLY_DRIVER22::getFAMILY() : NumberOfAttributes" );
1536
1537         int NumberOfGroups = med_2_2::MEDnGroupe(_medIdt, const_cast <char *>
1538                                                 (_meshName.c_str()),(i+1)) ;
1539
1540         if (NumberOfGroups < 0)
1541           throw MEDEXCEPTION("MED_MESH_RDONLY_DRIVER22::getFAMILY() : NumberOfGroups" );
1542       
1543         int FamilyIdentifier ;
1544         string FamilyName(MED_TAILLE_NOM,'\0');
1545         int *  AttributesIdentifier = new int[NumberOfAttributes] ;
1546         int *  AttributesValues     = new int[NumberOfAttributes] ;
1547         string AttributesDescription(MED_TAILLE_DESC*NumberOfAttributes,' ') ;
1548         string GroupsNames(MED_TAILLE_LNOM*NumberOfGroups+1,'\0') ;
1549         err = med_2_2::MEDfamInfo(_medIdt,const_cast <char *>
1550                                  (_meshName.c_str()),
1551                                  (i+1),const_cast <char *>
1552                                  (FamilyName.c_str()), &FamilyIdentifier,
1553                                  AttributesIdentifier,AttributesValues,
1554                                  const_cast <char *>
1555                                  (AttributesDescription.c_str()),
1556                                  &NumberOfAttributes, const_cast <char *>
1557                                  (GroupsNames.c_str()),&NumberOfGroups);
1558
1559
1560         SCRUTE(GroupsNames);
1561         SCRUTE(FamilyName);
1562         SCRUTE(err);
1563         SCRUTE(i);
1564
1565       if (err != MED_VALID)
1566         throw MEDEXCEPTION("MED_MESH_RDONLY_DRIVER22::getFAMILY() : ERROR when get FAMILY informations" );
1567
1568         if (FamilyIdentifier != 0 )
1569           {
1570             FAMILY * Family = new FAMILY(_ptrMesh,FamilyIdentifier,FamilyName,
1571                                          NumberOfAttributes,
1572                                          AttributesIdentifier,
1573                                          AttributesValues,
1574                                          AttributesDescription,
1575                                          NumberOfGroups,GroupsNames,
1576                                          MEDArrayNodeFamily,
1577                                          MEDArrayCellFamily,
1578                                          MEDArrayFaceFamily,
1579                                          MEDArrayEdgeFamily) ;
1580
1581             // All good ?
1582             // if nothing found, delete Family
1583
1584             if (Family->getNumberOfTypes() == 0)
1585               {
1586                 MESSAGE(LOC<<"Nothing found for family "<<FamilyName<<
1587                         " : skip");
1588                 delete Family;
1589               }
1590             else
1591               switch (Family->getEntity())
1592                 {
1593                 case MED_EN::MED_NODE :
1594                   NodeFamilyVector.push_back(Family) ;
1595                   numberOfNodesFamilies++ ;
1596                   break ;
1597                 case MED_EN::MED_CELL :
1598                   CellFamilyVector.push_back(Family) ;
1599                   numberOfCellsFamilies++ ;
1600                   break ;
1601                 case MED_EN::MED_FACE :
1602                   FaceFamilyVector.push_back(Family) ;
1603                   numberOfFacesFamilies++ ;
1604                   break ;
1605                 case MED_EN::MED_EDGE :
1606                   EdgeFamilyVector.push_back(Family) ;
1607                   numberOfEdgesFamilies++ ;
1608                   break ;
1609                 }
1610             //  MESSAGE(LOC << (*Family));
1611           }
1612
1613         delete [] AttributesIdentifier ;
1614         delete [] AttributesValues ;
1615       }
1616
1617     if (MEDArrayNodeFamily != NULL)
1618       delete[] MEDArrayNodeFamily ;
1619
1620     if (MEDArrayCellFamily != NULL)
1621       {
1622         for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_CELL);i++)
1623           delete[] MEDArrayCellFamily[i] ;
1624         delete[] MEDArrayCellFamily ;
1625       }
1626
1627     if (MEDArrayFaceFamily != NULL)
1628       {
1629         for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_FACE);i++)
1630           delete[] MEDArrayFaceFamily[i] ;
1631         delete[] MEDArrayFaceFamily ;
1632       }
1633
1634     if (MEDArrayEdgeFamily != NULL)
1635       {
1636         for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_EDGE);i++)
1637           delete[] MEDArrayEdgeFamily[i] ;
1638         delete[] MEDArrayEdgeFamily ;
1639       }
1640
1641     END_OF(LOC);
1642     return MED_VALID ;
1643     }
1644
1645   return MED_ERROR;
1646 }
1647
1648 int  MED_MESH_RDONLY_DRIVER22::getNodesFamiliesNumber(int * MEDArrayNodeFamily)
1649 {
1650   const char * LOC = "MED_MESH_RDONLY_DRIVER22::getNodesFamiliesNumber() : " ;
1651
1652   BEGIN_OF(LOC);
1653
1654   if (_status==MED_OPENED)
1655     {
1656     int err = 0 ;
1657
1658       err = MEDfamLire(_medIdt, const_cast <char *>
1659                        (_ptrMesh->_name.c_str()), MEDArrayNodeFamily,
1660                        _ptrMesh->getNumberOfNodes(), med_2_2::MED_NOEUD,
1661                        (med_2_2::med_geometrie_element) MED_NONE);
1662
1663       if ( err != MED_VALID)
1664         throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "There is no family for the |"<< _ptrMesh->getNumberOfNodes() << "| nodes in mesh |" << _ptrMesh->_name.c_str() << "|"));
1665
1666       END_OF(LOC);
1667       return MED_VALID;
1668     }
1669
1670   return MED_ERROR;
1671 }
1672
1673 int  MED_MESH_RDONLY_DRIVER22::getCellsFamiliesNumber(int **MEDArrayFamily,
1674                                                       CONNECTIVITY *Connectivity,
1675                                                       MED_EN::medEntityMesh entity) 
1676 {
1677   const char * LOC = "MED_MESH_RDONLY_DRIVER22::getCellsFamiliesNumber " ;
1678
1679   BEGIN_OF(LOC);
1680
1681   if (_status==MED_OPENED)
1682     {
1683     int i, err = 0 ;
1684     MED_EN::medGeometryElement *types=Connectivity->getGeometricTypesWithPoly(Connectivity->_entity);
1685     for (i=0;i<Connectivity->getNumberOfTypesWithPoly(Connectivity->_entity);i++)
1686       {
1687         int NumberOfCell=Connectivity->getNumberOfElementsWithPoly(Connectivity->_entity,types[i]);
1688         err=MEDfamLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
1689                        MEDArrayFamily[i],NumberOfCell,
1690                        (med_2_2::med_entite_maillage) Connectivity->_entity,
1691                        (med_2_2::med_geometrie_element)types[i]);
1692         if (err != MED_VALID)
1693           {
1694             err=MEDfamLire(_medIdt,const_cast <char *>
1695                            (_ptrMesh->_name.c_str()),
1696                            MEDArrayFamily[i],NumberOfCell,
1697                            med_2_2::MED_MAILLE,
1698                            (med_2_2::med_geometrie_element)types[i]);
1699             if (err != MED_VALID)
1700               throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Family not found for entity "<<Connectivity->_entity<<" and geometric type "<<Connectivity->_geometricTypes[i]));
1701           }
1702       }
1703     delete [] types;
1704     return MED_VALID;
1705     }
1706   return MED_ERROR;
1707 }
1708
1709 /*--------------------- WRONLY PART -------------------------------*/
1710
1711 MED_MESH_WRONLY_DRIVER22::MED_MESH_WRONLY_DRIVER22()
1712 {
1713 }
1714   
1715 MED_MESH_WRONLY_DRIVER22::MED_MESH_WRONLY_DRIVER22(const string & fileName,
1716                                                    MESH * ptrMesh):
1717   MED_MESH_DRIVER22(fileName,ptrMesh,MED_WRONLY),IMED_MESH_WRONLY_DRIVER(fileName,ptrMesh),MED_MESH_DRIVER(fileName,ptrMesh,MED_WRONLY)
1718 {
1719   MESSAGE("MED_MESH_WRONLY_DRIVER22::MED_MESH_WRONLY_DRIVER22(const string & fileName, MESH * ptrMesh) has been created");
1720 }
1721
1722 MED_MESH_WRONLY_DRIVER22::MED_MESH_WRONLY_DRIVER22(const MED_MESH_WRONLY_DRIVER22 & driver):
1723   IMED_MESH_WRONLY_DRIVER(driver),MED_MESH_DRIVER22(driver),MED_MESH_DRIVER(driver)
1724 {
1725 }
1726
1727 MED_MESH_WRONLY_DRIVER22::~MED_MESH_WRONLY_DRIVER22()
1728 {
1729   //MESSAGE("MED_MESH_WRONLY_DRIVER22::MED_MESH_WRONLY_DRIVER22(const string & fileName, MESH * ptrMesh) has been destroyed");
1730 }
1731
1732 GENDRIVER * MED_MESH_WRONLY_DRIVER22::copy(void) const
1733 {
1734   return new MED_MESH_WRONLY_DRIVER22(*this);
1735 }
1736
1737 void MED_MESH_WRONLY_DRIVER22::write(void) const
1738
1739   const char * LOC = "void MED_MESH_WRONLY_DRIVER22::write(void) const : ";
1740   BEGIN_OF(LOC);
1741
1742   // we must first create mesh !!
1743   MESSAGE(LOC << "MeshName : |" << _meshName << "| FileName : |"<<_fileName<<"| MedIdt : | "<< _medIdt << "|");
1744
1745   if (_status!=MED_OPENED)
1746     throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "File "<<_fileName<<" is not open. Open it before write !"));
1747
1748   if (_ptrMesh->getIsAGrid())
1749   {
1750     if ( writeGRID() != MED_VALID )
1751       throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeGRID()"  )) ;
1752   }
1753   else
1754   {
1755     if (writeCoordinates()!=MED_VALID)
1756       throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeCoordinates()"  )) ;
1757
1758     if (writeConnectivities(MED_EN::MED_CELL)!=MED_VALID)
1759       throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeConnectivities(MED_CELL)"  )) ;
1760     if (writeConnectivities(MED_EN::MED_FACE)!=MED_VALID)
1761       throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeConnectivities(MED_FACE)"  )) ;
1762     if (writeConnectivities(MED_EN::MED_EDGE)!=MED_VALID)
1763       throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeConnectivities(MED_EDGE)"  )) ;
1764   }
1765
1766   if (writeFamilyNumbers() !=MED_VALID)
1767     throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilyNumbers()"  )) ;
1768   
1769
1770   // well we must first write zero family :
1771   if (_status==MED_OPENED) {
1772     int err ;
1773     // test if the family already exists (HDF trick waiting a MED evolution to be replaced)
1774     string dataGroupFam = "/ENS_MAA/"+_meshName+"/FAS/FAMILLE_ZERO/";  
1775     MESSAGE("|"<<dataGroupFam<<"|");
1776     err =med_2_2::_MEDdatagroupOuvrir(_medIdt,const_cast <char *> (dataGroupFam.c_str()) );
1777     if ( err < MED_VALID ) {
1778       SCRUTE(err);
1779
1780       char familyName[MED_TAILLE_NOM+1];
1781       //      strcpy(familyName,"FAMILLE_ZERO");
1782       err = med_2_2::MEDfamCr( _medIdt,
1783                               const_cast <char *> ( _meshName.c_str() ),
1784                               familyName, 0,
1785                               (int*)NULL, (int*)NULL, (char*)NULL, 0,
1786                               (char*)NULL, 0);
1787
1788       SCRUTE(familyName);
1789       
1790       if ( err != MED_VALID) 
1791         throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't create family |FAMILLE_ZERO| with identifier |0| groups names || and  attributes descriptions ||")) ;
1792     }
1793     else
1794       med_2_2::_MEDdatagroupFermer(_medIdt);
1795      
1796   }
1797
1798   MESSAGE(LOC<<"writeFamilies(_ptrMesh->_familyNode)");
1799   if (writeFamilies(_ptrMesh->_familyNode) !=MED_VALID)
1800     throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilies(_ptrMesh->_familyNode)"  )) ;
1801
1802   MESSAGE(LOC<<"writeFamilies(_ptrMesh->_familyCell)");
1803   if (writeFamilies(_ptrMesh->_familyCell) !=MED_VALID)
1804     throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilies(_ptrMesh->_familyCell)"  )) ;
1805
1806   MESSAGE(LOC<<"writeFamilies(_ptrMesh->_familyFace)");
1807   if (writeFamilies(_ptrMesh->_familyFace) !=MED_VALID)
1808     throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilies(_ptrMesh->_familyFace)"  )) ;
1809
1810   MESSAGE(LOC<<"writeFamilies(_ptrMesh->_familyEdge)");
1811   if (writeFamilies(_ptrMesh->_familyEdge) !=MED_VALID)
1812     throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilies(_ptrMesh->_familyEdge)"  )) ;
1813
1814   END_OF(LOC);
1815
1816
1817 //=======================================================================
1818 //function : writeGRID
1819 //purpose  : 
1820 //=======================================================================
1821
1822 int MED_MESH_WRONLY_DRIVER22::writeGRID() const
1823 {
1824   const char * LOC = "MED_MESH_WRONLY_DRIVER22::writeGRID() : " ;
1825   BEGIN_OF(LOC);
1826   
1827   if (_status!=MED_OPENED)
1828   {
1829     MESSAGE (LOC<<" Not open !!!");
1830     return MED_ERROR;
1831   }
1832   GRID * ptrGrid = (GRID*) _ptrMesh;
1833   
1834   med_2_2::med_err err = MED_ERROR;
1835   med_2_2::med_repere rep;
1836   string tmp_name(_ptrMesh->_spaceDimension*MED_TAILLE_PNOM22,' ');
1837   string tmp_unit(_ptrMesh->_spaceDimension*MED_TAILLE_PNOM22,' ');
1838
1839   // Test if the mesh <_meshName> already exists
1840   // If it doesn't exists create it
1841   // If it already exists verify if its space and mesh dimensions are the same
1842   // as <_ptrMesh->_spaceDimension>, <_ptrMesh->_meshDimension> respectively
1843   // rem : <_meshName> is the driver meshName not <ptrMesh->_meshName>
1844
1845   int spaceDimension = med_2_2::MEDdimEspaceLire(_medIdt, const_cast <char *>
1846                                                 (_meshName.c_str()) );
1847
1848   int meshDimension = med_2_2::MEDdimLire(_medIdt, const_cast <char *>
1849                                          (_meshName.c_str()) );
1850
1851
1852   MESSAGE(LOC << "spacedim " << spaceDimension << " meshdim " << meshDimension);
1853
1854   MESSAGE(LOC << "From the mesh spacedim " << _ptrMesh->_spaceDimension << " meshdim " << _ptrMesh->_meshDimension);
1855
1856   if ((spaceDimension <= MED_VALID) && (meshDimension <= MED_VALID))
1857     {
1858       err = MEDmaaCr(_medIdt,
1859                      const_cast <char *> (_meshName.c_str()),
1860                      _ptrMesh->_meshDimension,med_2_2::MED_STRUCTURE,
1861                      const_cast <char *> (_ptrMesh->_description.c_str()));
1862
1863       meshDimension =  _ptrMesh->_meshDimension;
1864
1865       if (err != MED_VALID)
1866         throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Unable to create Grid"));
1867       else 
1868         MESSAGE(LOC<<"Grid "<<_meshName<<" created in file "<<_fileName<<" !");
1869     }
1870   else if ((spaceDimension != _ptrMesh->_spaceDimension)  &&
1871            (meshDimension != _ptrMesh->_meshDimension))
1872     throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Grid |" << _meshName.c_str() <<
1873                                  "| already exists in file |" << _fileName <<
1874                                  "| with space dimension |" << spaceDimension <<
1875                                  "| and mesh dimension |" << meshDimension <<
1876                                  "| but the space dimension and the mesh dimension of the mesh we want to write are respectively |"
1877                                  << _ptrMesh->_spaceDimension <<"|" <<
1878                                  _ptrMesh->_meshDimension <<"|" )) ;
1879
1880   MED_EN::med_grid_type gridType = ptrGrid->getGridType();
1881
1882   err = med_2_2::MEDnatureGrilleEcr(_medIdt,
1883                                    const_cast <char *> (_meshName.c_str()),
1884                                    (med_2_2::med_type_grille) gridType);
1885
1886   if (err != MED_VALID)
1887     throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Unable to write the type of the Grid"));
1888
1889   // Recompose the <_spaceDimension> strings in 1 string 
1890   int lengthString ;
1891   string valueString ;
1892   for (int i=0;i<_ptrMesh->_spaceDimension;i++) {
1893     SCRUTE(i);
1894     valueString = _ptrMesh->_coordinate->_coordinateName[i] ;
1895     lengthString = (MED_TAILLE_PNOM22<valueString.size())?MED_TAILLE_PNOM22:valueString.size() ;
1896     tmp_name.replace(i*MED_TAILLE_PNOM22,i*MED_TAILLE_PNOM22+lengthString,valueString,0,lengthString);
1897     valueString = _ptrMesh->_coordinate->_coordinateUnit[i];
1898     lengthString = (MED_TAILLE_PNOM22<valueString.size())?MED_TAILLE_PNOM22:valueString.size() ;
1899     tmp_unit.replace(i*MED_TAILLE_PNOM22,i*MED_TAILLE_PNOM22+lengthString,valueString,0,lengthString);
1900   }
1901
1902   // Pourquoi le stocker sous forme de chaîne ?
1903   const string & coordinateSystem = _ptrMesh->_coordinate->_coordinateSystem;
1904   if      (coordinateSystem  == "CARTESIAN") 
1905     rep = med_2_2::MED_CART;
1906   else if ( coordinateSystem == "CYLINDRICAL")
1907     rep = med_2_2::MED_CYL;
1908   else if ( coordinateSystem == "SPHERICAL" )
1909     rep = med_2_2::MED_SPHER;
1910   else
1911     throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Grid |" << _meshName.c_str() <<
1912                                  "| doesn't have a valid coordinate system : |" 
1913                                  << _ptrMesh->_coordinate->_coordinateSystem
1914                                  << "|" )) ;  
1915
1916   med_2_2::med_int ArrayLen[] = { (med_2_2::med_int) ptrGrid->_iArrayLength,
1917                      (med_2_2::med_int) ptrGrid->_jArrayLength,
1918                      (med_2_2::med_int) ptrGrid->_kArrayLength  };
1919   
1920   // Write node coordinates for MED_BODY_FITTED grid
1921   if (gridType == MED_EN::MED_BODY_FITTED)
1922     {
1923       // Write Coordinates and families
1924 //       double * coo = const_cast <double *>
1925 //      (_ptrMesh->_coordinate->getCoordinates(MED_EN::MED_FULL_INTERLACE));
1926
1927       err = MEDcoordEcr(_medIdt, const_cast <char *> (_meshName.c_str()),
1928                         _ptrMesh->_spaceDimension, 
1929                         //const_cast <double *> ( _ptrMesh->_coordinate->_coordinate->get(MED_EN::MED_FULL_INTERLACE) ), 
1930                         const_cast <double *> ( _ptrMesh->_coordinate->_coordinate.get(MED_EN::MED_FULL_INTERLACE) ), 
1931                         med_2_2::MED_FULL_INTERLACE, _ptrMesh->_numberOfNodes,
1932                         //  _ptrMesh->_coordinate->_numberOfNodes
1933                         rep, const_cast <char *> (tmp_name.c_str()), 
1934                         const_cast <char *> (tmp_unit.c_str()));
1935
1936       if (err != MED_VALID) 
1937         throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write coordinates of the grid |" << _meshName.c_str() << "| in file |" << _fileName
1938                                      << "| with dimension |"  << _ptrMesh->_spaceDimension <<"| and" 
1939                                      << " with units names |"  << tmp_name
1940                                      << "| and units |"       << tmp_unit
1941                                      << " |")) ;
1942
1943       int* structure = new int [meshDimension];
1944
1945       for (int idim = 0; idim < meshDimension; ++idim)
1946         structure[idim] = ArrayLen [idim];
1947  
1948
1949       err = med_2_2::MEDstructureCoordEcr(_medIdt, const_cast <char *>
1950                                          (_meshName.c_str()), meshDimension,
1951                                          structure);
1952
1953       if (err != MED_VALID)
1954         throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"error in writing the structure of the grid |" << _meshName.c_str()));
1955
1956       delete structure;
1957     }
1958   else if ((gridType == MED_EN::MED_CARTESIAN) ||
1959            (gridType == MED_EN::MED_POLAR))
1960     {
1961       // Write Arrays of Cartesian or Polar Grid
1962
1963       double * Array[] = { ptrGrid->_iArray,
1964                            ptrGrid->_jArray,
1965                            ptrGrid->_kArray };
1966
1967       for (int idim = 0; idim < _ptrMesh->_meshDimension; ++idim)
1968         {
1969           string str_name = string (tmp_name,idim*MED_TAILLE_PNOM22,
1970                                     MED_TAILLE_PNOM22);
1971           string str_unit = string (tmp_unit,idim*MED_TAILLE_PNOM22,
1972                                     MED_TAILLE_PNOM22);
1973
1974           err = med_2_2::MEDindicesCoordEcr(_medIdt, const_cast <char *>
1975                                            (_ptrMesh->_name.c_str()),
1976                                            _ptrMesh->_meshDimension,
1977                                            Array[idim], ArrayLen[idim],
1978                                            (idim+1), const_cast <char *>
1979                                            (str_name.c_str()),
1980                                            const_cast <char *>
1981                                            (str_unit.c_str()));
1982
1983           if (err != MED_VALID)
1984             throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<
1985                                          "Can't write grid coordinates for " <<
1986                                          idim << "-th dimention"));
1987         }
1988   } // end Write  Cartesian or Polar Grid
1989
1990   END_OF(LOC);
1991   return MED_VALID;
1992 }
1993
1994 //=======================================================================
1995 //function : writeCoordinates
1996 //purpose  : 
1997 //=======================================================================
1998
1999 int MED_MESH_WRONLY_DRIVER22::writeCoordinates() const {
2000  
2001   const char * LOC = "int MED_MESH_WRONLY_DRIVER22::writeCoordinates() const : ";
2002   BEGIN_OF(LOC);
2003
2004   med_2_2::med_err err = MED_ERROR;
2005   med_2_2::med_repere rep;
2006   string tmp_name(_ptrMesh->_spaceDimension*MED_TAILLE_PNOM22,' ');
2007   string tmp_unit(_ptrMesh->_spaceDimension*MED_TAILLE_PNOM22,' ');
2008     
2009   // Recompose the <_spaceDimension> strings in 1 string 
2010   int lengthString ;
2011   string valueString ;
2012   for (int i=0;i<_ptrMesh->_spaceDimension;i++) {
2013     valueString = _ptrMesh->_coordinate->_coordinateName[i] ;
2014     lengthString = (MED_TAILLE_PNOM22<valueString.size())?MED_TAILLE_PNOM22:valueString.size() ;
2015     tmp_name.replace(i*MED_TAILLE_PNOM22,i*MED_TAILLE_PNOM22+lengthString,valueString,0,lengthString);
2016     valueString = _ptrMesh->_coordinate->_coordinateUnit[i];
2017     lengthString = (MED_TAILLE_PNOM22<valueString.size())?MED_TAILLE_PNOM22:valueString.size() ;
2018     tmp_unit.replace(i*MED_TAILLE_PNOM22,i*MED_TAILLE_PNOM22+lengthString,valueString,0,lengthString);
2019   }
2020
2021   // Test if the mesh <_meshName> already exists
2022   // If it doesn't exists create it
2023   // If it already exists verify if its space and mesh dimensions are the same
2024   // as <_ptrMesh->_spaceDimension>, <_ptrMesh->_meshDimension> respectively
2025   // rem : <_meshName> is the driver meshName not <ptrMesh->_meshName>
2026
2027   int spaceDimension = med_2_2::MEDdimEspaceLire(_medIdt, const_cast <char *>
2028                                                 (_meshName.c_str()));
2029
2030   int meshDimension = med_2_2::MEDdimLire(_medIdt, const_cast <char *>
2031                                          (_meshName.c_str()) );
2032
2033   if ((spaceDimension != MED_VALID) && (meshDimension != MED_VALID))
2034     {
2035       err = MEDmaaCr(_medIdt, const_cast <char *> (_meshName.c_str()),
2036                      _ptrMesh->_meshDimension, med_2_2::MED_NON_STRUCTURE,
2037                      const_cast <char *> (_ptrMesh->_description.c_str()));
2038
2039       if (err != MED_VALID)
2040         throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Unable to create Mesh : |" << _meshName << "|"));
2041       else 
2042         MESSAGE(LOC<<"Mesh "<<_meshName<<" created in file "<<_fileName<<" !");
2043     }
2044   else if ((spaceDimension != _ptrMesh->_spaceDimension)  &&
2045            (meshDimension != _ptrMesh->_meshDimension))
2046     throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Mesh |" << _meshName.c_str() <<
2047                                  "| already exists in file |" << _fileName <<
2048                                  "| with space dimension |" << spaceDimension <<
2049                                  "| and mesh dimension |" << meshDimension <<
2050                                  "| but the space dimension and the mesh dimension of the mesh we want to write are respectively |"
2051                                  << _ptrMesh->_spaceDimension <<"|" <<
2052                                  _ptrMesh->_meshDimension << "|")) ;
2053     
2054   // Pourquoi le stocker sous forme de chaîne ?
2055   const string & coordinateSystem = _ptrMesh->_coordinate->_coordinateSystem;
2056   if      (coordinateSystem  == "CARTESIAN") 
2057     rep = med_2_2::MED_CART;
2058   else if ( coordinateSystem == "CYLINDRICAL")
2059     rep = med_2_2::MED_CYL;
2060   else if ( coordinateSystem == "SPHERICAL" )
2061     rep = med_2_2::MED_SPHER;
2062   else
2063     throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Mesh |" << _meshName.c_str() << "| doesn't have a valid coordinate system : |" 
2064                                  << _ptrMesh->_coordinate->_coordinateSystem
2065                                  << "|" )) ;  
2066       
2067 //   err = MEDcoordEcr(_medIdt, const_cast <char *> (_meshName.c_str()),
2068 //                  _ptrMesh->_spaceDimension, 
2069 //                  //const_cast <double *> ( _ptrMesh->_coordinate->_coordinate->get(MED_EN::MED_FULL_INTERLACE) ), 
2070 //                  const_cast <double *> ( _ptrMesh->_coordinate->_coordinate.get(MED_EN::MED_FULL_INTERLACE) ), 
2071 //                  MED_FR::MED_FULL_INTERLACE, 
2072 //                  _ptrMesh->_numberOfNodes,                 //  _ptrMesh->_coordinate->_numberOfNodes
2073 //                  MED_FR::MED_LECTURE_ECRITURE,    
2074 //                  rep,
2075 //                  const_cast <char *> (tmp_name.c_str()), 
2076 //                  const_cast <char *> (tmp_unit.c_str()) 
2077 //                  );
2078
2079   err = MEDcoordEcr(_medIdt, const_cast <char *> (_meshName.c_str()),
2080                     _ptrMesh->_spaceDimension, 
2081                     //const_cast <double *> ( _ptrMesh->_coordinate->_coordinate->get(MED_EN::MED_FULL_INTERLACE) ), 
2082                     const_cast <double *> ( _ptrMesh->_coordinate->_coordinate.get(MED_EN::MED_FULL_INTERLACE) ), 
2083                     med_2_2::MED_FULL_INTERLACE, _ptrMesh->_numberOfNodes,
2084                     //  _ptrMesh->_coordinate->_numberOfNodes
2085                     rep, const_cast <char *> (tmp_name.c_str()), 
2086                     const_cast <char *> (tmp_unit.c_str()));
2087
2088   if (err<0) 
2089     throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write coordinates of mesh |" << _meshName.c_str() << "| in file |" << _fileName
2090                                  << "| with dimension |"  << _ptrMesh->_spaceDimension <<"| and" 
2091                                  << " with units names |"  << tmp_name
2092                                  << "| and units |"       << tmp_unit
2093                                  << " |")) ;    
2094     
2095
2096        //////////////////////////////////////////////////////////////////////////////////////
2097        ///  Modification pour prise en compte de la numérotation optionnelle des noeuds   ///
2098        //////////////////////////////////////////////////////////////////////////////////////
2099        ///
2100        /// Ecrit les numéros optionnels des noeuds
2101        /// Le traitement est identique à la version originelle s'il n'y a pas de numérotation optionnelle
2102
2103
2104       if (_ptrMesh->_arePresentOptionnalNodesNumbers==1) {
2105         
2106         err =  MEDnumEcr(_medIdt, const_cast <char *> (_meshName.c_str()),
2107                          const_cast <med_int *> (_ptrMesh->_coordinate->getNodesNumbers() ), 
2108                          _ptrMesh->_numberOfNodes, med_2_2::MED_NOEUD,
2109                          med_2_2::med_geometrie_element(0) );
2110
2111         if (err != MED_VALID) 
2112           throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write optionnal numbers of mesh |" << 
2113                                        _meshName.c_str() << "| in file |" <<
2114                                        _fileName  << " |")) ;
2115       }
2116       //////////////////////////////////////////////////////////////////////////////////////
2117
2118   END_OF(LOC);
2119     
2120   return MED_VALID;
2121 }
2122
2123
2124
2125
2126 int MED_MESH_WRONLY_DRIVER22::writeConnectivities(medEntityMesh entity) const 
2127 {
2128   const char * LOC="int MED_MESH_WRONLY_DRIVER22::writeConnectivities() const : ";
2129   BEGIN_OF(LOC);
2130
2131   med_2_2::med_err err;
2132   
2133   // REM SI LA METHODE EST APPELEE DIRECTEMENT ET QUE LE MAILLAGE N'EST PAS CREE IL Y A PB !
2134   // PG : IMPOSSIBLE : LA METHODE EST PRIVEE !
2135     
2136   // A FAIRE : A tester surtout dans les methodes de MESH.
2137   //    if ( _ptrMesh->_connectivity == (CONNECTIVITY *) MED_INVALID )
2138   if ( _ptrMesh->_connectivity == (CONNECTIVITY *) NULL )
2139     throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The connectivity is not defined in the MESH object ")) ;
2140
2141
2142   // Nodal connectivity for classic geometric types
2143   if   ( _ptrMesh->existConnectivity(MED_NODAL,entity) ) 
2144     {
2145
2146       int numberOfTypes           = _ptrMesh->getNumberOfTypes (entity) ;
2147       const medGeometryElement  * types = _ptrMesh->getTypes         (entity) ;
2148
2149       for (int i=0; i<numberOfTypes; i++) 
2150         {
2151
2152           int    numberOfElements = _ptrMesh->getNumberOfElements (entity,types[i]);
2153           const int * connectivity      = _ptrMesh->getConnectivity     (MED_EN::MED_FULL_INTERLACE, 
2154                                                                          MED_NODAL, entity, types[i]); // ?? et SI MED_NODAL n'existe pas, recalcul auto ??
2155       
2156           // Pour l'instant la class utilise le multi.....
2157           int multi = 0 ;
2158           //      if (entity==MED_EN::MED_CELL)
2159           //        if ( (types[i]/ 100) < _ptrMesh->_spaceDimension) 
2160           //          multi=1 ;
2161           int numberOfNodes = types[i]%100 ;
2162           int * connectivityArray = new int[numberOfElements*(numberOfNodes+multi)];
2163       
2164           // version originale sans prise en compte des numéros optionnels 
2165           //     
2166           for (int j=0 ; j<numberOfElements; j++) 
2167             {
2168               for (int k=0; k<numberOfNodes; k++)
2169                 connectivityArray[j*(numberOfNodes+multi)+k]=connectivity[j*numberOfNodes+k] ;
2170
2171               if (multi>0) connectivityArray[j*(numberOfNodes+multi)+numberOfNodes]=0;
2172             }
2173       
2174           //////////////////////////////////////////////////////////////////////////////////////
2175           ///  Modification pour prise en compte de la numérotation optionnelle des noeuds   ///
2176               //////////////////////////////////////////////////////////////////////////////////////
2177               ///
2178               /// Dénumérote les sommets des mailles pour leur rendre leurs numéros optionnels
2179               /// Le traitement est identique à la version originelle s'il n'y a pas de numérotation optionnelle
2180
2181               //        if (_ptrMesh->_arePresentOptionnalNodesNumbers==1) 
2182               //                {
2183               //                const int * nodesNumbers = _ptrMesh->_coordinate->getNodesNumbers();
2184               //                for (int j=0 ; j<numberOfElements; j++) 
2185               //                        {
2186               //                        for (int k=0; k<numberOfNodes; k++) connectivityArray[j*(numberOfNodes+multi)+k]=nodesNumbers[connectivity[j*numberOfNodes+k]-1] ;
2187               //                        if (multi>0) connectivityArray[j*(numberOfNodes+multi)+numberOfNodes]=0;
2188               //                        }
2189               //                }
2190               //        else
2191               //                {
2192               //                for (int j=0 ; j<numberOfElements; j++) 
2193               //                        {
2194               //                        for (int k=0; k<numberOfNodes; k++) connectivityArray[j*(numberOfNodes+multi)+k]=connectivity[j*numberOfNodes+k] ;
2195               //                        if (multi>0) connectivityArray[j*(numberOfNodes+multi)+numberOfNodes]=0;
2196               //                        }
2197               //                }
2198
2199               //////////////////////////////////////////////////////////////////////////////////////
2200       
2201               //       err = MEDconnEcr( _medIdt, const_cast <char *> ( _meshName.c_str()), _ptrMesh->_spaceDimension,
2202               //                        connectivityArray, MED_FR::MED_FULL_INTERLACE , numberOfElements,
2203               //                        MED_FR::MED_LECTURE_ECRITURE,
2204               //                        (MED_FR::med_entite_maillage  ) entity, 
2205               //                        (MED_FR::med_geometrie_element) types[i], MED_FR::MED_NOD );
2206
2207               //          err = MEDconnEcr(_medIdt, const_cast <char *> ( _meshName.c_str()),
2208               //                           _ptrMesh->_spaceDimension, connectivityArray,
2209               //                           MED_FR::MED_FULL_INTERLACE , numberOfElements,
2210               //                           (MED_FR::med_entite_maillage  ) entity, 
2211               //                           (MED_FR::med_geometrie_element) types[i],
2212               //                           med_2_2::MED_NOD);
2213               
2214               err = MEDconnEcr(_medIdt, const_cast <char *> ( _meshName.c_str()),
2215                                _ptrMesh->_spaceDimension, connectivityArray,
2216                                med_2_2::MED_FULL_INTERLACE , numberOfElements,
2217                                (med_2_2::med_entite_maillage  ) MED_CELL, 
2218                                (med_2_2::med_geometrie_element) types[i],
2219                                med_2_2::MED_NOD);
2220
2221               delete[] connectivityArray ;
2222
2223               if (err<0) // ETENDRE LES EXPLICATIONS
2224                 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write connectivities of mesh |" << _meshName.c_str() << "| in file |" << _fileName
2225                                              << "| with dimension |"  << _ptrMesh->_spaceDimension <<"| and" 
2226                                              ));
2227         }
2228
2229     }
2230
2231
2232   // Polygons writing
2233   if (_ptrMesh->existPolygonsConnectivity(MED_NODAL,entity))
2234     {
2235       err = MEDpolygoneConnEcr(_medIdt,
2236                                const_cast <char *> (_meshName.c_str()),
2237                                const_cast <med_int*> (_ptrMesh->getPolygonsConnectivityIndex(MED_NODAL,entity)),
2238                                _ptrMesh->getNumberOfPolygons()+1,
2239                                const_cast <med_int*> (_ptrMesh->getPolygonsConnectivity(MED_NODAL,entity)),
2240                                (med_2_2::med_entite_maillage) entity,
2241                                med_2_2::MED_NOD);
2242
2243       if (err<0)
2244         throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write polygons nodal connectivities of mesh |" <<  _meshName.c_str() << "| in file |" << _fileName
2245                                              << "| with dimension |"  << _ptrMesh->_spaceDimension <<"| and" 
2246                                              ));
2247     }
2248
2249
2250   // Polyhedron writing
2251   if (_ptrMesh->existPolyhedronConnectivity(MED_NODAL,entity))
2252     {
2253       err = MEDpolyedreConnEcr(_medIdt,
2254                                const_cast <char *> (_meshName.c_str()),
2255                                const_cast <med_int*> (_ptrMesh->getPolyhedronIndex(MED_NODAL)),
2256                                _ptrMesh->getNumberOfPolyhedron()+1,
2257                                const_cast <med_int*> (_ptrMesh->getPolyhedronFacesIndex()),
2258                                _ptrMesh->getNumberOfPolyhedronFaces()+1,
2259                                const_cast <med_int*> (_ptrMesh->getPolyhedronConnectivity(MED_NODAL)),
2260                                med_2_2::MED_NOD);
2261
2262       if (err<0)
2263         throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write polyhedron nodal connectivities of mesh |" << _meshName.c_str() << "| in file |" << _fileName
2264                                      << "| with dimension |"  << _ptrMesh->_spaceDimension <<"| and" 
2265                                              ));
2266     }
2267
2268
2269   // Descending connectivity for classic geometric types
2270   if   ( _ptrMesh->existConnectivity(MED_DESCENDING,entity) )
2271     {
2272       
2273       int numberOfTypes           = _ptrMesh->getNumberOfTypes (entity) ;
2274       const medGeometryElement  * types = _ptrMesh->getTypes         (entity) ;
2275       
2276       for (int i=0; i<numberOfTypes; i++)
2277         {
2278         
2279           int    numberOfElements = _ptrMesh->getNumberOfElements (entity,types[i]);
2280           const int * connectivity = _ptrMesh->getConnectivity(MED_EN::MED_FULL_INTERLACE, MED_DESCENDING, entity, types[i]); 
2281       
2282       // Pour l'instant la class utilise le multi.....
2283           //       err = MED_FR::MEDconnEcr( _medIdt,
2284           //                            const_cast <char *> ( _meshName.c_str()),
2285           //                            _ptrMesh->_spaceDimension,
2286           //                            const_cast <int *> (connectivity),
2287           //                            MED_FR::MED_FULL_INTERLACE,
2288           //                            numberOfElements,
2289           //                            MED_FR::MED_LECTURE_ECRITURE,
2290           //                            (MED_FR::med_entite_maillage  ) entity, 
2291           //                            (MED_FR::med_geometrie_element) types[i],
2292           //                            MED_FR::MED_DESC );
2293
2294           err = med_2_2::MEDconnEcr(_medIdt,
2295                                 const_cast <char *> ( _meshName.c_str()),
2296                                 _ptrMesh->_spaceDimension,
2297                                 const_cast <int *> (connectivity),
2298                                 med_2_2::MED_FULL_INTERLACE,
2299                                 numberOfElements,
2300                                 (med_2_2::med_entite_maillage  ) entity, 
2301                                 (med_2_2::med_geometrie_element) types[i],
2302                                 med_2_2::MED_DESC );
2303         
2304           if (err<0) // ETENDRE LES EXPLICATIONS
2305             throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write connectivities of mesh |" << _meshName.c_str() << "| in file |" << _fileName
2306                                          << "| with dimension |"  << _ptrMesh->_spaceDimension <<"| and" 
2307                                          )) ;
2308             
2309         }
2310     }
2311
2312
2313   // Polygons writing
2314   if (_ptrMesh->existPolygonsConnectivity(MED_DESCENDING,entity))
2315     {
2316       err = MEDpolygoneConnEcr(_medIdt,
2317                                const_cast <char *> (_meshName.c_str()),
2318                                const_cast <med_int*> (_ptrMesh->getPolygonsConnectivityIndex(MED_DESCENDING,entity)),
2319                                _ptrMesh->getNumberOfPolygons()+1,
2320                                const_cast <med_int*> (_ptrMesh->getPolygonsConnectivity(MED_DESCENDING,entity)),
2321                                (med_2_2::med_entite_maillage) entity,
2322                                med_2_2::MED_DESC);
2323
2324       if (err<0)
2325         throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write polygons descending connectivities of mesh |" <<  _meshName.c_str() << "| in file |" << _fileName
2326                                              << "| with dimension |"  << _ptrMesh->_spaceDimension <<"| and" 
2327                                              ));
2328     }
2329
2330
2331   // Polyhedron writing
2332   if (_ptrMesh->existPolyhedronConnectivity(MED_DESCENDING,entity))
2333     {
2334       med_int NumberOfFaces = _ptrMesh->getPolyhedronIndex(MED_DESCENDING)[_ptrMesh->getNumberOfPolyhedron()]-1;
2335       vector<med_int> FacesGeometricTypes(NumberOfFaces,MED_POLYGON); // by default all polyhedron faces are polygons
2336
2337       err = MEDpolyedreConnEcr(_medIdt,
2338                                const_cast <char *> (_meshName.c_str()),
2339                                const_cast <med_int*> (_ptrMesh->getPolyhedronIndex(MED_DESCENDING)),
2340                                _ptrMesh->getNumberOfPolyhedron()+1,
2341                                &FacesGeometricTypes[0],
2342                                NumberOfFaces,
2343                                const_cast <med_int*> (_ptrMesh->getPolyhedronConnectivity(MED_DESCENDING)),
2344                                med_2_2::MED_DESC);
2345
2346       if (err<0)
2347         throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write polyhedron descending connectivities of mesh |" << _meshName.c_str() << "| in file |" << _fileName
2348                                              << "| with dimension |"  << _ptrMesh->_spaceDimension <<"| and" 
2349                                              ));
2350     }
2351
2352
2353   END_OF(LOC);
2354   return MED_VALID;
2355 }
2356
2357 int MED_MESH_WRONLY_DRIVER22::writeFamilyNumbers() const {
2358   
2359   const char * LOC="int MED_MESH_WRONLY_DRIVER22::writeFamilyNumbers() const : ";
2360   BEGIN_OF(LOC);
2361
2362   med_2_2::med_err err;
2363   
2364   // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArrayNodeFamily DOIT ETRE ENLEVER DE LA CLASSE MESH
2365
2366   { // Node related block
2367     
2368     // We build the array from the families list objects :
2369     int NumberOfNodes = _ptrMesh->getNumberOfNodes() ;
2370     int * MEDArrayNodeFamily = new int[NumberOfNodes] ;
2371     // family 0 by default
2372     for (int i=0; i<NumberOfNodes; i++)
2373       MEDArrayNodeFamily[i]=0;
2374     //vector<FAMILY*> myFamilies = _ptrMesh->getFamilies(MED_NODE);
2375     vector<FAMILY*> * myFamilies = &_ptrMesh->_familyNode;
2376     int NumberOfNodesFamilies = myFamilies->size() ;
2377     //bool ToDestroy = false;
2378     if (0 == NumberOfNodesFamilies) {
2379       //ToDestroy = true ;
2380       vector<GROUP*> myGroups = _ptrMesh->getGroups(MED_NODE);
2381       int NumberOfGroups = myGroups.size() ;
2382       // build families from groups
2383       for (int i=0; i<NumberOfGroups; i++) {
2384         SUPPORT * mySupport = myGroups[i] ;
2385         FAMILY* myFamily = new FAMILY(*mySupport);
2386         myFamily->setIdentifier(i+1);
2387         myFamilies->push_back(myFamily);
2388       }
2389       NumberOfNodesFamilies=myFamilies->size() ;
2390     }
2391     for (int i=0 ; i<NumberOfNodesFamilies; i++) {
2392       //SCRUTE(i);
2393       //SCRUTE(myFamilies[i]->getName());
2394       int FamilyIdentifier = (*myFamilies)[i]->getIdentifier() ;
2395       int TotalNumber = (*myFamilies)[i]->getNumberOfElements(MED_ALL_ELEMENTS) ;
2396       if ((*myFamilies)[i]->isOnAllElements())
2397         for (int j=0; j<TotalNumber; j++)
2398           MEDArrayNodeFamily[j]=FamilyIdentifier;
2399       else {
2400         const int * Number = (*myFamilies)[i]->getNumber(MED_ALL_ELEMENTS) ;
2401         for (int j=0; j<TotalNumber; j++)
2402           MEDArrayNodeFamily[Number[j]-1]=FamilyIdentifier ;
2403       }
2404     }
2405
2406     for(int j=0; j<NumberOfNodes; j++) {
2407       SCRUTE(MEDArrayNodeFamily[j]);
2408     }
2409
2410 //     if ( !_ptrMesh->getIsAGrid() )
2411
2412       err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
2413                     MEDArrayNodeFamily, NumberOfNodes, med_2_2::MED_NOEUD,
2414                     (med_2_2::med_geometrie_element) MED_NONE);
2415
2416 //     else
2417 //       err = MEDfamGridEcr(_medIdt,
2418 //                        const_cast <char *> (_ptrMesh->_name.c_str()),
2419 //                        MEDArrayNodeFamily,
2420 //                        NumberOfNodes,
2421 //                        MED_FR::MED_LECTURE_ECRITURE,
2422 //                        MED_FR::MED_NOEUD);
2423
2424     if ( err != MED_VALID) 
2425       throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write node family for the |"<< NumberOfNodes
2426                                    << "| nodes in mesh |" 
2427                                    << _ptrMesh->_name.c_str() << "|" ));
2428     delete[] MEDArrayNodeFamily;
2429     //if (true == ToDestroy)
2430     //  for (int i=0; i<NumberOfNodesFamilies; i++)
2431     //    delete myFamilies[i];
2432   }
2433     
2434   { // CELLS RELATED BLOCK
2435     medEntityMesh entity=MED_EN::MED_CELL;
2436     // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArray____Family DOIT ETRE ENLEVER DE LA CLASSE MESH
2437     if  ( ( _ptrMesh->existConnectivity(MED_NODAL,entity) )|( _ptrMesh->existConnectivity(MED_DESCENDING,entity) ) ) { 
2438
2439       int numberOfTypes           = _ptrMesh->getNumberOfTypes (entity) ;
2440       const medGeometryElement  * types = _ptrMesh->getTypes         (entity) ;
2441
2442       // We build the array from the families list objects :
2443       int NumberOfElements = _ptrMesh->getNumberOfElements(entity, MED_ALL_ELEMENTS);
2444       int * MEDArrayFamily = new int[NumberOfElements] ;
2445       // family 0 by default
2446       for (int i=0; i<NumberOfElements; i++)
2447         MEDArrayFamily[i]=0;
2448       //vector<FAMILY*> myFamilies = _ptrMesh->getFamilies(entity);
2449       vector<FAMILY*> * myFamilies = &_ptrMesh->_familyCell ;
2450       int NumberOfFamilies = myFamilies->size() ;
2451       //bool ToDestroy = false;
2452       if (0 == NumberOfFamilies) {
2453         //ToDestroy = true ;
2454         vector<GROUP*> myGroups = _ptrMesh->getGroups(entity);
2455         int NumberOfGroups = myGroups.size() ;
2456         // build families from groups
2457         for (int i=0; i<NumberOfGroups; i++) {
2458           SCRUTE( myGroups[i]->getName() );
2459           SUPPORT * mySupport = myGroups[i] ;
2460           FAMILY* myFamily = new FAMILY(*mySupport);
2461           myFamily->setIdentifier(-i-1);
2462           myFamilies->push_back(myFamily);
2463         }
2464         NumberOfFamilies=myFamilies->size() ;
2465       }
2466       for (int i=0 ; i<NumberOfFamilies; i++) {
2467         int FamilyIdentifier = (*myFamilies)[i]->getIdentifier() ;
2468         int TotalNumber = (*myFamilies)[i]->getNumberOfElements(MED_ALL_ELEMENTS) ;
2469         if ((*myFamilies)[i]->isOnAllElements())
2470           for (int ii=0; ii<TotalNumber; ii++)
2471             MEDArrayFamily[ii]=FamilyIdentifier;
2472         else {
2473           const int * Number = (*myFamilies)[i]->getNumber(MED_ALL_ELEMENTS) ;
2474           for (int ii=0; ii<TotalNumber; ii++)
2475             MEDArrayFamily[Number[ii]-1]=FamilyIdentifier ;
2476         }
2477       }
2478
2479       const int * typeCount = _ptrMesh->getGlobalNumberingIndex(entity) ;
2480 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
2481         int lgth=NumberOfElements;
2482         med_2_2::med_int *temp=new med_2_2::med_int[lgth];
2483         for(int i2=0;i2<lgth;i2++)
2484           temp[i2]=(med_2_2::med_int) (MEDArrayFamily[i2]);
2485 #endif
2486       for (int i=0; i<numberOfTypes; i++) {
2487 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
2488         err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
2489                         temp+typeCount[i]-1,typeCount[i+1]-typeCount[i],
2490                         med_2_2::MED_REMP ,
2491                         (med_2_2::med_entite_maillage) entity,
2492                         (med_2_2::med_geometrie_element) types[i]
2493 );
2494 #else
2495         err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
2496                         (MEDArrayFamily+typeCount[i]-1),
2497                         (typeCount[i+1]-typeCount[i]),
2498                         (med_2_2::med_entite_maillage) entity,
2499                         (med_2_2::med_geometrie_element) types[i]); 
2500
2501         MESSAGE("OK "<<i);
2502         if ( err != MED_VALID) 
2503           throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write family for the |"<< _ptrMesh->getNumberOfElements(entity, types[i])
2504                                        << "| cells of geometric type |" << geoNames[types[i]] <<"|in mesh |"      
2505                                        << _ptrMesh->_name.c_str() << "|" ));   
2506       }
2507 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
2508       delete [] temp;
2509 #endif
2510       delete[] MEDArrayFamily ;
2511       //if (true == ToDestroy) {
2512       //  int NumberOfFamilies = myFamilies->size();
2513       //  for (int i=0; i<NumberOfFamilies; i++)
2514       //    delete myFamilies[i];
2515       //}
2516     }
2517   }
2518
2519   { // FACE RELATED BLOCK
2520     medEntityMesh entity=MED_EN::MED_FACE;
2521     // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArray____Family DOIT ETRE ENLEVER DE LA CLASSE MESH
2522     if  ( ( _ptrMesh->existConnectivity(MED_NODAL,entity) )|( _ptrMesh->existConnectivity(MED_DESCENDING,entity) ) ) { 
2523
2524       int numberOfTypes           = _ptrMesh->getNumberOfTypes (entity) ;
2525       const medGeometryElement  * types = _ptrMesh->getTypes         (entity) ;
2526       SCRUTE(numberOfTypes);
2527       
2528       int numberOfElements = _ptrMesh->getNumberOfElements(entity, MED_ALL_ELEMENTS) ;
2529       int * familyArray = new int[numberOfElements] ;
2530       for (int i=0;i<numberOfElements;i++)
2531         familyArray[i]=0;
2532
2533       int numberOfFamilies = _ptrMesh->getNumberOfFamilies(entity) ;
2534       //vector<FAMILY*> myFamilies = _ptrMesh->getFamilies(entity) ;
2535       vector<FAMILY*> * myFamilies = &_ptrMesh->_familyFace ;
2536       //bool ToDestroy = false;
2537       if (0 == numberOfFamilies) {
2538         //ToDestroy = true ;
2539         vector<GROUP*> myGroups = _ptrMesh->getGroups(entity);
2540         int NumberOfGroups = myGroups.size() ;
2541         // build families from groups
2542         for (int i=0; i<NumberOfGroups; i++) {
2543           SCRUTE( myGroups[i]->getName() );
2544           SUPPORT * mySupport = myGroups[i] ;
2545           FAMILY* myFamily = new FAMILY(*mySupport);
2546           myFamily->setIdentifier(-i-1000);
2547           myFamilies->push_back(myFamily);
2548         }
2549         numberOfFamilies=myFamilies->size() ;
2550       }
2551       for (int i=0;i<numberOfFamilies;i++) {
2552         int familyNumber = (*myFamilies)[i]->getIdentifier() ;
2553         int numberOfFamilyElements = (*myFamilies)[i]->getNumberOfElements(MED_ALL_ELEMENTS) ;
2554         if ((*myFamilies)[i]->isOnAllElements())
2555           for (int ii=0; ii<numberOfFamilyElements; ii++)
2556             familyArray[ii]=familyNumber;
2557         else {
2558           const int * myFamilyElements = (*myFamilies)[i]->getNumber(MED_ALL_ELEMENTS) ;
2559           for (int ii=0;ii<numberOfFamilyElements;ii++)
2560             familyArray[myFamilyElements[ii]-1]=familyNumber;
2561         }
2562       }
2563
2564       const int * typeCount = _ptrMesh->getGlobalNumberingIndex(entity) ;
2565 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
2566         int lgth=numberOfElements;
2567         med_2_2::med_int *temp=new med_2_2::med_int[lgth];
2568         for(int i2=0;i2<lgth;i2++)
2569           temp[i2]=(med_2_2::med_int) (familyArray[i2]);
2570 #endif
2571       for (int i=0; i<numberOfTypes; i++) {
2572         int typeNumberOfElements = typeCount[i+1] - typeCount[i] ;
2573
2574         err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
2575                         familyArray+typeCount[i]-1, typeNumberOfElements,
2576                         (med_2_2::med_entite_maillage) entity,
2577                         (med_2_2::med_geometrie_element) types[i]); 
2578 #endif
2579         if ( err != MED_VALID) 
2580           throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write family for the |"<< _ptrMesh->getNumberOfElements(entity, types[i])
2581                                        << "| faces of geometric type |" << geoNames[types[i]] <<"|in mesh |"      
2582                                        << _ptrMesh->_name.c_str() << "|" ));   
2583       }
2584 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
2585       delete [] temp;
2586 #endif
2587       delete[] familyArray ;
2588       //if (true == ToDestroy) {
2589       //  int NumberOfFamilies = myFamilies->size();
2590       //    for (int i=0; i<NumberOfFamilies; i++)
2591       //      delete myFamilies[i];
2592       //}
2593     }
2594   }
2595
2596   { // EDGE RELATED BLOCK
2597     //medEntityMesh entity=MED_EN::MED_FACE;
2598     medEntityMesh entity=MED_EN::MED_EDGE;
2599     // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArray____Family DOIT ETRE ENLEVER DE LA CLASSE MESH
2600     if  ( ( _ptrMesh->existConnectivity(MED_NODAL,entity) )|( _ptrMesh->existConnectivity(MED_DESCENDING,entity) ) ) { 
2601
2602       int numberOfTypes           = _ptrMesh->getNumberOfTypes (entity) ;
2603       const medGeometryElement  * types = _ptrMesh->getTypes         (entity) ;
2604       
2605       int numberOfElements = _ptrMesh->getNumberOfElements(entity, MED_ALL_ELEMENTS) ;
2606       int * familyArray = new int[numberOfElements] ;
2607       for (int i=0;i<numberOfElements;i++)
2608         familyArray[i]=0;
2609
2610       int numberOfFamilies = _ptrMesh->getNumberOfFamilies(entity) ;
2611       //vector<FAMILY*> myFamilies = _ptrMesh->getFamilies(entity) ;
2612       vector<FAMILY*> * myFamilies = &_ptrMesh->_familyEdge ;
2613       //bool ToDestroy = false;
2614       if (0 == numberOfFamilies) {
2615         //ToDestroy = true ;
2616         vector<GROUP*> myGroups = _ptrMesh->getGroups(entity);
2617         int NumberOfGroups = myGroups.size() ;
2618         // build families from groups
2619         for (int i=0; i<NumberOfGroups; i++) {
2620           SCRUTE( myGroups[i]->getName() );
2621           SUPPORT * mySupport = myGroups[i] ;
2622           FAMILY* myFamily = new FAMILY(*mySupport);
2623           myFamily->setIdentifier(-i-2000);
2624           myFamilies->push_back(myFamily);
2625         }
2626         numberOfFamilies=myFamilies->size() ;
2627       }
2628       for (int i=0;i<numberOfFamilies;i++) {
2629         int familyNumber = (*myFamilies)[i]->getIdentifier() ;
2630         int numberOfFamilyElements = (*myFamilies)[i]->getNumberOfElements(MED_ALL_ELEMENTS) ;
2631         if ((*myFamilies)[i]->isOnAllElements())
2632           for (int ii=0; ii<numberOfFamilyElements; ii++)
2633             familyArray[ii]=familyNumber;
2634         else {
2635           const int * myFamilyElements = (*myFamilies)[i]->getNumber(MED_ALL_ELEMENTS) ;
2636           for (int ii=0;ii<numberOfFamilyElements;ii++)
2637             familyArray[myFamilyElements[ii]-1]=familyNumber;
2638         }
2639       }
2640
2641       const int * typeCount = _ptrMesh->getGlobalNumberingIndex(entity) ;
2642 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
2643         int lgth=numberOfElements;
2644         med_2_2::med_int *temp=new med_2_2::med_int[lgth];
2645         for(int i2=0;i2<lgth;i2++)
2646           temp[i2]=(med_2_2::med_int) (familyArray[i2]);
2647 #endif
2648       for (int i=0; i<numberOfTypes; i++) {
2649         int typeNumberOfElements = typeCount[i+1] - typeCount[i] ;
2650
2651         err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
2652                         familyArray+typeCount[i]-1, typeNumberOfElements,
2653                         (med_2_2::med_entite_maillage) entity,
2654                         (med_2_2::med_geometrie_element) types[i]); 
2655
2656         if ( err != MED_VALID) 
2657           throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write family for the |"<< _ptrMesh->getNumberOfElements(entity, types[i])
2658                                        << "| edges of geometric type |" << geoNames[types[i]] <<"|in mesh |"      
2659                                        << _ptrMesh->_name.c_str() << "|" ));   
2660       }
2661 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
2662       delete [] temp;
2663 #endif
2664       delete[] familyArray ;
2665       //if (true == ToDestroy) {
2666       //  int NumberOfFamilies = myFamilies->size();
2667       //  for (int i=0; i<NumberOfFamilies; i++)
2668       //    delete myFamilies[i];
2669       //}
2670     }
2671   }
2672     
2673   END_OF(LOC);
2674   return MED_VALID;
2675 }
2676
2677 int MED_MESH_WRONLY_DRIVER22::writeFamilies(vector<FAMILY*> & families ) const
2678 {
2679   
2680   const char * LOC="int MED_MESH_WRONLY_DRIVER22::writeFamilies(vector<FAMILY*> families) const : ";
2681   BEGIN_OF(LOC);
2682
2683   med_2_2::med_err err;
2684   
2685   MESSAGE(LOC<<" families.size() :"<<families.size());
2686
2687   for (unsigned int i=0; i< families.size(); i++) {
2688
2689     int      numberOfAttributes         = families[i]->getNumberOfAttributes ();
2690     string   attributesDescriptions     = "";
2691
2692     // Recompose the attributes descriptions arg for MED
2693     for (int j=0; j < numberOfAttributes; j++) {
2694         
2695       string attributeDescription = families[i]->getAttributeDescription(j+1);
2696         
2697       if ( attributeDescription.size() > MED_TAILLE_DESC )
2698         throw MEDEXCEPTION( LOCALIZED(STRING(LOC) << "The size of the attribute description n° |" << j+1 << "| of the family |" << families[i]->getName()
2699                                       << "| with identifier |" << families[i]->getIdentifier()  << "| is |" 
2700                                       <<  attributeDescription.size()  <<"| and is more than |" <<  MED_TAILLE_DESC << "|")) ;
2701         
2702       attributesDescriptions += attributeDescription;
2703     }
2704       
2705
2706     int      numberOfGroups  = families[i]->getNumberOfGroups();
2707     string   groupsNames(numberOfGroups*MED_TAILLE_LNOM,'\0') ;
2708     // Recompose the groups names arg for MED
2709     for (int j=0; j < numberOfGroups; j++) {
2710
2711       string groupName = families[i]->getGroupName(j+1);
2712        
2713       if ( groupName.size() > MED_TAILLE_LNOM )
2714         throw MEDEXCEPTION( LOCALIZED(STRING(LOC) << "The size of the group name  n° |" << j+1 << "| of the family |" << families[i]->getName()
2715                                       << "| with identifier |" << families[i]->getIdentifier()  << "| is |" 
2716                                       <<  groupName.size()  <<"| and is more than |" << MED_TAILLE_LNOM << "|")) ;
2717         
2718
2719       int length = min(MED_TAILLE_LNOM,(int)groupName.size());
2720       groupsNames.replace(j*MED_TAILLE_LNOM,length, groupName,0,length);
2721       
2722     }
2723
2724     // test if the family already exists (HDF trick waiting a MED evolution to be replaced)
2725
2726     string dataGroupFam;
2727     if (families[i]->getEntity() == MED_NODE)
2728       dataGroupFam = "/ENS_MAA/"+_meshName+"/FAS/NOEUD/"+families[i]->getName()+"/";  
2729     else
2730       dataGroupFam = "/ENS_MAA/"+_meshName+"/FAS/ELEM/"+families[i]->getName()+"/"; 
2731
2732     SCRUTE("|"<<dataGroupFam<<"|");
2733     err = med_2_2::_MEDdatagroupOuvrir(_medIdt,const_cast <char *> (dataGroupFam.c_str()) ) ;
2734     if ( err < MED_VALID ) {
2735       SCRUTE(err);
2736
2737       MESSAGE(LOC<<"families[i]->getName().c_str() : "<<families[i]->getName().c_str());
2738       MESSAGE(LOC<<"_meshName.c_str() : "<<_meshName.c_str());
2739       MESSAGE(LOC<<"families[i]->getIdentifier() : "<<families[i]->getIdentifier());
2740       MESSAGE(LOC<<"numberOfAttributes : "<<numberOfAttributes);
2741         
2742       //MESSAGE(LOC<<"families[i]->getAttributesIdentifiers() : "<<families[i]->getAttributesIdentifiers()[0]);
2743       //MESSAGE(LOC<<"families[i]->getAttributesValues() : "<<families[i]->getAttributesValues()[0]);
2744       MESSAGE(LOC<<"attributesDescriptions.c_str() : "<<attributesDescriptions.c_str());
2745       MESSAGE(LOC<<"numberOfGroups : "<<numberOfGroups);
2746       MESSAGE(LOC<<"groupsNames.c_str() : "<<groupsNames.c_str());
2747 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
2748       int lgth=families[i]->getNumberOfAttributes();
2749       med_2_2::med_int *  AttributesIdentifier2 = new med_2_2::med_int[lgth] ;
2750       med_2_2::med_int *  AttributesValues2     = new med_2_2::med_int[lgth] ;
2751       for(med_2_2::med_int i2=0;i2<lgth;i2++)
2752         {
2753           AttributesIdentifier2[i2]=(med_2_2::med_int)(families[i]->getAttributesIdentifiers()[i2]);
2754           AttributesValues2[i2]=(med_2_2::med_int)(families[i]->getAttributesValues()[i2]);
2755         }
2756       err = med_2_2::MEDfamCr( _medIdt, 
2757                               const_cast <char *> ( _meshName.c_str() ),
2758                               const_cast <char *> ( families[i]->getName().c_str() ),
2759                               families[i]->getIdentifier(), 
2760                               AttributesIdentifier2,
2761                               AttributesValues2,
2762                               const_cast <char *> (attributesDescriptions.c_str()), 
2763                               numberOfAttributes,  
2764                               const_cast <char *> (groupsNames.c_str()), 
2765                               numberOfGroups);
2766       delete [] AttributesIdentifier2;
2767       delete [] AttributesValues2;
2768 #else
2769       err = med_2_2::MEDfamCr( _medIdt, 
2770                               const_cast <char *> ( _meshName.c_str() ),
2771                               const_cast <char *> ( families[i]->getName().c_str() ),
2772                               families[i]->getIdentifier(), 
2773                               families[i]->getAttributesIdentifiers(),
2774                               families[i]->getAttributesValues(),
2775                               const_cast <char *> (attributesDescriptions.c_str()), 
2776                               numberOfAttributes,  
2777                               const_cast <char *> (groupsNames.c_str()), 
2778                               numberOfGroups);
2779 #endif
2780       SCRUTE(err);
2781       if ( err != MED_VALID) 
2782         throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't create family |" << families[i]->getName()
2783                                      << "| with identifier |" << families[i]->getIdentifier()  << "| groups names |" 
2784                                      << groupsNames  <<"| and  attributes descriptions |" << attributesDescriptions << "|")) ;
2785     }
2786     else
2787       med_2_2::_MEDdatagroupFermer(_medIdt);
2788
2789
2790   }
2791
2792   END_OF(LOC);
2793     
2794   return MED_VALID;
2795 }
2796
2797
2798 // A FAIRE POUR LES NOEUDS ET LES ELEMENTS ret = MEDfamEcr(
2799
2800
2801
2802 /*--------------------- RDWR PART -------------------------------*/
2803
2804 MED_MESH_RDWR_DRIVER22::MED_MESH_RDWR_DRIVER22()
2805 {
2806 }
2807
2808 MED_MESH_RDWR_DRIVER22::MED_MESH_RDWR_DRIVER22(const string & fileName,
2809                                                MESH * ptrMesh):
2810   MED_MESH_DRIVER(fileName,ptrMesh,MED_RDWR),
2811   IMED_MESH_RDONLY_DRIVER(fileName,ptrMesh),
2812   IMED_MESH_WRONLY_DRIVER(fileName,ptrMesh),
2813   IMED_MESH_RDWR_DRIVER(fileName,ptrMesh),
2814   MED_MESH_DRIVER22(fileName,ptrMesh,MED_RDWR),
2815   MED_MESH_RDONLY_DRIVER22(fileName,ptrMesh),
2816   MED_MESH_WRONLY_DRIVER22(fileName,ptrMesh)
2817 {
2818   MESSAGE("MED_MESH_RDWR_DRIVER22::MED_MESH_RDWR_DRIVER22(const string & fileName, MESH * ptrMesh) has been created");
2819 }
2820
2821 MED_MESH_RDWR_DRIVER22::MED_MESH_RDWR_DRIVER22(const MED_MESH_RDWR_DRIVER22 & driver):
2822   MED_MESH_DRIVER(driver),
2823   IMED_MESH_RDONLY_DRIVER(driver),
2824   IMED_MESH_WRONLY_DRIVER(driver),
2825   IMED_MESH_RDWR_DRIVER(driver),
2826   MED_MESH_DRIVER22(driver),
2827   MED_MESH_RDONLY_DRIVER22(driver),
2828   MED_MESH_WRONLY_DRIVER22(driver)
2829 {
2830 }
2831
2832 MED_MESH_RDWR_DRIVER22::~MED_MESH_RDWR_DRIVER22() {
2833   //MESSAGE("MED_MESH_RDWR_DRIVER22::MED_MESH_RDWR_DRIVER22(const string & fileName, MESH * ptrMesh) has been destroyed");
2834
2835   
2836 GENDRIVER * MED_MESH_RDWR_DRIVER22::copy(void) const
2837 {
2838   return new MED_MESH_RDWR_DRIVER22(*this);
2839 }
2840
2841 void MED_MESH_RDWR_DRIVER22::write(void) const
2842 {
2843   MED_MESH_WRONLY_DRIVER22::write();
2844 }
2845 void MED_MESH_RDWR_DRIVER22::read (void)
2846 {
2847   MED_MESH_RDONLY_DRIVER22::read();
2848 }
2849