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