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