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