1 #include "MEDMEM_MedMeshDriver22.hxx"
3 #include "MEDMEM_DriversDef.hxx"
5 #include "MEDMEM_Family.hxx"
6 #include "MEDMEM_Group.hxx"
7 #include "MEDMEM_Coordinate.hxx"
8 #include "MEDMEM_Connectivity.hxx"
9 #include "MEDMEM_Mesh.hxx"
10 #include "MEDMEM_CellModel.hxx"
11 #include "MEDMEM_Grid.hxx"
14 using namespace MED_EN;
15 using namespace MEDMEM;
19 extern med_idt _MEDdatagroupOuvrir(med_idt pid, char *nom);
20 extern med_err _MEDdatagroupFermer(med_idt id);
24 // Every memory allocation made in the MedDriver members function are desallocated in the Mesh destructor
26 MED_MESH_DRIVER22::MED_MESH_DRIVER22(): _medIdt(MED_INVALID)
30 MED_MESH_DRIVER22::MED_MESH_DRIVER22(const string & fileName,
32 MED_EN::med_mode_acces accessMode):
33 _medIdt(MED_INVALID), MED_MESH_DRIVER(fileName,ptrMesh,accessMode)
37 MED_MESH_DRIVER22::MED_MESH_DRIVER22(const MED_MESH_DRIVER22 & driver):
38 MED_MESH_DRIVER(driver),_medIdt(driver._medIdt)
42 MED_MESH_DRIVER22::~MED_MESH_DRIVER22()
46 void MED_MESH_DRIVER22::open()
48 const char * LOC = "MED_MESH_DRIVER22::open()" ;
51 MESSAGE(LOC<<" : _fileName.c_str : "<< _fileName.c_str()<<",mode : "<< _accessMode);
52 _medIdt = med_2_2::MEDouvrir( (const_cast <char *> (_fileName.c_str())),(med_2_2::med_mode_acces) _accessMode);
53 MESSAGE(LOC<<" _medIdt : "<< _medIdt );
57 _medIdt = MED_INVALID;
59 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Could not open file "<<_fileName<<" in mode "<<_accessMode));
65 void MED_MESH_DRIVER22::close()
67 const char * LOC = "MED_MESH_DRIVER22::close() " ;
70 if ( _status == MED_OPENED) {
71 err = med_2_2::MEDfermer(_medIdt);
72 // san -- MED5873 : Calling H5close() here leads to failure of SALOMEDS::StudyManager_i::_SaveAs()
73 // method during study saving process. MEDfermer() seems sufficient for closing a file.
74 //H5close(); // If we call H5close() all the files are closed.
76 throw MEDEXCEPTION( LOCALIZED(STRING(LOC)
77 <<" Error when closing file !"
80 MESSAGE(LOC <<": _medIdt= " << _medIdt );
81 MESSAGE(LOC<<": MEDfermer : err = " << err );
83 _medIdt = MED_INVALID;
88 //A FAIRE UTILISER LES MAPS...
89 const med_2_2::med_geometrie_element MED_MESH_DRIVER22::all_cell_type[MED_NBR_GEOMETRIE_MAILLE]=
90 { med_2_2::MED_POINT1,med_2_2::MED_SEG2,med_2_2::MED_SEG3,med_2_2::MED_TRIA3,med_2_2::MED_QUAD4,med_2_2::MED_TRIA6,med_2_2::MED_QUAD8,
91 med_2_2::MED_TETRA4,med_2_2::MED_PYRA5,med_2_2::MED_PENTA6,med_2_2::MED_HEXA8,med_2_2::MED_TETRA10,med_2_2::MED_PYRA13,
92 med_2_2::MED_PENTA15, med_2_2::MED_HEXA20};
94 const char * const MED_MESH_DRIVER22::all_cell_type_tab [MED_NBR_GEOMETRIE_MAILLE]=
95 { "MED_POINT1","MED_SEG2","MED_SEG3","MED_TRIA3","MED_QUAD4","MED_TRIA6","MED_QUAD8",
96 "MED_TETRA4","MED_PYRA5","MED_PENTA6","MED_HEXA8","MED_TETRA10","MED_PYRA13",
97 "MED_PENTA15","MED_HEXA20"};
100 //---------------------------------- RDONLY PART -------------------------------------------------------------
102 MED_MESH_RDONLY_DRIVER22::MED_MESH_RDONLY_DRIVER22()
106 MED_MESH_RDONLY_DRIVER22::MED_MESH_RDONLY_DRIVER22(const string & fileName,
108 IMED_MESH_RDONLY_DRIVER(fileName,ptrMesh),MED_MESH_DRIVER22(fileName,ptrMesh,MED_RDONLY),MED_MESH_DRIVER(fileName,ptrMesh,MED_RDONLY)
110 MESSAGE("MED_MESH_RDONLY_DRIVER22::MED_MESH_RDONLY_DRIVER22(const string & fileName, MESH * ptrMesh) has been created");
113 MED_MESH_RDONLY_DRIVER22::MED_MESH_RDONLY_DRIVER22(const MED_MESH_RDONLY_DRIVER22 & driver):
114 IMED_MESH_RDONLY_DRIVER(driver),MED_MESH_DRIVER22(driver),MED_MESH_DRIVER(driver)
118 MED_MESH_RDONLY_DRIVER22::~MED_MESH_RDONLY_DRIVER22()
120 //MESSAGE("MED_MESH_RDONLY_DRIVER22::~MED_MESH_RDONLY_DRIVER() has been destroyed");
123 GENDRIVER * MED_MESH_RDONLY_DRIVER22::copy(void) const
125 return new MED_MESH_RDONLY_DRIVER22(*this);
128 void MED_MESH_RDONLY_DRIVER22::read(void)
130 const char * LOC = "MED_MESH_RDONLY_DRIVER22::read() : " ;
132 if (_status!=MED_OPENED)
133 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The _idt of file " << _fileName << " is : " << _medIdt << " (the file is not opened)." )) ;
135 _ptrMesh->_name = _meshName;
137 SCRUTE(_ptrMesh->getIsAGrid());
139 if (_ptrMesh->getIsAGrid())
143 // always call getFAMILY : families are requiered !!!!
145 // int nbFam = MEDnFam(_medIdt,
146 // const_cast <char *> (_meshName.c_str()),
148 // MED_FR::MED_FAMILLE);
153 if (getFAMILY()!=MED_VALID)
154 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERREUR in getFAMILY when the mesh is a grid")) ;
156 buildAllGroups(_ptrMesh->_groupNode,_ptrMesh->_familyNode) ;
163 if (getCOORDINATE()!=MED_VALID)
164 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERREUR in getCOORDINATE" )) ;
166 if (getCONNECTIVITY()!=MED_VALID)
167 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERREUR in getCOONECTIVITY")) ;
169 if (getFAMILY()!=MED_VALID)
170 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERREUR in getFAMILY" )) ;
174 // we build all groups
176 buildAllGroups(_ptrMesh->_groupNode,_ptrMesh->_familyNode) ;
178 buildAllGroups(_ptrMesh->_groupCell,_ptrMesh->_familyCell) ;
180 buildAllGroups(_ptrMesh->_groupFace,_ptrMesh->_familyFace) ;
182 buildAllGroups(_ptrMesh->_groupEdge,_ptrMesh->_familyEdge) ;
184 // MESSAGE(LOC<<"Checking of CellModel !!!!!!!");
186 // int nbOfTypes = _ptrMesh->_connectivity->_numberOfTypes;
187 // for(int i=0;i<nbOfTypes;i++)
189 // MESSAGE(LOC << _ptrMesh->_connectivity->_type[i]) ;
195 //=======================================================================
198 //=======================================================================
200 void MED_MESH_RDONLY_DRIVER22::getGRID()
202 const char * LOC = "MED_MESH_RDONLY_DRIVER22::getGRID() : " ;
205 if (_status!=MED_OPENED)
206 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "med file is not opened"));
208 GRID * ptrGrid = (GRID *) _ptrMesh;
214 int numberOfMeshesInFile = med_2_2::MEDnMaa(_medIdt);
216 if (numberOfMeshesInFile == MED_INVALID)
217 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Problem in File where the mesh " << _meshName << " is supposed to be stored"));
219 for (int index = 0; index < numberOfMeshesInFile; index++)
221 char meshName[MED_TAILLE_NOM+1]="";
222 char meshDescription[MED_TAILLE_DESC+1]="";
224 med_2_2::med_maillage meshType;
226 err = med_2_2::MEDmaaInfo(_medIdt, (index+1),meshName, &meshDim,
227 &meshType, meshDescription) ;
229 MESSAGE(LOC<<": Mesh n°"<< (index+1) <<" nammed "<< meshName << " with the description " << meshDescription << " is structured");
231 if (_meshName == string(meshName))
233 _ptrMesh->_description = meshDescription;
234 _ptrMesh->_name = meshName;
238 MED_EN::med_grid_type gridType = ptrGrid->getGridType();
240 MESSAGE(LOC<<": Mesh processed is nammed "<< _ptrMesh->_name << " with the description " << _ptrMesh->_description << " is structured with the type " << gridType);
242 // Read the dimension of the mesh <_meshName>
243 int MeshDimension = med_2_2::MEDdimLire(_medIdt, const_cast <char *>
244 (_meshName.c_str())) ;
246 if (MeshDimension == MED_INVALID)
247 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The mesh dimension |" <<
248 MeshDimension << "| seems to be incorrect " <<
249 "for the mesh : |" << _meshName << "|")) ;
251 _ptrMesh->_meshDimension = MeshDimension;
253 // Read or get the dimension of the space for the mesh <_meshName>
254 int SpaceDimension = MeshDimension;
256 int SpaceDimensionRead = med_2_2::MEDdimEspaceLire(_medIdt,
258 (_meshName.c_str())) ;
260 if (SpaceDimensionRead != MED_INVALID) SpaceDimension = SpaceDimensionRead;
262 _ptrMesh->_spaceDimension = SpaceDimension;
264 med_2_2::med_repere rep ;
265 string tmp_nom_coord (MED_TAILLE_PNOM22*(_ptrMesh->_spaceDimension)+1,' ');
266 string tmp_unit_coord(MED_TAILLE_PNOM22*(_ptrMesh->_spaceDimension)+1,' ');
267 char * tmp_nom = (const_cast <char *> ( tmp_nom_coord.c_str()) ) ;
268 char * tmp_unit= (const_cast <char *> ( tmp_unit_coord.c_str()) ) ;
271 int * ArrayLen[] = { & ptrGrid->_iArrayLength,
272 & ptrGrid->_jArrayLength,
273 & ptrGrid->_kArrayLength };
275 MESSAGE(LOC << "The mesh is a " << _ptrMesh->_meshDimension << "D mesh on a " << _ptrMesh->_spaceDimension << "D space");
279 // if (gridType == MED_EN::MED_GRILLE_STANDARD)
280 if (gridType == MED_EN::MED_BODY_FITTED)
282 int * structure = new int[MeshDimension];
284 err = med_2_2::MEDstructureCoordLire(_medIdt,
286 (_ptrMesh->_name.c_str()),
287 MeshDimension,structure);
289 if (err != MED_VALID)
290 throw MEDEXCEPTION(STRING(LOC) <<"Error in reading the structure of grid : |" << _meshName << "|" ) ;
294 for (int idim = 0; idim < MeshDimension; idim++)
296 MESSAGE(LOC<<"structure dim " << idim << " " << structure[idim]);
298 ArrayLen [idim][0] = structure[idim];
299 NumberOfNodes = NumberOfNodes*structure[idim];
304 // NumberOfNodes = MED_FR::MEDnEntMaa(_medIdt,
305 // const_cast <char *>
306 // (_ptrMesh->_name.c_str()),
307 // MED_FR::MED_COOR,MED_FR::MED_NOEUD,
308 // (MED_FR::med_geometrie_element) 0,
309 // (MED_FR::med_connectivite) 0);
311 if ( NumberOfNodes == MED_INVALID )
312 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"The number of nodes |" <<
314 "| seems to be incorrect "
315 << "for the mesh : |" <<
316 _meshName << "|" )) ;
318 _ptrMesh->_numberOfNodes = NumberOfNodes ;
320 // create coordinates and its structure
321 _ptrMesh->_coordinate = new COORDINATE(SpaceDimension,NumberOfNodes,
322 MED_EN::MED_FULL_INTERLACE);
324 err = MEDcoordLire(_medIdt,
325 const_cast <char *> (_ptrMesh->_name.c_str()),
326 _ptrMesh->_spaceDimension,
327 //const_cast <double *> ( _ptrMesh->_coordinate->_coordinate->get(MED_EN::MED_FULL_INTERLACE) ),
328 const_cast <double *> ( _ptrMesh->_coordinate->_coordinate.get(MED_EN::MED_FULL_INTERLACE) ),
329 med_2_2::MED_FULL_INTERLACE,
330 MED_ALL, // we read all the coordinates
331 NULL, // we don't use a profile
332 0, // so the profile's size is 0
333 &rep,tmp_nom,tmp_unit);
335 if (err != MED_VALID)
336 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't read coordinates of the |" <<
337 NumberOfNodes << "| nodes for the mesh : |" <<
338 _meshName << "| of space dimension |" <<
339 SpaceDimension << "| with units names |" <<
340 tmp_nom << "| and units |" <<
343 ptrGrid->_is_coordinates_filled = true;
345 else if ((gridType == MED_EN::MED_CARTESIAN) ||
346 (gridType == MED_EN::MED_POLAR))
350 double * Array[] = { (double*) 0, (double*) 0, (double*) 0 };
352 for (int idim = 0; idim < _ptrMesh->_meshDimension; ++idim)
354 med_2_2::med_table table;
355 if (idim == 0) table = med_2_2::MED_COOR_IND1;
356 else if (idim == 1) table = med_2_2::MED_COOR_IND2;
357 else if (idim == 2) table = med_2_2::MED_COOR_IND3;
359 int length = med_2_2::MEDnEntMaa(_medIdt,
360 const_cast <char *> (_ptrMesh->_name.c_str()),
361 table,med_2_2::MED_NOEUD,
364 if ( length <= MED_VALID )
365 throw MEDEXCEPTION(STRING(LOC) <<"The number of nodes |" << length <<
366 "| seems to be incorrect "
367 << "for the mesh : |" << _meshName << "|" ) ;
369 ArrayLen [idim][0] = length;
370 NumberOfNodes *= length;
372 Array [idim] = new double [ length ];
374 err = med_2_2::MEDindicesCoordLire(_medIdt, const_cast <char *>
375 (_ptrMesh->_name.c_str()),
376 _ptrMesh->_meshDimension,
377 Array [idim], length, (idim+1),
378 tmp_nom+(idim*MED_TAILLE_PNOM22),
379 tmp_unit+(idim*MED_TAILLE_PNOM22));
381 if (err != MED_VALID)
382 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Error in reading coordinates indices " <<
383 idim << "of the grid : |" <<
384 _meshName << "|" )) ;
387 ptrGrid->_iArray = Array[0];
388 ptrGrid->_jArray = Array[1];
389 ptrGrid->_kArray = Array[2];
391 _ptrMesh->_numberOfNodes = NumberOfNodes ;
393 // create coordinates
394 _ptrMesh->_coordinate = new COORDINATE(SpaceDimension,NumberOfNodes,
395 MED_EN::MED_FULL_INTERLACE);
397 if (gridType == MED_EN::MED_CARTESIAN)
398 rep = med_2_2::MED_CART;
399 else if (gridType == MED_EN::MED_POLAR)
401 if (SpaceDimension == 2) rep = med_2_2::MED_CYL;
402 else if (SpaceDimension == 3) rep = med_2_2::MED_SPHER;
406 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<" bad grid type : " << gridType));
408 // set coordinate names
410 for (i=0; i<_ptrMesh->_spaceDimension; ++i ) {
411 string myStringName(tmp_nom_coord,i*MED_TAILLE_PNOM22,MED_TAILLE_PNOM22) ;
412 string myStringUnit(tmp_unit_coord,i*MED_TAILLE_PNOM22,MED_TAILLE_PNOM22) ;
413 // suppress space at the end
415 for(j=MED_TAILLE_PNOM22-1;j>=0;j--)
416 if (myStringName[j] != ' ') break ;
417 _ptrMesh->_coordinate->_coordinateName[i]=string(myStringName,0,j+1);
418 for(j=MED_TAILLE_PNOM22-1;j>=0;j--)
419 if (myStringUnit[j] != ' ') break ;
420 _ptrMesh->_coordinate->_coordinateUnit[i]=string(myStringUnit,0,j+1);
423 string coordinateSystem = "UNDEFINED";
425 if( rep == med_2_2::MED_CART) coordinateSystem = "CARTESIAN";
426 else if ( rep == med_2_2::MED_CYL) coordinateSystem = "CYLINDRICAL";
427 else if ( rep == med_2_2::MED_SPHER) coordinateSystem = "SPHERICAL";
429 _ptrMesh->_coordinate->setCoordinatesSystem(coordinateSystem);
434 //=======================================================================
435 //function : getCOORDINATE
436 // A FAIRE : RENVOYER DU VOID
437 //=======================================================================
438 int MED_MESH_RDONLY_DRIVER22::getCOORDINATE()
440 const char * LOC = "MED_MESH_RDONLY_DRIVER22::getCOORDINATE() : " ;
444 if (_status==MED_OPENED)
448 int numberOfMeshesInFile = med_2_2::MEDnMaa(_medIdt);
450 if (numberOfMeshesInFile == MED_INVALID)
451 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Problem in File where the mesh " << _meshName << " is supposed to be stored"));
453 for (int index = 0; index < numberOfMeshesInFile; index++)
455 char meshName[MED_TAILLE_NOM+1]="";
456 char meshDescription[MED_TAILLE_DESC+1]="";
458 med_2_2::med_maillage meshType;
460 err = med_2_2::MEDmaaInfo(_medIdt, (index+1), meshName, &meshDim,
461 &meshType, meshDescription) ;
463 MESSAGE(LOC<<": Mesh n°"<< (index+1) <<" nammed "<< meshName << " with the description " << meshDescription << " is structured");
465 if (_meshName == string(meshName))
467 _ptrMesh->_description = meshDescription;
472 // Read the dimension of the mesh <_meshName>
473 int MeshDimension = med_2_2::MEDdimLire(_medIdt, const_cast <char *>
474 (_meshName.c_str())) ;
476 if ( MeshDimension == MED_INVALID )
477 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The mesh dimension |" <<
479 "| seems to be incorrect " <<
480 "for the mesh : |" << _meshName << "|")) ;
482 _ptrMesh->_meshDimension = MeshDimension;
484 // Read or get the dimension of the space for the mesh <_meshName>
485 int SpaceDimension = MeshDimension;
487 int SpaceDimensionRead = med_2_2::MEDdimEspaceLire(_medIdt,
489 (_meshName.c_str())) ;
491 if (SpaceDimensionRead != MED_INVALID)
492 SpaceDimension = SpaceDimensionRead;
494 _ptrMesh->_spaceDimension = SpaceDimension;
496 // Read the number of nodes used in the mesh <_meshName>
497 // to be able to create a COORDINATE object
498 int NumberOfNodes=MEDnEntMaa(_medIdt,
499 const_cast <char *> (_meshName.c_str()),
502 (med_2_2::med_geometrie_element) MED_NONE,
503 (med_2_2::med_connectivite) MED_NONE);
504 if ( NumberOfNodes <= MED_VALID )
505 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"The number of nodes |" << NumberOfNodes << "| seems to be incorrect "
506 << "for the mesh : |" << _meshName << "|" )) ;
507 _ptrMesh->_numberOfNodes = NumberOfNodes ;
509 // create a COORDINATE object
510 _ptrMesh->_coordinate = new COORDINATE(SpaceDimension, NumberOfNodes, MED_EN::MED_FULL_INTERLACE);
512 med_2_2::med_repere rep ; // ATTENTION ---> DOIT ETRE INTEGRE DS MESH EF: FAIT NON?
513 string tmp_nom_coord (MED_TAILLE_PNOM22*(_ptrMesh->_spaceDimension)+1,'\0');
514 string tmp_unit_coord(MED_TAILLE_PNOM22*(_ptrMesh->_spaceDimension)+1,'\0');
515 char * tmp_nom = (const_cast <char *> ( tmp_nom_coord.c_str()) ) ;
516 char * tmp_unit= (const_cast <char *> ( tmp_unit_coord.c_str()) ) ;
518 err=MEDcoordLire(_medIdt,
519 const_cast <char *> (_ptrMesh->_name.c_str()),
520 _ptrMesh->_spaceDimension,
521 //const_cast <double *> ( _ptrMesh->_coordinate->_coordinate->get(MED_EN::MED_FULL_INTERLACE) ),
522 const_cast <double *> ( _ptrMesh->_coordinate->_coordinate.get(MED_EN::MED_FULL_INTERLACE) ),
523 med_2_2::MED_FULL_INTERLACE,
524 MED_ALL, // we read all the coordinates
525 NULL, // we don't use a profile
526 0, // so the profile's size is 0
527 &rep,tmp_nom,tmp_unit);
528 if (err != MED_VALID)
529 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't read coordinates of the |" << NumberOfNodes << "| nodes "
530 << "for the mesh : |" << _meshName
531 << "| of space dimension |" << SpaceDimension
532 << "| with units names |" << tmp_nom
533 << "| and units |" << tmp_unit
537 for (int i=0;i<_ptrMesh->_spaceDimension;i++) {
538 string myStringName(tmp_nom_coord,i*MED_TAILLE_PNOM22,MED_TAILLE_PNOM22) ;
539 string myStringUnit(tmp_unit_coord,i*MED_TAILLE_PNOM22,MED_TAILLE_PNOM22) ;
540 // suppress space at the end
542 for(j=MED_TAILLE_PNOM22-1;j>=0;j--)
543 if (myStringName[j] != ' ') break ;
544 _ptrMesh->_coordinate->_coordinateName[i]=string(myStringName,0,j+1);
545 for(j=MED_TAILLE_PNOM22-1;j>=0;j--)
546 if (myStringUnit[j] != ' ') break ;
547 _ptrMesh->_coordinate->_coordinateUnit[i]=string(myStringUnit,0,j+1);
550 // Pourquoi le stocker sous forme de chaîne ?
553 case med_2_2::MED_CART :
555 _ptrMesh->_coordinate->_coordinateSystem = "CARTESIAN";
558 case med_2_2::MED_CYL :
560 _ptrMesh->_coordinate->_coordinateSystem = "CYLINDRICAL";
563 case med_2_2::MED_SPHER :
565 _ptrMesh->_coordinate->_coordinateSystem = "SPHERICAL";
570 _ptrMesh->_coordinate->_coordinateSystem = "UNDEFINED"; // ?Erreur ?
575 // Read the unused optional node Names
576 char * tmp_node_name = new char[NumberOfNodes*MED_TAILLE_PNOM22+1];
577 tmp_node_name[NumberOfNodes]='\0' ;
578 err=MEDnomLire(_medIdt,const_cast <char*> (_ptrMesh->_name.c_str()),
579 tmp_node_name,NumberOfNodes*MED_TAILLE_PNOM22,med_2_2::MED_NOEUD,
580 (med_2_2::med_geometrie_element) MED_NONE);
581 if (err == MED_VALID)
582 MESSAGE(LOC<<"MED_MESH_RDONLY_DRIVER::getNoeuds() : WARNING : Nodes have names but we do not read them !");
583 delete[] tmp_node_name ;
586 // ??? Read the unused optional node Numbers ???
587 med_2_2::med_int * tmp_node_number = new med_2_2::med_int[NumberOfNodes] ;
588 err=MEDnumLire(_medIdt,const_cast <char*> (_ptrMesh->_name.c_str()),
589 tmp_node_number,NumberOfNodes,med_2_2::MED_NOEUD,(med_2_2::med_geometrie_element)0);
590 if (err == MED_VALID) {
591 // INFOS(LOC<<"WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING");
592 // INFOS(LOC<<"MED_MESH_RDONLY_DRIVER::getNoeuds() : WARNING : Nodes have numbers but we do not take care of them !");
593 // INFOS(LOC<<"WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING");
594 MESSAGE(LOC<<"MED_MESH_RDONLY_DRIVER::getNoeuds() : Nodes have numbers, we DO TAKE care of them !");
595 _ptrMesh->_coordinate->_nodeNumber.set(NumberOfNodes) ;
596 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
597 for(med_2_2::med_int i2=0;i2<NumberOfNodes;i2++)
598 _ptrMesh->_coordinate->_nodeNumber[i2]=(int)(tmp_node_number[i2]);
600 memcpy((int*)_ptrMesh->_coordinate->_nodeNumber,tmp_node_number,sizeof(int)*NumberOfNodes) ;
603 //////////////////////////////////////////////////////////////////////////////////////
604 /// Modification pour prise en compte de la numérotation optionnelle des noeuds ///
605 //////////////////////////////////////////////////////////////////////////////////////
607 /// Calcule _optionnalToCanonicNodesNumbers de telle sorte que _optionnalToCanonicNodesNumbers[OptionnalNumber]==CanonicNumber
609 // _ptrMesh->_arePresentOptionnalNodesNumbers=1;
610 // for (int canonicNumber=1;canonicNumber<=NumberOfNodes;canonicNumber++) _ptrMesh->_optionnalToCanonicNodesNumbers[tmp_node_number[canonicNumber-1]]=canonicNumber;
611 // ICI RETOUR A LA NORMALE::: AUCUNE PRISE EN COMPTE D'UN NUMEROTATION OPTIONNEL
612 _ptrMesh->_arePresentOptionnalNodesNumbers=0;
614 else _ptrMesh->_arePresentOptionnalNodesNumbers=0;
616 //////////////////////////////////////////////////////////////////////////////////////
618 delete[] tmp_node_number ;
627 int MED_MESH_RDONLY_DRIVER22::getCONNECTIVITY()
629 const char * LOC = "MED_MESH_RDONLY_DRIVER22::getCONNECTIVITY : " ;
632 if (_status==MED_OPENED)
636 // read MED_CELL connectivity
637 CONNECTIVITY * Connectivity = new CONNECTIVITY(MED_CELL) ;
638 Connectivity->_numberOfNodes = _ptrMesh->_numberOfNodes ; // EF : Pourquoi cet attribut est-il dans MESH et non dans COORDINATE ?
640 // Try to read nodal connectivity of the cells <Connectivity->_nodal>
641 // then try to read descending connectivity <Connectivity->_descending>
642 // if neither nodal nor descending connectivity exists
643 // throw an exception.
644 err = getNodalConnectivity(Connectivity) ;
647 Connectivity->_typeConnectivity = MED_DESCENDING ;
648 err = getDescendingConnectivity(Connectivity) ;
651 getDescendingConnectivity(Connectivity) ; // we read it if there is one
655 delete Connectivity ;
656 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "We could not read " <<
657 "any Connectivity")) ;
660 if (Connectivity->_entityDimension != _ptrMesh->_meshDimension)
661 MESSAGE(LOC << "Small mesh dimension problem on the med file mounted in memory : diim stored " << _ptrMesh->_meshDimension << " dim computed using the connectivity " << Connectivity->_entityDimension);
663 _ptrMesh->_meshDimension = Connectivity->_entityDimension ;
665 // At this point Connectivity->_typeConnectivity is either NODAL or DESCENDING
666 // If both connectivities are found Connectivity->_typeConnectivity is NODAL
667 // If space dimension is 3
668 // try to read the nodal connectivity of the faces <ConnectivityFace->_nodal> then
669 // try to read the descending connectivity <ConnectivityFace->_descending>
670 // if there is no descending connectivity and the CELLS are
671 // defined in descending mode then throw an exception
673 // PROVISOIRE : if we have some face or edge in MED_MAILLE, we don't read more. There could not be have face or edge !!!!
675 if(Connectivity->_constituent==NULL) {
677 SCRUTE(_ptrMesh->_meshDimension);
678 SCRUTE(Connectivity->_entityDimension);
679 if (_ptrMesh->_meshDimension == 3) {
680 MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DES FACES..." );
681 CONNECTIVITY * ConnectivityFace = new CONNECTIVITY(MED_EN::MED_FACE) ;
682 ConnectivityFace->_typeConnectivity = Connectivity->_typeConnectivity ; // NODAL or DESCENDING
683 SCRUTE(ConnectivityFace->_typeConnectivity);
684 if (Connectivity->_typeConnectivity == MED_DESCENDING) {
685 MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DESCENDANTE DES FACES" );
686 err = getDescendingConnectivity(ConnectivityFace) ;
688 throw MEDEXCEPTION ( LOCALIZED(STRING(LOC) << "No FACE in descending connectivity")) ;
689 getNodalConnectivity(ConnectivityFace) ; // if any !
691 MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE NODALE DES FACES" );
692 err = getNodalConnectivity(ConnectivityFace) ;
693 if (err!=MED_VALID) { // or error ????? we are in NODAL mode.
694 err = getDescendingConnectivity(ConnectivityFace) ;
696 getDescendingConnectivity(ConnectivityFace); // if any !
698 if (err!=MED_VALID) {
699 delete ConnectivityFace ;
700 MESSAGE(LOC<<"No FACE defined.") ;
702 MESSAGE(LOC<<" SAUVEGARDE DE LA CONNECTIVITE DES FACES DANS L'OBJET CONNECTIVITY" );
703 Connectivity->_constituent=ConnectivityFace ;
707 // read MED_EDGE connectivity
708 if (_ptrMesh->_meshDimension > 1) { // we are in 3 or 2D
709 MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DES ARRETES...." );
710 CONNECTIVITY * ConnectivityEdge = new CONNECTIVITY(MED_EDGE) ;
711 ConnectivityEdge->_typeConnectivity = Connectivity->_typeConnectivity ;
712 if (Connectivity->_typeConnectivity == MED_DESCENDING) {
713 MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DESCENDANTE DES ARRETES" );
714 err = getDescendingConnectivity(ConnectivityEdge) ;
716 throw MEDEXCEPTION ( LOCALIZED(STRING(LOC) << "No EDGE in descending connectivity")) ;
717 getNodalConnectivity(ConnectivityEdge) ; // if any !
719 MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE NODALE DES ARRETES" );
720 err = getNodalConnectivity(ConnectivityEdge) ;
721 if (err!=MED_VALID) { // or error ????? we are in NODAL mode.
722 err = getDescendingConnectivity(ConnectivityEdge) ;
724 getDescendingConnectivity(ConnectivityEdge) ; // if any !
726 if (err!=MED_VALID) {
727 delete ConnectivityEdge ;
728 MESSAGE(LOC<<"No EDGE defined.") ;
730 if (_ptrMesh->_meshDimension == 3)
731 if (Connectivity->_constituent != NULL)
732 Connectivity->_constituent->_constituent=ConnectivityEdge ;
734 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<< "EDGE defined but there are no FACE !")) ;
736 MESSAGE(LOC<<" SAUVEGARDE DE LA CONNECTIVITE DES ARETES DANS L'OBJET CONNECTIVITY" );
737 Connectivity->_constituent=ConnectivityEdge ;
742 _ptrMesh->_connectivity = Connectivity ;
746 // we have read all connectivity in file, now we must build descending connectivity if necessary !
748 // If connectivity descending is defined, we have nothing to do, all constituent are defined !
749 // If connectivity is only nodal, we must rebuild descending if we have some contituent !
752 // if (Connectivity->_descending == NULL)
753 // if (Connectivity->_constituent != NULL){
754 // // update Connectivity->_constituent
755 // CONNECTIVITY * myConstituentOld = Connectivity->_constituent ;
756 // Connectivity->_constituent = (CONNECTIVITY *)NULL ;
757 // Connectivity->calculateDescendingConnectivity() ;
767 int MED_MESH_RDONLY_DRIVER22::getNodalConnectivity(CONNECTIVITY * Connectivity)
769 const char * LOC = "MED_MESH_RDONLY_DRIVER22::getNodalConnectivity : " ;
772 int spaceDimension = _ptrMesh->_spaceDimension;
774 if (_status==MED_OPENED)
776 // Get the type of entity to work on (previously set in the Connectivity Object)
777 med_2_2::med_entite_maillage Entity = (med_2_2::med_entite_maillage) Connectivity->getEntity();
779 // Get the number of cells of each type & store it in <tmp_cells_count>.
780 int * tmp_cells_count = new int[MED_NBR_GEOMETRIE_MAILLE] ;
782 for (i=1;i<MED_NBR_GEOMETRIE_MAILLE;i++)
783 { // EF :ON SCANNE DES GEOMETRIES INUTILES, UTILISER LES MAPS
784 tmp_cells_count[i]=MEDnEntMaa(_medIdt,(const_cast <char *> (_ptrMesh->_name.c_str())),
785 med_2_2::MED_CONN,(med_2_2::med_entite_maillage) Entity,
786 all_cell_type[i],med_2_2::MED_NOD);
789 // Get the greatest dimension of the cells : Connectivity->_entityDimension
790 // We suppose there is no cells used as faces in MED 2.2.x , this is forbidden !!!
791 // In version prior to 2.2.x, it is possible
792 if (tmp_cells_count[i]>0)
794 Connectivity->_entityDimension=all_cell_type[i]/100;
795 Connectivity->_numberOfTypes++;
801 // begin classic geometric types
802 if (Connectivity->_numberOfTypes > 0)
804 // if MED version < 2.2.x, we read only entity with dimention = Connectivity->_entityDimension. Lesser dimension are face or edge !
806 med_int major, minor, release;
808 if ( med_2_2::MEDversionLire(_medIdt, &major, &minor, &release) != 0 )
810 // error : we suppose we have not a good med file !
811 delete[] tmp_cells_count ;
815 // we get MED version number
816 // If MED version is < 2.2 then the cells which dimension
817 // is lesser than the main dimension ( Connectivity->_entityDimension )
818 // are either faces or edges
820 // string medVersion(version_med);
822 int * tmpEdgeCount = new int[MED_NBR_GEOMETRIE_MAILLE] ;
823 tmpEdgeCount[0] = 0 ;
824 int numberOfEdgesTypes = 0;
825 int * tmpFaceCount = new int[MED_NBR_GEOMETRIE_MAILLE] ;
826 tmpFaceCount[0] = 0 ;
827 int numberOfFacesTypes = 0;
829 // if ((version_med != "2.2")&(Entity==MED_FR::MED_MAILLE))
831 // Connectivity->_numberOfTypes=0;
833 // for ( i=1;i<MED_NBR_GEOMETRIE_MAILLE;i++)
835 // tmpFaceCount[i]=0;
836 // tmpEdgeCount[i]=0;
837 // if (tmp_cells_count[i]!=0)
839 // int dimension = all_cell_type[i]/100 ;
840 // if (Connectivity->_entityDimension==dimension)
841 // Connectivity->_numberOfTypes++ ;
843 // if (dimension == 2)
844 // if (Connectivity->_entityDimension==3)
846 // tmpFaceCount[i]=tmp_cells_count[i] ;
847 // tmp_cells_count[i]=0 ;
848 // numberOfFacesTypes++;
850 // if (dimension == 1)
851 // if (Connectivity->_entityDimension>dimension)
853 // tmpEdgeCount[i]=tmp_cells_count[i] ;
854 // tmp_cells_count[i]=0;
855 // numberOfEdgesTypes++ ;
861 if (Entity==med_2_2::MED_MAILLE)
863 Connectivity->_numberOfTypes=0;
865 for ( i=1;i<MED_NBR_GEOMETRIE_MAILLE;i++)
869 if (tmp_cells_count[i]!=0)
871 int dimension = all_cell_type[i]/100 ;
872 if (Connectivity->_entityDimension==dimension)
873 Connectivity->_numberOfTypes++ ;
876 if (Connectivity->_entityDimension==3)
878 tmpFaceCount[i]=tmp_cells_count[i] ;
879 //tmp_cells_count[i]=0 ;
880 //Connectivity->_numberOfTypes++ ;
881 numberOfFacesTypes++;
884 if (Connectivity->_entityDimension>dimension)
886 tmpEdgeCount[i]=tmp_cells_count[i] ;
887 //tmp_cells_count[i]=0;
888 //Connectivity->_numberOfTypes++ ;
889 numberOfEdgesTypes++ ;
895 // bloc to read CELL :
897 // Prepare an array of indexes on the different cell types to create a MEDSKYLINEARRAY
898 // We use <tmp_cells_count> to calculate <Connectivity->_count> then we release it
899 Connectivity->_geometricTypes = new MED_EN::medGeometryElement [Connectivity->_numberOfTypes] ; // Double emploi pour des raisons pratiques
900 Connectivity->_type = new CELLMODEL [Connectivity->_numberOfTypes] ; //
901 Connectivity->_count = new int [Connectivity->_numberOfTypes+1] ;
902 Connectivity->_count[0] = 1;
907 for ( i=1;i<MED_NBR_GEOMETRIE_MAILLE;i++)
908 { // no point1 cell type (?)
909 int dimension = all_cell_type[i]/100 ;
910 if ((tmp_cells_count[i]>0) && (Connectivity->_entityDimension == dimension))
912 Connectivity->_count[typeNumber]=Connectivity->_count[typeNumber-1]+tmp_cells_count[i];
914 CELLMODEL t( (MED_EN::medGeometryElement) MED_MESH_DRIVER22::all_cell_type[i]) ;
916 Connectivity->_type[typeNumber-1] = t ;
918 Connectivity->_geometricTypes[typeNumber-1]=( MED_EN::medGeometryElement) MED_MESH_DRIVER22::all_cell_type[i] ;
920 // probleme avec les mailles de dimension < a dimension du maillage :
921 // Il faut oter le zero a la lecture est le remettre a l'ecriture : ce n'est pas fait !!!!! On interdit ce cas pour l'instant !!!
924 size+=tmp_cells_count[i]*((MED_MESH_DRIVER22::all_cell_type[i])%100) ;
927 << Connectivity->_count[typeNumber]-1 << " cells of type "
928 << all_cell_type_tab[i] );
933 // Creation of the MEDSKYLINEARRAY
934 //Connectivity->_nodal = new MEDSKYLINEARRAY(Connectivity->_count[Connectivity->_numberOfTypes]-1,size) ;
935 //int * NodalIndex = Connectivity->_nodal->getIndex() ;
936 int * NodalValue = new int[size] ;
937 int * NodalIndex = new int[Connectivity->_count[Connectivity->_numberOfTypes]] ;
940 // Fill the MEDSKYLINEARRAY by reading the MED file.
942 for ( i=0;i<Connectivity->_numberOfTypes;i++)
945 med_2_2::med_geometrie_element med_type = (med_2_2::med_geometrie_element) Connectivity->_type[i].getType() ;
946 // if ( Connectivity->_type[i].getDimension() < Connectivity->_entityDimension)
947 // if (Connectivity->_entity == MED_CELL)
948 // if ( Connectivity->_type[i].getDimension() < _ptrMesh->_spaceDimension)
951 // int NumberOfCell = Connectivity->_count[i+1]-Connectivity->_count[i] ;
952 int NumberOfNodeByCell = Connectivity->_type[i].getNumberOfNodes() ;
955 for ( j=Connectivity->_count[i]; j<Connectivity->_count[i+1];j++)
956 NodalIndex[j]=NodalIndex[j-1]+NumberOfNodeByCell ;
958 int tmp_numberOfCells = Connectivity->_count[i+1]-Connectivity->_count[i] ;
959 int * tmp_ConnectivityArray = new int[(NumberOfNodeByCell+multi)*tmp_numberOfCells];
961 // int err=MEDconnLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
962 // Connectivity->_entityDimension,tmp_ConnectivityArray,
963 // MED_FR::MED_FULL_INTERLACE,NULL,0,Entity,med_type,MED_FR::MED_NOD);
964 int err=MEDconnLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
965 spaceDimension,tmp_ConnectivityArray,
966 med_2_2::MED_FULL_INTERLACE,NULL,0,Entity,med_type,med_2_2::MED_NOD);
968 if ( err != MED_VALID)
970 delete[] tmp_ConnectivityArray;
971 delete[] tmp_cells_count;
972 delete[] tmpFaceCount;
973 delete[] tmpEdgeCount;
974 MESSAGE(LOC<<": MEDconnLire returns "<<err) ;
978 int * ConnectivityArray = NodalValue + NodalIndex[Connectivity->_count[i]-1]-1 ;
980 // version originale sans prise en compte des numéros optionnels
982 for ( j=0; j<tmp_numberOfCells; j++) for (int k=0; k<NumberOfNodeByCell; k++)
983 ConnectivityArray[j*NumberOfNodeByCell+k]=tmp_ConnectivityArray[j*(NumberOfNodeByCell+multi)+k] ;
985 //////////////////////////////////////////////////////////////////////////////
986 // Modification pour prise en compte de la numérotation optionnelle des noeuds ///
987 //////////////////////////////////////////////////////////////////////////////
989 // Rénumérote le tableau temporaire tmp_ConnectivityArray en utilisant _optionnalToCanonicNodesNumbers
990 // Le traitement est identique à la version originelle s'il n'y a pas de numérotation optionnelle
992 // if (_ptrMesh->_arePresentOptionnalNodesNumbers==1)
994 // for ( j=0; j<tmp_numberOfCells; j++) for (int k=0; k<NumberOfNodeByCell; k++)
995 // ConnectivityArray[j*NumberOfNodeByCell+k]=_ptrMesh->_optionnalToCanonicNodesNumbers[tmp_ConnectivityArray[j*(NumberOfNodeByCell+multi)+k]] ;
999 // for ( j=0; j<tmp_numberOfCells; j++) for (int k=0; k<NumberOfNodeByCell; k++)
1000 // ConnectivityArray[j*NumberOfNodeByCell+k]=tmp_ConnectivityArray[j*(NumberOfNodeByCell+multi)+k] ;
1002 ////////////////////////////////////////////////////////////////////////////
1004 delete[] tmp_ConnectivityArray;
1008 Connectivity->_nodal = new MEDSKYLINEARRAY(Connectivity->_count[Connectivity->_numberOfTypes]-1,
1013 delete[] NodalIndex;
1014 delete[] NodalValue;
1016 } // end of bloc to read CELL
1022 if (numberOfFacesTypes!=0)
1025 // Create a CONNECTIVITY constituent to put in the top level CONNECTIVITY recursive class
1026 CONNECTIVITY * constituent = new CONNECTIVITY(numberOfFacesTypes,MED_EN::MED_FACE) ;
1027 constituent->_entityDimension = 2 ;
1028 constituent->_count[0]=1 ;
1030 // In order to create the MEDSKYLINEARRAY of the constituent object we need :
1032 // To initialize the _count array of the constituent object (containning cumulated face count by geometric type)
1033 // _count[0]=1 and _count[_numberOfTypes] give the size of NodalIndex
1035 // To calculate the total number of face nodes whatever the geometric type is.
1036 // The result is the size of the array containning all the nodes : NodalValue
1038 // To calculate the starting indexes of the different face types in NodalValue,
1039 // this is the NodalIndex array.
1042 int typeNumber = 1 ;
1044 for ( i=1; i < MED_NBR_GEOMETRIE_MAILLE; i++)
1045 { // no point1 cell type (?)
1046 if (tmpFaceCount[i]>0)
1048 constituent->_count[typeNumber] = constituent->_count[typeNumber-1] + tmpFaceCount[i];
1049 CELLMODEL t( (MED_EN::medGeometryElement) MED_MESH_DRIVER22::all_cell_type[i]) ;
1050 constituent->_type[typeNumber-1]=t ;
1052 constituent->_geometricTypes[typeNumber-1]=( MED_EN::medGeometryElement) MED_MESH_DRIVER22::all_cell_type[i] ;
1054 size+=tmpFaceCount[i]*((MED_MESH_DRIVER22::all_cell_type[i])%100) ;
1059 // Creation of the MEDSKYLINEARRAY
1060 //constituent->_nodal = new MEDSKYLINEARRAY(constituent->_count[constituent->_numberOfTypes]-1,size) ;
1061 //int * NodalIndex = constituent->_nodal->getIndex() ;
1062 int * NodalValue = new int[size] ;
1063 int * NodalIndex = new int[constituent->_count[constituent->_numberOfTypes]] ;
1066 // Fill the MEDSKYLINEARRAY by reading the MED file.
1067 for ( i=0; i<constituent->_numberOfTypes; i++)
1069 med_2_2::med_geometrie_element med_type = (med_2_2::med_geometrie_element) constituent->_type[i].getType() ;
1071 int NumberOfNodeByFace = constituent->_type[i].getNumberOfNodes() ;
1073 // initialise NodalIndex
1074 for (int j=constituent->_count[i]; j<constituent->_count[i+1];j++)
1075 NodalIndex[j]=NodalIndex[j-1]+NumberOfNodeByFace ;
1077 int tmp_numberOfFaces = constituent->_count[i+1]-constituent->_count[i] ;
1078 // Il faut ajouter 1 pour le zero a la lecture !!!
1079 // ATTENTION UNIQUEMENT POUR MED < 2.2.x
1080 int * tmp_constituentArray = NULL;
1082 MESSAGE(LOC << "Med file version used here " << major << " " << minor << " " << release);
1084 if ((major == 2) && (minor <= 1))
1085 tmp_constituentArray = new int[(NumberOfNodeByFace+1)*tmp_numberOfFaces] ;
1086 else if ((major == 2) && (minor >= 2))
1088 tmp_constituentArray = new int[NumberOfNodeByFace*tmp_numberOfFaces] ;
1089 MESSAGE(LOC<<": WE ARE USING MED2.2 so there is no +1 for calculating the size of tmp_constituentArray !") ;
1092 int err=MEDconnLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
1093 Connectivity->_entityDimension,tmp_constituentArray,
1094 med_2_2::MED_FULL_INTERLACE,NULL,0,med_2_2::MED_MAILLE,med_type,med_2_2::MED_NOD);
1096 if ( err != MED_VALID)
1098 MESSAGE(LOC<<": MEDconnLire returns "<<err) ;
1099 delete constituent ;
1100 delete[] tmp_constituentArray;
1101 delete[] tmpFaceCount;
1102 delete[] tmpEdgeCount;
1106 int * constituentArray = NodalValue + NodalIndex[constituent->_count[i]-1]-1 ;
1108 // version originale sans prise en compte des numéros optionnels
1110 int multi = 0; // quand est-ce que multi vaut 1 ?? en MED-fichier < 2.2 ??
1111 MESSAGE(LOC << "Med file version used here " << major << " " << minor << " " << release);
1113 if ((major == 2) && (minor <= 1))
1114 for (int j=0; j<tmp_numberOfFaces; j++)
1115 for (int k=0; k<NumberOfNodeByFace; k++)
1116 constituentArray[j*NumberOfNodeByFace+k]=tmp_constituentArray[j*(NumberOfNodeByFace+1)+k] ;
1117 else if ((major == 2) && (minor >= 2))
1118 for (int j=0; j<tmp_numberOfFaces; j++)
1119 for (int k=0; k<NumberOfNodeByFace; k++)
1120 constituentArray[j*NumberOfNodeByFace+k]=tmp_constituentArray[j*(NumberOfNodeByFace+multi)+k] ;
1122 //////////////////////////////////////////////////////////////////////////////////////
1123 /// Modification pour prise en compte de la numérotation optionnelle des noeuds ///
1124 //////////////////////////////////////////////////////////////////////////////////////
1126 /// Rénumérote le tableau temporaire tmp_constituentArray en utilisant _optionnalToCanonicNodesNumbers
1127 /// Le traitement est identique à la version originelle s'il n'y a pas de numérotation optionnelle
1129 // if (_ptrMesh->_arePresentOptionnalNodesNumbers)
1131 // for (int j=0; j<tmp_numberOfFaces; j++) for (int k=0; k<NumberOfNodeByFace; k++)
1132 // constituentArray[j*NumberOfNodeByFace+k]=_ptrMesh->_optionnalToCanonicNodesNumbers[tmp_constituentArray[j*(NumberOfNodeByFace+1)+k]] ;
1136 // for (int j=0; j<tmp_numberOfFaces; j++) for (int k=0; k<NumberOfNodeByFace; k++)
1137 // constituentArray[j*NumberOfNodeByFace+k]=tmp_constituentArray[j*(NumberOfNodeByFace+1)+k] ;
1140 //////////////////////////////////////////////////////////////////////////////////////
1142 delete[] tmp_constituentArray;
1145 constituent->_nodal = new MEDSKYLINEARRAY(constituent->_count[constituent->_numberOfTypes]-1,
1149 delete[] NodalIndex ;
1150 delete[] NodalValue ;
1153 Connectivity->_constituent = constituent ;
1156 delete[] tmpFaceCount;
1161 if (numberOfEdgesTypes!=0)
1163 CONNECTIVITY * constituent = new CONNECTIVITY(numberOfEdgesTypes,MED_EDGE) ;
1164 constituent->_entityDimension = 1 ;
1165 constituent->_count[0]=1 ;
1169 // if you declare a variable <i> in two <for> initialization statement,
1170 // compiler gcc2.95.3 says nothing but there are two <i> variables in the same block
1171 //and the value you get in the common block seems to be the value of the first variable !
1174 for ( i=1; i<MED_NBR_GEOMETRIE_MAILLE; i++)
1175 { // no point1 cell type (?)
1176 if (tmpEdgeCount[i]>0)
1179 constituent->_count[typeNumber]=constituent->_count[typeNumber-1]+tmpEdgeCount[i];
1180 CELLMODEL t( (MED_EN::medGeometryElement) MED_MESH_DRIVER22::all_cell_type[i]) ;
1181 constituent->_type[typeNumber-1]=t ;
1183 constituent->_geometricTypes[typeNumber-1]=( MED_EN::medGeometryElement) MED_MESH_DRIVER22::all_cell_type[i] ;
1185 size+=tmpEdgeCount[i]*((MED_MESH_DRIVER22::all_cell_type[i])%100) ;
1190 // Creation of the MEDSKYLINEARRAY
1191 //constituent->_nodal = new MEDSKYLINEARRAY(constituent->_count[constituent->_numberOfTypes]-1,size) ;
1192 //int * NodalIndex = constituent->_nodal->getIndex() ;
1193 int * NodalValue = new int[size] ;
1194 int * NodalIndex = new int[constituent->_count[constituent->_numberOfTypes]] ;
1197 // Fill the MEDSKYLINEARRAY by reading the MED file.
1198 for ( i=0; i<constituent->_numberOfTypes; i++)
1200 med_2_2::med_geometrie_element med_type = (med_2_2::med_geometrie_element) constituent->_type[i].getType() ;
1202 int NumberOfNodeByEdge = constituent->_type[i].getNumberOfNodes() ;
1205 for (int j=constituent->_count[i]; j<constituent->_count[i+1];j++)
1206 NodalIndex[j]=NodalIndex[j-1]+NumberOfNodeByEdge ;
1208 int tmp_numberOfEdges = constituent->_count[i+1]-constituent->_count[i] ;
1209 // Il faut ajouter 1 pour le zero a la lecture !!!
1211 // ATTENTION UNIQUEMENT POUR MED < 2.2.x
1212 int * tmp_constituentArray = NULL;
1214 MESSAGE(LOC << "Med file version used here " << major << " " << minor << " " << release);
1216 if ((major == 2) && (minor <= 1))
1217 tmp_constituentArray = new int[(NumberOfNodeByEdge+1)*tmp_numberOfEdges] ;
1218 else if ((major == 2) && (minor >= 2))
1220 tmp_constituentArray = new int[NumberOfNodeByEdge*tmp_numberOfEdges] ;
1221 MESSAGE(LOC<<": WE ARE USING MED2.2 so there is no +1 for calculating the size of tmp_constituentArray !") ;
1224 int err=MEDconnLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
1225 spaceDimension,tmp_constituentArray,
1226 med_2_2::MED_FULL_INTERLACE,NULL,0,med_2_2::MED_MAILLE,med_type,med_2_2::MED_NOD);
1227 if ( err != MED_VALID)
1229 MESSAGE(LOC<<": MEDconnLire returns "<<err) ;
1230 delete constituent ;
1231 delete[] tmp_constituentArray;
1232 delete[] tmpEdgeCount;
1236 int * constituentArray = NodalValue + NodalIndex[constituent->_count[i]-1]-1 ;
1238 // version originale sans prise en compte des numéros optionnels
1240 int multi = 0; // quand est-ce que multi vaut 1 ?? en MED-fichier < 2.2 ??
1241 MESSAGE(LOC << "Med file version used here " << major << " " << minor << " " << release);
1243 if ((major == 2) && (minor <= 1))
1244 for (int j=0; j<tmp_numberOfEdges; j++)
1245 for (int k=0; k<NumberOfNodeByEdge; k++)
1246 constituentArray[j*NumberOfNodeByEdge+k]=tmp_constituentArray[j*(NumberOfNodeByEdge+multi)+k] ;
1247 else if ((major == 2) && (minor >= 2))
1248 for (int j=0; j<tmp_numberOfEdges; j++)
1249 for (int k=0; k<NumberOfNodeByEdge; k++)
1250 constituentArray[j*NumberOfNodeByEdge+k]=tmp_constituentArray[j*(NumberOfNodeByEdge)+k] ;
1252 //////////////////////////////////////////////////////////////////////////////////////
1253 /// Modification pour prise en compte de la numérotation optionnelle des noeuds ///
1254 //////////////////////////////////////////////////////////////////////////////////////
1256 /// Rénumérote le tableau temporaire tmp_constituentArray en utilisant _optionnalToCanonicNodesNumbers
1257 /// Le traitement est identique à la version originelle s'il n'y a pas de numérotation optionnelle
1259 // if (_ptrMesh->_arePresentOptionnalNodesNumbers)
1261 // for (int j=0; j<tmp_numberOfEdges; j++) for (int k=0; k<NumberOfNodeByEdge; k++)
1262 // constituentArray[j*NumberOfNodeByEdge+k]=_ptrMesh->_optionnalToCanonicNodesNumbers[tmp_constituentArray[j*(NumberOfNodeByEdge+1)+k]] ;
1266 // for (int j=0; j<tmp_numberOfEdges; j++) for (int k=0; k<NumberOfNodeByEdge; k++)
1267 // constituentArray[j*NumberOfNodeByEdge+k]=tmp_constituentArray[j*(NumberOfNodeByEdge+1)+k] ;
1270 //////////////////////////////////////////////////////////////////////////////////////
1272 delete[] tmp_constituentArray;
1275 constituent->_nodal = new MEDSKYLINEARRAY(constituent->_count[constituent->_numberOfTypes]-1,
1280 delete[] NodalIndex ;
1281 delete[] NodalValue ;
1283 if (Connectivity->_entityDimension == 3)
1285 if (Connectivity->_constituent==NULL)
1286 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Edges are defined but there are no Faces !"));
1287 Connectivity->_constituent->_constituent = constituent ;
1289 Connectivity->_constituent = constituent ;
1292 delete[] tmpEdgeCount;
1295 } // end classic geometric types
1296 delete[] tmp_cells_count;
1300 // Lecture des polygones MED_CELL
1301 int NumberOfPolygons = MEDnEntMaa(_medIdt,
1302 const_cast <char *> (_ptrMesh->_name.c_str()),
1305 med_2_2::MED_POLYGONE,
1307 if (NumberOfPolygons > 0)
1309 if (Connectivity->_entityDimension == 1)
1310 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"In a 2D mesh, polygons need at least one 2D cell of a classic geometric type !"));
1311 med_int ConnectivitySize;
1312 med_err err1 = MEDpolygoneInfo(_medIdt,
1313 const_cast <char *> (_ptrMesh->_name.c_str()),
1317 if (err1 != MED_VALID)
1319 MESSAGE(LOC<<": MEDpolygoneInfo returns "<<err1);
1323 med_int* PolygonsConnectivity = new med_int[ConnectivitySize];
1324 med_int* PolygonsConnectivityIndex = new med_int[NumberOfPolygons+1];
1326 med_err err2 = MEDpolygoneConnLire(_medIdt,
1327 const_cast <char *> (_ptrMesh->_name.c_str()),
1328 PolygonsConnectivityIndex,
1330 PolygonsConnectivity,
1333 if (err2 != MED_VALID)
1335 MESSAGE(LOC<<": MEDpolygoneConnLire returns "<<err2);
1339 if (Connectivity->_entityDimension == 2) // 2D mesh : polygons in Connectivity
1340 Connectivity->setPolygonsConnectivity(MED_NODAL,(medEntityMesh) Entity,PolygonsConnectivity,PolygonsConnectivityIndex,ConnectivitySize,NumberOfPolygons);
1341 else if (Connectivity->_entityDimension == 3)
1343 if (Connectivity->_constituent == NULL) // 3D mesh : polygons in Connectivity->_constituent
1344 Connectivity->_constituent = new CONNECTIVITY(MED_FACE);
1345 Connectivity->_constituent->setPolygonsConnectivity(MED_NODAL,MED_FACE,PolygonsConnectivity,PolygonsConnectivityIndex,ConnectivitySize,NumberOfPolygons);
1348 delete[] PolygonsConnectivity;
1349 delete[] PolygonsConnectivityIndex;
1354 // Lecture des polyedres MED_CELL
1355 med_int NumberOfPolyhedron = MEDnEntMaa(_medIdt,
1356 const_cast <char *> (_ptrMesh->_name.c_str()),
1359 med_2_2::MED_POLYEDRE,
1361 if (NumberOfPolyhedron > 0)
1363 if (Connectivity->_entityDimension == 2 || Connectivity->_entityDimension == 1)
1364 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"In a 3D mesh, polyhedron need at least one 3D cell of a classic geometric type !"));
1365 med_int FacesIndexSize, NumberOfNodes, NumberOfFaces;
1366 med_err err3 = MEDpolyedreInfo(_medIdt,
1367 const_cast <char *> (_ptrMesh->_name.c_str()),
1371 NumberOfFaces = FacesIndexSize-1;
1372 if (err3 != MED_VALID)
1374 MESSAGE(LOC<<": MEDpolyhedreInfo returns "<<err3);
1378 med_int* Nodes = new med_int[NumberOfNodes];
1379 med_int* FacesIndex = new med_int[NumberOfFaces+1];
1380 med_int* PolyhedronIndex = new med_int[NumberOfPolyhedron+1];
1382 med_err err4 = MEDpolyedreConnLire(_medIdt,
1383 const_cast <char *> (_ptrMesh->_name.c_str()),
1385 NumberOfPolyhedron+1,
1390 if (err4 != MED_VALID)
1392 MESSAGE(LOC<<": MEDpolyedreConnLire returns "<<err4);
1396 Connectivity->setPolyhedronConnectivity(MED_NODAL,Nodes,PolyhedronIndex,NumberOfNodes,NumberOfPolyhedron,FacesIndex,NumberOfFaces);
1399 delete[] FacesIndex;
1400 delete[] PolyhedronIndex;
1405 // If there is no nodal connectivity, we return MED_ERROR !
1406 if (Connectivity->_numberOfTypes == 0 && NumberOfPolygons == 0 && NumberOfPolyhedron == 0)
1415 int MED_MESH_RDONLY_DRIVER22::getFAMILY()
1417 const char * LOC = "MED_MESH_RDONLY_DRIVER22::getFAMILY() : " ;
1420 if (_status==MED_OPENED)
1424 int * MEDArrayNodeFamily = NULL ;
1425 int ** MEDArrayCellFamily = NULL ;
1426 int ** MEDArrayFaceFamily = NULL ;
1427 int ** MEDArrayEdgeFamily = NULL ;
1430 MEDArrayNodeFamily = new int[_ptrMesh->getNumberOfNodes()] ;
1432 err = getNodesFamiliesNumber(MEDArrayNodeFamily) ;
1433 // error only if (_status!=MED_OPENED), other case exeception !
1436 MESSAGE(LOC << "error returned from getNodesFamiliesNumber " << err);
1438 MEDArrayCellFamily = new int* [_ptrMesh->getNumberOfTypesWithPoly(MED_CELL)] ;
1439 // ET SI IL N'Y A PAS DE CELLS ?
1441 medGeometryElement * myTypes = _ptrMesh->getTypesWithPoly(MED_CELL);
1442 for (int i=0;i<_ptrMesh->getNumberOfTypesWithPoly(MED_CELL);i++)
1443 MEDArrayCellFamily[i] = new
1444 int[_ptrMesh->getNumberOfElementsWithPoly(MED_CELL,myTypes[i])] ;
1446 err = getCellsFamiliesNumber(MEDArrayCellFamily,
1447 _ptrMesh->_connectivity,MED_CELL) ;
1450 MESSAGE(LOC << "error returned from getCellsFamiliesNumber for Cells " << err);
1452 if (_ptrMesh->_connectivity->_constituent != NULL)
1454 if (_ptrMesh->_connectivity->_constituent->_entity == MED_EN::MED_FACE)
1457 MEDArrayFaceFamily = new
1458 int* [_ptrMesh->getNumberOfTypesWithPoly(MED_FACE)] ;
1460 myTypes = _ptrMesh->getTypesWithPoly(MED_FACE);
1461 for (int i=0;i<_ptrMesh->getNumberOfTypesWithPoly(MED_FACE);i++)
1462 MEDArrayFaceFamily[i] = new
1463 int[_ptrMesh->getNumberOfElementsWithPoly(MED_FACE,myTypes[i])] ;
1466 getCellsFamiliesNumber(MEDArrayFaceFamily,
1467 _ptrMesh->_connectivity->_constituent,MED_FACE) ;
1469 MESSAGE(LOC << "error returned from getCellsFamiliesNumber for Faces " << err);
1474 MEDArrayEdgeFamily = new
1475 int* [_ptrMesh->getNumberOfTypes(MED_EDGE)] ;
1477 const medGeometryElement *myTypes2 = _ptrMesh->getTypes(MED_EDGE);
1478 for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_EDGE);i++)
1479 MEDArrayEdgeFamily[i] = new
1480 int[_ptrMesh->getNumberOfElements(MED_EDGE,myTypes2[i])] ;
1483 getCellsFamiliesNumber(MEDArrayEdgeFamily,
1484 _ptrMesh->_connectivity->_constituent,MED_FACE) ;
1486 MESSAGE(LOC << "error returned from getCellsFamiliesNumber for Edges in 2D " << err);
1489 if (_ptrMesh->_connectivity->_constituent->_constituent != NULL)
1491 MEDArrayEdgeFamily = new
1492 int* [_ptrMesh->getNumberOfTypes(MED_EDGE)] ;
1494 const medGeometryElement *myTypes2 = _ptrMesh->getTypes(MED_EDGE);
1495 for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_EDGE);i++)
1496 MEDArrayEdgeFamily[i] = new
1497 int[_ptrMesh->getNumberOfElements(MED_EDGE,myTypes2[i])] ;
1500 getCellsFamiliesNumber(MEDArrayEdgeFamily,
1501 _ptrMesh->_connectivity->_constituent->_constituent,MED_EDGE);
1504 MESSAGE(LOC << "error returned from getCellsFamiliesNumber for Edges in 3D " << err);
1509 int NumberOfFamilies = med_2_2::MEDnFam(_medIdt, const_cast <char *>
1510 (_meshName.c_str())) ;
1512 if ( NumberOfFamilies < 1 ) // at least family 0 must exist
1513 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"There is no FAMILY, FAMILY 0 must exists" ));
1515 SCRUTE(NumberOfFamilies);
1517 vector<FAMILY*> &NodeFamilyVector = _ptrMesh->_familyNode ;
1518 vector<FAMILY*> &CellFamilyVector = _ptrMesh->_familyCell ;
1519 vector<FAMILY*> &FaceFamilyVector = _ptrMesh->_familyFace ;
1520 vector<FAMILY*> &EdgeFamilyVector = _ptrMesh->_familyEdge ;
1522 int numberOfNodesFamilies = 0 ;
1523 int numberOfCellsFamilies = 0 ;
1524 int numberOfFacesFamilies = 0 ;
1525 int numberOfEdgesFamilies = 0 ;
1527 for (int i=0;i<NumberOfFamilies;i++)
1529 int NumberOfAttributes = med_2_2::MEDnAttribut(_medIdt,
1531 (_meshName.c_str()),
1534 if (NumberOfAttributes < 0)
1535 throw MEDEXCEPTION("MED_MESH_RDONLY_DRIVER22::getFAMILY() : NumberOfAttributes" );
1537 int NumberOfGroups = med_2_2::MEDnGroupe(_medIdt, const_cast <char *>
1538 (_meshName.c_str()),(i+1)) ;
1540 if (NumberOfGroups < 0)
1541 throw MEDEXCEPTION("MED_MESH_RDONLY_DRIVER22::getFAMILY() : NumberOfGroups" );
1543 int FamilyIdentifier ;
1544 string FamilyName(MED_TAILLE_NOM,'\0');
1545 int * AttributesIdentifier = new int[NumberOfAttributes] ;
1546 int * AttributesValues = new int[NumberOfAttributes] ;
1547 string AttributesDescription(MED_TAILLE_DESC*NumberOfAttributes,' ') ;
1548 string GroupsNames(MED_TAILLE_LNOM*NumberOfGroups+1,'\0') ;
1549 err = med_2_2::MEDfamInfo(_medIdt,const_cast <char *>
1550 (_meshName.c_str()),
1551 (i+1),const_cast <char *>
1552 (FamilyName.c_str()), &FamilyIdentifier,
1553 AttributesIdentifier,AttributesValues,
1555 (AttributesDescription.c_str()),
1556 &NumberOfAttributes, const_cast <char *>
1557 (GroupsNames.c_str()),&NumberOfGroups);
1560 SCRUTE(GroupsNames);
1565 if (err != MED_VALID)
1566 throw MEDEXCEPTION("MED_MESH_RDONLY_DRIVER22::getFAMILY() : ERROR when get FAMILY informations" );
1568 if (FamilyIdentifier != 0 )
1570 FAMILY * Family = new FAMILY(_ptrMesh,FamilyIdentifier,FamilyName,
1572 AttributesIdentifier,
1574 AttributesDescription,
1575 NumberOfGroups,GroupsNames,
1579 MEDArrayEdgeFamily) ;
1582 // if nothing found, delete Family
1584 if (Family->getNumberOfTypes() == 0)
1586 MESSAGE(LOC<<"Nothing found for family "<<FamilyName<<
1591 switch (Family->getEntity())
1593 case MED_EN::MED_NODE :
1594 NodeFamilyVector.push_back(Family) ;
1595 numberOfNodesFamilies++ ;
1597 case MED_EN::MED_CELL :
1598 CellFamilyVector.push_back(Family) ;
1599 numberOfCellsFamilies++ ;
1601 case MED_EN::MED_FACE :
1602 FaceFamilyVector.push_back(Family) ;
1603 numberOfFacesFamilies++ ;
1605 case MED_EN::MED_EDGE :
1606 EdgeFamilyVector.push_back(Family) ;
1607 numberOfEdgesFamilies++ ;
1610 // MESSAGE(LOC << (*Family));
1613 delete [] AttributesIdentifier ;
1614 delete [] AttributesValues ;
1617 if (MEDArrayNodeFamily != NULL)
1618 delete[] MEDArrayNodeFamily ;
1620 if (MEDArrayCellFamily != NULL)
1622 for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_CELL);i++)
1623 delete[] MEDArrayCellFamily[i] ;
1624 delete[] MEDArrayCellFamily ;
1627 if (MEDArrayFaceFamily != NULL)
1629 for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_FACE);i++)
1630 delete[] MEDArrayFaceFamily[i] ;
1631 delete[] MEDArrayFaceFamily ;
1634 if (MEDArrayEdgeFamily != NULL)
1636 for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_EDGE);i++)
1637 delete[] MEDArrayEdgeFamily[i] ;
1638 delete[] MEDArrayEdgeFamily ;
1648 int MED_MESH_RDONLY_DRIVER22::getNodesFamiliesNumber(int * MEDArrayNodeFamily)
1650 const char * LOC = "MED_MESH_RDONLY_DRIVER22::getNodesFamiliesNumber() : " ;
1654 if (_status==MED_OPENED)
1658 err = MEDfamLire(_medIdt, const_cast <char *>
1659 (_ptrMesh->_name.c_str()), MEDArrayNodeFamily,
1660 _ptrMesh->getNumberOfNodes(), med_2_2::MED_NOEUD,
1661 (med_2_2::med_geometrie_element) MED_NONE);
1663 if ( err != MED_VALID)
1664 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "There is no family for the |"<< _ptrMesh->getNumberOfNodes() << "| nodes in mesh |" << _ptrMesh->_name.c_str() << "|"));
1673 int MED_MESH_RDONLY_DRIVER22::getCellsFamiliesNumber(int **MEDArrayFamily,
1674 CONNECTIVITY *Connectivity,
1675 MED_EN::medEntityMesh entity)
1677 const char * LOC = "MED_MESH_RDONLY_DRIVER22::getCellsFamiliesNumber " ;
1681 if (_status==MED_OPENED)
1684 MED_EN::medGeometryElement *types=Connectivity->getGeometricTypesWithPoly(Connectivity->_entity);
1685 for (i=0;i<Connectivity->getNumberOfTypesWithPoly(Connectivity->_entity);i++)
1687 int NumberOfCell=Connectivity->getNumberOfElementsWithPoly(Connectivity->_entity,types[i]);
1688 err=MEDfamLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
1689 MEDArrayFamily[i],NumberOfCell,
1690 (med_2_2::med_entite_maillage) Connectivity->_entity,
1691 (med_2_2::med_geometrie_element)types[i]);
1692 if (err != MED_VALID)
1694 err=MEDfamLire(_medIdt,const_cast <char *>
1695 (_ptrMesh->_name.c_str()),
1696 MEDArrayFamily[i],NumberOfCell,
1697 med_2_2::MED_MAILLE,
1698 (med_2_2::med_geometrie_element)types[i]);
1699 if (err != MED_VALID)
1700 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Family not found for entity "<<Connectivity->_entity<<" and geometric type "<<Connectivity->_geometricTypes[i]));
1709 /*--------------------- WRONLY PART -------------------------------*/
1711 MED_MESH_WRONLY_DRIVER22::MED_MESH_WRONLY_DRIVER22()
1715 MED_MESH_WRONLY_DRIVER22::MED_MESH_WRONLY_DRIVER22(const string & fileName,
1717 MED_MESH_DRIVER22(fileName,ptrMesh,MED_WRONLY),IMED_MESH_WRONLY_DRIVER(fileName,ptrMesh),MED_MESH_DRIVER(fileName,ptrMesh,MED_WRONLY)
1719 MESSAGE("MED_MESH_WRONLY_DRIVER22::MED_MESH_WRONLY_DRIVER22(const string & fileName, MESH * ptrMesh) has been created");
1722 MED_MESH_WRONLY_DRIVER22::MED_MESH_WRONLY_DRIVER22(const MED_MESH_WRONLY_DRIVER22 & driver):
1723 IMED_MESH_WRONLY_DRIVER(driver),MED_MESH_DRIVER22(driver),MED_MESH_DRIVER(driver)
1727 MED_MESH_WRONLY_DRIVER22::~MED_MESH_WRONLY_DRIVER22()
1729 //MESSAGE("MED_MESH_WRONLY_DRIVER22::MED_MESH_WRONLY_DRIVER22(const string & fileName, MESH * ptrMesh) has been destroyed");
1732 GENDRIVER * MED_MESH_WRONLY_DRIVER22::copy(void) const
1734 return new MED_MESH_WRONLY_DRIVER22(*this);
1737 void MED_MESH_WRONLY_DRIVER22::write(void) const
1739 const char * LOC = "void MED_MESH_WRONLY_DRIVER22::write(void) const : ";
1742 // we must first create mesh !!
1743 MESSAGE(LOC << "MeshName : |" << _meshName << "| FileName : |"<<_fileName<<"| MedIdt : | "<< _medIdt << "|");
1745 if (_status!=MED_OPENED)
1746 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "File "<<_fileName<<" is not open. Open it before write !"));
1748 if (_ptrMesh->getIsAGrid())
1750 if ( writeGRID() != MED_VALID )
1751 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeGRID()" )) ;
1755 if (writeCoordinates()!=MED_VALID)
1756 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeCoordinates()" )) ;
1758 if (writeConnectivities(MED_EN::MED_CELL)!=MED_VALID)
1759 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeConnectivities(MED_CELL)" )) ;
1760 if (writeConnectivities(MED_EN::MED_FACE)!=MED_VALID)
1761 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeConnectivities(MED_FACE)" )) ;
1762 if (writeConnectivities(MED_EN::MED_EDGE)!=MED_VALID)
1763 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeConnectivities(MED_EDGE)" )) ;
1766 if (writeFamilyNumbers() !=MED_VALID)
1767 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilyNumbers()" )) ;
1770 // well we must first write zero family :
1771 if (_status==MED_OPENED) {
1773 // test if the family already exists (HDF trick waiting a MED evolution to be replaced)
1774 string dataGroupFam = "/ENS_MAA/"+_meshName+"/FAS/FAMILLE_ZERO/";
1775 MESSAGE("|"<<dataGroupFam<<"|");
1776 err =med_2_2::_MEDdatagroupOuvrir(_medIdt,const_cast <char *> (dataGroupFam.c_str()) );
1777 if ( err < MED_VALID ) {
1780 char familyName[MED_TAILLE_NOM+1];
1781 // strcpy(familyName,"FAMILLE_ZERO");
1782 err = med_2_2::MEDfamCr( _medIdt,
1783 const_cast <char *> ( _meshName.c_str() ),
1785 (int*)NULL, (int*)NULL, (char*)NULL, 0,
1790 if ( err != MED_VALID)
1791 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't create family |FAMILLE_ZERO| with identifier |0| groups names || and attributes descriptions ||")) ;
1794 med_2_2::_MEDdatagroupFermer(_medIdt);
1798 MESSAGE(LOC<<"writeFamilies(_ptrMesh->_familyNode)");
1799 if (writeFamilies(_ptrMesh->_familyNode) !=MED_VALID)
1800 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilies(_ptrMesh->_familyNode)" )) ;
1802 MESSAGE(LOC<<"writeFamilies(_ptrMesh->_familyCell)");
1803 if (writeFamilies(_ptrMesh->_familyCell) !=MED_VALID)
1804 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilies(_ptrMesh->_familyCell)" )) ;
1806 MESSAGE(LOC<<"writeFamilies(_ptrMesh->_familyFace)");
1807 if (writeFamilies(_ptrMesh->_familyFace) !=MED_VALID)
1808 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilies(_ptrMesh->_familyFace)" )) ;
1810 MESSAGE(LOC<<"writeFamilies(_ptrMesh->_familyEdge)");
1811 if (writeFamilies(_ptrMesh->_familyEdge) !=MED_VALID)
1812 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilies(_ptrMesh->_familyEdge)" )) ;
1817 //=======================================================================
1818 //function : writeGRID
1820 //=======================================================================
1822 int MED_MESH_WRONLY_DRIVER22::writeGRID() const
1824 const char * LOC = "MED_MESH_WRONLY_DRIVER22::writeGRID() : " ;
1827 if (_status!=MED_OPENED)
1829 MESSAGE (LOC<<" Not open !!!");
1832 GRID * ptrGrid = (GRID*) _ptrMesh;
1834 med_2_2::med_err err = MED_ERROR;
1835 med_2_2::med_repere rep;
1836 string tmp_name(_ptrMesh->_spaceDimension*MED_TAILLE_PNOM22,' ');
1837 string tmp_unit(_ptrMesh->_spaceDimension*MED_TAILLE_PNOM22,' ');
1839 // Test if the mesh <_meshName> already exists
1840 // If it doesn't exists create it
1841 // If it already exists verify if its space and mesh dimensions are the same
1842 // as <_ptrMesh->_spaceDimension>, <_ptrMesh->_meshDimension> respectively
1843 // rem : <_meshName> is the driver meshName not <ptrMesh->_meshName>
1845 int spaceDimension = med_2_2::MEDdimEspaceLire(_medIdt, const_cast <char *>
1846 (_meshName.c_str()) );
1848 int meshDimension = med_2_2::MEDdimLire(_medIdt, const_cast <char *>
1849 (_meshName.c_str()) );
1852 MESSAGE(LOC << "spacedim " << spaceDimension << " meshdim " << meshDimension);
1854 MESSAGE(LOC << "From the mesh spacedim " << _ptrMesh->_spaceDimension << " meshdim " << _ptrMesh->_meshDimension);
1856 if ((spaceDimension <= MED_VALID) && (meshDimension <= MED_VALID))
1858 err = MEDmaaCr(_medIdt,
1859 const_cast <char *> (_meshName.c_str()),
1860 _ptrMesh->_meshDimension,med_2_2::MED_STRUCTURE,
1861 const_cast <char *> (_ptrMesh->_description.c_str()));
1863 meshDimension = _ptrMesh->_meshDimension;
1865 if (err != MED_VALID)
1866 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Unable to create Grid"));
1868 MESSAGE(LOC<<"Grid "<<_meshName<<" created in file "<<_fileName<<" !");
1870 else if ((spaceDimension != _ptrMesh->_spaceDimension) &&
1871 (meshDimension != _ptrMesh->_meshDimension))
1872 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Grid |" << _meshName.c_str() <<
1873 "| already exists in file |" << _fileName <<
1874 "| with space dimension |" << spaceDimension <<
1875 "| and mesh dimension |" << meshDimension <<
1876 "| but the space dimension and the mesh dimension of the mesh we want to write are respectively |"
1877 << _ptrMesh->_spaceDimension <<"|" <<
1878 _ptrMesh->_meshDimension <<"|" )) ;
1880 MED_EN::med_grid_type gridType = ptrGrid->getGridType();
1882 err = med_2_2::MEDnatureGrilleEcr(_medIdt,
1883 const_cast <char *> (_meshName.c_str()),
1884 (med_2_2::med_type_grille) gridType);
1886 if (err != MED_VALID)
1887 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Unable to write the type of the Grid"));
1889 // Recompose the <_spaceDimension> strings in 1 string
1891 string valueString ;
1892 for (int i=0;i<_ptrMesh->_spaceDimension;i++) {
1894 valueString = _ptrMesh->_coordinate->_coordinateName[i] ;
1895 lengthString = (MED_TAILLE_PNOM22<valueString.size())?MED_TAILLE_PNOM22:valueString.size() ;
1896 tmp_name.replace(i*MED_TAILLE_PNOM22,i*MED_TAILLE_PNOM22+lengthString,valueString,0,lengthString);
1897 valueString = _ptrMesh->_coordinate->_coordinateUnit[i];
1898 lengthString = (MED_TAILLE_PNOM22<valueString.size())?MED_TAILLE_PNOM22:valueString.size() ;
1899 tmp_unit.replace(i*MED_TAILLE_PNOM22,i*MED_TAILLE_PNOM22+lengthString,valueString,0,lengthString);
1902 // Pourquoi le stocker sous forme de chaîne ?
1903 const string & coordinateSystem = _ptrMesh->_coordinate->_coordinateSystem;
1904 if (coordinateSystem == "CARTESIAN")
1905 rep = med_2_2::MED_CART;
1906 else if ( coordinateSystem == "CYLINDRICAL")
1907 rep = med_2_2::MED_CYL;
1908 else if ( coordinateSystem == "SPHERICAL" )
1909 rep = med_2_2::MED_SPHER;
1911 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Grid |" << _meshName.c_str() <<
1912 "| doesn't have a valid coordinate system : |"
1913 << _ptrMesh->_coordinate->_coordinateSystem
1916 med_2_2::med_int ArrayLen[] = { (med_2_2::med_int) ptrGrid->_iArrayLength,
1917 (med_2_2::med_int) ptrGrid->_jArrayLength,
1918 (med_2_2::med_int) ptrGrid->_kArrayLength };
1920 // Write node coordinates for MED_BODY_FITTED grid
1921 if (gridType == MED_EN::MED_BODY_FITTED)
1923 // Write Coordinates and families
1924 // double * coo = const_cast <double *>
1925 // (_ptrMesh->_coordinate->getCoordinates(MED_EN::MED_FULL_INTERLACE));
1927 err = MEDcoordEcr(_medIdt, const_cast <char *> (_meshName.c_str()),
1928 _ptrMesh->_spaceDimension,
1929 //const_cast <double *> ( _ptrMesh->_coordinate->_coordinate->get(MED_EN::MED_FULL_INTERLACE) ),
1930 const_cast <double *> ( _ptrMesh->_coordinate->_coordinate.get(MED_EN::MED_FULL_INTERLACE) ),
1931 med_2_2::MED_FULL_INTERLACE, _ptrMesh->_numberOfNodes,
1932 // _ptrMesh->_coordinate->_numberOfNodes
1933 rep, const_cast <char *> (tmp_name.c_str()),
1934 const_cast <char *> (tmp_unit.c_str()));
1936 if (err != MED_VALID)
1937 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write coordinates of the grid |" << _meshName.c_str() << "| in file |" << _fileName
1938 << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
1939 << " with units names |" << tmp_name
1940 << "| and units |" << tmp_unit
1943 int* structure = new int [meshDimension];
1945 for (int idim = 0; idim < meshDimension; ++idim)
1946 structure[idim] = ArrayLen [idim];
1949 err = med_2_2::MEDstructureCoordEcr(_medIdt, const_cast <char *>
1950 (_meshName.c_str()), meshDimension,
1953 if (err != MED_VALID)
1954 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"error in writing the structure of the grid |" << _meshName.c_str()));
1958 else if ((gridType == MED_EN::MED_CARTESIAN) ||
1959 (gridType == MED_EN::MED_POLAR))
1961 // Write Arrays of Cartesian or Polar Grid
1963 double * Array[] = { ptrGrid->_iArray,
1967 for (int idim = 0; idim < _ptrMesh->_meshDimension; ++idim)
1969 string str_name = string (tmp_name,idim*MED_TAILLE_PNOM22,
1971 string str_unit = string (tmp_unit,idim*MED_TAILLE_PNOM22,
1974 err = med_2_2::MEDindicesCoordEcr(_medIdt, const_cast <char *>
1975 (_ptrMesh->_name.c_str()),
1976 _ptrMesh->_meshDimension,
1977 Array[idim], ArrayLen[idim],
1978 (idim+1), const_cast <char *>
1981 (str_unit.c_str()));
1983 if (err != MED_VALID)
1984 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<
1985 "Can't write grid coordinates for " <<
1986 idim << "-th dimention"));
1988 } // end Write Cartesian or Polar Grid
1994 //=======================================================================
1995 //function : writeCoordinates
1997 //=======================================================================
1999 int MED_MESH_WRONLY_DRIVER22::writeCoordinates() const {
2001 const char * LOC = "int MED_MESH_WRONLY_DRIVER22::writeCoordinates() const : ";
2004 med_2_2::med_err err = MED_ERROR;
2005 med_2_2::med_repere rep;
2006 string tmp_name(_ptrMesh->_spaceDimension*MED_TAILLE_PNOM22,' ');
2007 string tmp_unit(_ptrMesh->_spaceDimension*MED_TAILLE_PNOM22,' ');
2009 // Recompose the <_spaceDimension> strings in 1 string
2011 string valueString ;
2012 for (int i=0;i<_ptrMesh->_spaceDimension;i++) {
2013 valueString = _ptrMesh->_coordinate->_coordinateName[i] ;
2014 lengthString = (MED_TAILLE_PNOM22<valueString.size())?MED_TAILLE_PNOM22:valueString.size() ;
2015 tmp_name.replace(i*MED_TAILLE_PNOM22,i*MED_TAILLE_PNOM22+lengthString,valueString,0,lengthString);
2016 valueString = _ptrMesh->_coordinate->_coordinateUnit[i];
2017 lengthString = (MED_TAILLE_PNOM22<valueString.size())?MED_TAILLE_PNOM22:valueString.size() ;
2018 tmp_unit.replace(i*MED_TAILLE_PNOM22,i*MED_TAILLE_PNOM22+lengthString,valueString,0,lengthString);
2021 // Test if the mesh <_meshName> already exists
2022 // If it doesn't exists create it
2023 // If it already exists verify if its space and mesh dimensions are the same
2024 // as <_ptrMesh->_spaceDimension>, <_ptrMesh->_meshDimension> respectively
2025 // rem : <_meshName> is the driver meshName not <ptrMesh->_meshName>
2027 int spaceDimension = med_2_2::MEDdimEspaceLire(_medIdt, const_cast <char *>
2028 (_meshName.c_str()));
2030 int meshDimension = med_2_2::MEDdimLire(_medIdt, const_cast <char *>
2031 (_meshName.c_str()) );
2033 if ((spaceDimension != MED_VALID) && (meshDimension != MED_VALID))
2035 err = MEDmaaCr(_medIdt, const_cast <char *> (_meshName.c_str()),
2036 _ptrMesh->_meshDimension, med_2_2::MED_NON_STRUCTURE,
2037 const_cast <char *> (_ptrMesh->_description.c_str()));
2039 if (err != MED_VALID)
2040 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Unable to create Mesh : |" << _meshName << "|"));
2042 MESSAGE(LOC<<"Mesh "<<_meshName<<" created in file "<<_fileName<<" !");
2044 else if ((spaceDimension != _ptrMesh->_spaceDimension) &&
2045 (meshDimension != _ptrMesh->_meshDimension))
2046 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Mesh |" << _meshName.c_str() <<
2047 "| already exists in file |" << _fileName <<
2048 "| with space dimension |" << spaceDimension <<
2049 "| and mesh dimension |" << meshDimension <<
2050 "| but the space dimension and the mesh dimension of the mesh we want to write are respectively |"
2051 << _ptrMesh->_spaceDimension <<"|" <<
2052 _ptrMesh->_meshDimension << "|")) ;
2054 // Pourquoi le stocker sous forme de chaîne ?
2055 const string & coordinateSystem = _ptrMesh->_coordinate->_coordinateSystem;
2056 if (coordinateSystem == "CARTESIAN")
2057 rep = med_2_2::MED_CART;
2058 else if ( coordinateSystem == "CYLINDRICAL")
2059 rep = med_2_2::MED_CYL;
2060 else if ( coordinateSystem == "SPHERICAL" )
2061 rep = med_2_2::MED_SPHER;
2063 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Mesh |" << _meshName.c_str() << "| doesn't have a valid coordinate system : |"
2064 << _ptrMesh->_coordinate->_coordinateSystem
2067 // err = MEDcoordEcr(_medIdt, const_cast <char *> (_meshName.c_str()),
2068 // _ptrMesh->_spaceDimension,
2069 // //const_cast <double *> ( _ptrMesh->_coordinate->_coordinate->get(MED_EN::MED_FULL_INTERLACE) ),
2070 // const_cast <double *> ( _ptrMesh->_coordinate->_coordinate.get(MED_EN::MED_FULL_INTERLACE) ),
2071 // MED_FR::MED_FULL_INTERLACE,
2072 // _ptrMesh->_numberOfNodes, // _ptrMesh->_coordinate->_numberOfNodes
2073 // MED_FR::MED_LECTURE_ECRITURE,
2075 // const_cast <char *> (tmp_name.c_str()),
2076 // const_cast <char *> (tmp_unit.c_str())
2079 err = MEDcoordEcr(_medIdt, const_cast <char *> (_meshName.c_str()),
2080 _ptrMesh->_spaceDimension,
2081 //const_cast <double *> ( _ptrMesh->_coordinate->_coordinate->get(MED_EN::MED_FULL_INTERLACE) ),
2082 const_cast <double *> ( _ptrMesh->_coordinate->_coordinate.get(MED_EN::MED_FULL_INTERLACE) ),
2083 med_2_2::MED_FULL_INTERLACE, _ptrMesh->_numberOfNodes,
2084 // _ptrMesh->_coordinate->_numberOfNodes
2085 rep, const_cast <char *> (tmp_name.c_str()),
2086 const_cast <char *> (tmp_unit.c_str()));
2089 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write coordinates of mesh |" << _meshName.c_str() << "| in file |" << _fileName
2090 << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
2091 << " with units names |" << tmp_name
2092 << "| and units |" << tmp_unit
2096 //////////////////////////////////////////////////////////////////////////////////////
2097 /// Modification pour prise en compte de la numérotation optionnelle des noeuds ///
2098 //////////////////////////////////////////////////////////////////////////////////////
2100 /// Ecrit les numéros optionnels des noeuds
2101 /// Le traitement est identique à la version originelle s'il n'y a pas de numérotation optionnelle
2104 if (_ptrMesh->_arePresentOptionnalNodesNumbers==1) {
2106 err = MEDnumEcr(_medIdt, const_cast <char *> (_meshName.c_str()),
2107 const_cast <med_int *> (_ptrMesh->_coordinate->getNodesNumbers() ),
2108 _ptrMesh->_numberOfNodes, med_2_2::MED_NOEUD,
2109 med_2_2::med_geometrie_element(0) );
2111 if (err != MED_VALID)
2112 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write optionnal numbers of mesh |" <<
2113 _meshName.c_str() << "| in file |" <<
2114 _fileName << " |")) ;
2116 //////////////////////////////////////////////////////////////////////////////////////
2126 int MED_MESH_WRONLY_DRIVER22::writeConnectivities(medEntityMesh entity) const
2128 const char * LOC="int MED_MESH_WRONLY_DRIVER22::writeConnectivities() const : ";
2131 med_2_2::med_err err;
2133 // REM SI LA METHODE EST APPELEE DIRECTEMENT ET QUE LE MAILLAGE N'EST PAS CREE IL Y A PB !
2134 // PG : IMPOSSIBLE : LA METHODE EST PRIVEE !
2136 // A FAIRE : A tester surtout dans les methodes de MESH.
2137 // if ( _ptrMesh->_connectivity == (CONNECTIVITY *) MED_INVALID )
2138 if ( _ptrMesh->_connectivity == (CONNECTIVITY *) NULL )
2139 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The connectivity is not defined in the MESH object ")) ;
2142 // Nodal connectivity for classic geometric types
2143 if ( _ptrMesh->existConnectivity(MED_NODAL,entity) )
2146 int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ;
2147 const medGeometryElement * types = _ptrMesh->getTypes (entity) ;
2149 for (int i=0; i<numberOfTypes; i++)
2152 int numberOfElements = _ptrMesh->getNumberOfElements (entity,types[i]);
2153 const int * connectivity = _ptrMesh->getConnectivity (MED_EN::MED_FULL_INTERLACE,
2154 MED_NODAL, entity, types[i]); // ?? et SI MED_NODAL n'existe pas, recalcul auto ??
2156 // Pour l'instant la class utilise le multi.....
2158 // if (entity==MED_EN::MED_CELL)
2159 // if ( (types[i]/ 100) < _ptrMesh->_spaceDimension)
2161 int numberOfNodes = types[i]%100 ;
2162 int * connectivityArray = new int[numberOfElements*(numberOfNodes+multi)];
2164 // version originale sans prise en compte des numéros optionnels
2166 for (int j=0 ; j<numberOfElements; j++)
2168 for (int k=0; k<numberOfNodes; k++)
2169 connectivityArray[j*(numberOfNodes+multi)+k]=connectivity[j*numberOfNodes+k] ;
2171 if (multi>0) connectivityArray[j*(numberOfNodes+multi)+numberOfNodes]=0;
2174 //////////////////////////////////////////////////////////////////////////////////////
2175 /// Modification pour prise en compte de la numérotation optionnelle des noeuds ///
2176 //////////////////////////////////////////////////////////////////////////////////////
2178 /// Dénumérote les sommets des mailles pour leur rendre leurs numéros optionnels
2179 /// Le traitement est identique à la version originelle s'il n'y a pas de numérotation optionnelle
2181 // if (_ptrMesh->_arePresentOptionnalNodesNumbers==1)
2183 // const int * nodesNumbers = _ptrMesh->_coordinate->getNodesNumbers();
2184 // for (int j=0 ; j<numberOfElements; j++)
2186 // for (int k=0; k<numberOfNodes; k++) connectivityArray[j*(numberOfNodes+multi)+k]=nodesNumbers[connectivity[j*numberOfNodes+k]-1] ;
2187 // if (multi>0) connectivityArray[j*(numberOfNodes+multi)+numberOfNodes]=0;
2192 // for (int j=0 ; j<numberOfElements; j++)
2194 // for (int k=0; k<numberOfNodes; k++) connectivityArray[j*(numberOfNodes+multi)+k]=connectivity[j*numberOfNodes+k] ;
2195 // if (multi>0) connectivityArray[j*(numberOfNodes+multi)+numberOfNodes]=0;
2199 //////////////////////////////////////////////////////////////////////////////////////
2201 // err = MEDconnEcr( _medIdt, const_cast <char *> ( _meshName.c_str()), _ptrMesh->_spaceDimension,
2202 // connectivityArray, MED_FR::MED_FULL_INTERLACE , numberOfElements,
2203 // MED_FR::MED_LECTURE_ECRITURE,
2204 // (MED_FR::med_entite_maillage ) entity,
2205 // (MED_FR::med_geometrie_element) types[i], MED_FR::MED_NOD );
2207 // err = MEDconnEcr(_medIdt, const_cast <char *> ( _meshName.c_str()),
2208 // _ptrMesh->_spaceDimension, connectivityArray,
2209 // MED_FR::MED_FULL_INTERLACE , numberOfElements,
2210 // (MED_FR::med_entite_maillage ) entity,
2211 // (MED_FR::med_geometrie_element) types[i],
2212 // med_2_2::MED_NOD);
2214 err = MEDconnEcr(_medIdt, const_cast <char *> ( _meshName.c_str()),
2215 _ptrMesh->_spaceDimension, connectivityArray,
2216 med_2_2::MED_FULL_INTERLACE , numberOfElements,
2217 (med_2_2::med_entite_maillage ) MED_CELL,
2218 (med_2_2::med_geometrie_element) types[i],
2221 delete[] connectivityArray ;
2223 if (err<0) // ETENDRE LES EXPLICATIONS
2224 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write connectivities of mesh |" << _meshName.c_str() << "| in file |" << _fileName
2225 << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
2233 if (_ptrMesh->existPolygonsConnectivity(MED_NODAL,entity))
2235 err = MEDpolygoneConnEcr(_medIdt,
2236 const_cast <char *> (_meshName.c_str()),
2237 const_cast <med_int*> (_ptrMesh->getPolygonsConnectivityIndex(MED_NODAL,entity)),
2238 _ptrMesh->getNumberOfPolygons()+1,
2239 const_cast <med_int*> (_ptrMesh->getPolygonsConnectivity(MED_NODAL,entity)),
2240 (med_2_2::med_entite_maillage) entity,
2244 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write polygons nodal connectivities of mesh |" << _meshName.c_str() << "| in file |" << _fileName
2245 << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
2250 // Polyhedron writing
2251 if (_ptrMesh->existPolyhedronConnectivity(MED_NODAL,entity))
2253 err = MEDpolyedreConnEcr(_medIdt,
2254 const_cast <char *> (_meshName.c_str()),
2255 const_cast <med_int*> (_ptrMesh->getPolyhedronIndex(MED_NODAL)),
2256 _ptrMesh->getNumberOfPolyhedron()+1,
2257 const_cast <med_int*> (_ptrMesh->getPolyhedronFacesIndex()),
2258 _ptrMesh->getNumberOfPolyhedronFaces()+1,
2259 const_cast <med_int*> (_ptrMesh->getPolyhedronConnectivity(MED_NODAL)),
2263 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write polyhedron nodal connectivities of mesh |" << _meshName.c_str() << "| in file |" << _fileName
2264 << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
2269 // Descending connectivity for classic geometric types
2270 if ( _ptrMesh->existConnectivity(MED_DESCENDING,entity) )
2273 int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ;
2274 const medGeometryElement * types = _ptrMesh->getTypes (entity) ;
2276 for (int i=0; i<numberOfTypes; i++)
2279 int numberOfElements = _ptrMesh->getNumberOfElements (entity,types[i]);
2280 const int * connectivity = _ptrMesh->getConnectivity(MED_EN::MED_FULL_INTERLACE, MED_DESCENDING, entity, types[i]);
2282 // Pour l'instant la class utilise le multi.....
2283 // err = MED_FR::MEDconnEcr( _medIdt,
2284 // const_cast <char *> ( _meshName.c_str()),
2285 // _ptrMesh->_spaceDimension,
2286 // const_cast <int *> (connectivity),
2287 // MED_FR::MED_FULL_INTERLACE,
2288 // numberOfElements,
2289 // MED_FR::MED_LECTURE_ECRITURE,
2290 // (MED_FR::med_entite_maillage ) entity,
2291 // (MED_FR::med_geometrie_element) types[i],
2292 // MED_FR::MED_DESC );
2294 err = med_2_2::MEDconnEcr(_medIdt,
2295 const_cast <char *> ( _meshName.c_str()),
2296 _ptrMesh->_spaceDimension,
2297 const_cast <int *> (connectivity),
2298 med_2_2::MED_FULL_INTERLACE,
2300 (med_2_2::med_entite_maillage ) entity,
2301 (med_2_2::med_geometrie_element) types[i],
2302 med_2_2::MED_DESC );
2304 if (err<0) // ETENDRE LES EXPLICATIONS
2305 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write connectivities of mesh |" << _meshName.c_str() << "| in file |" << _fileName
2306 << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
2314 if (_ptrMesh->existPolygonsConnectivity(MED_DESCENDING,entity))
2316 err = MEDpolygoneConnEcr(_medIdt,
2317 const_cast <char *> (_meshName.c_str()),
2318 const_cast <med_int*> (_ptrMesh->getPolygonsConnectivityIndex(MED_DESCENDING,entity)),
2319 _ptrMesh->getNumberOfPolygons()+1,
2320 const_cast <med_int*> (_ptrMesh->getPolygonsConnectivity(MED_DESCENDING,entity)),
2321 (med_2_2::med_entite_maillage) entity,
2325 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write polygons descending connectivities of mesh |" << _meshName.c_str() << "| in file |" << _fileName
2326 << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
2331 // Polyhedron writing
2332 if (_ptrMesh->existPolyhedronConnectivity(MED_DESCENDING,entity))
2334 med_int NumberOfFaces = _ptrMesh->getPolyhedronIndex(MED_DESCENDING)[_ptrMesh->getNumberOfPolyhedron()]-1;
2335 vector<med_int> FacesGeometricTypes(NumberOfFaces,MED_POLYGON); // by default all polyhedron faces are polygons
2337 err = MEDpolyedreConnEcr(_medIdt,
2338 const_cast <char *> (_meshName.c_str()),
2339 const_cast <med_int*> (_ptrMesh->getPolyhedronIndex(MED_DESCENDING)),
2340 _ptrMesh->getNumberOfPolyhedron()+1,
2341 &FacesGeometricTypes[0],
2343 const_cast <med_int*> (_ptrMesh->getPolyhedronConnectivity(MED_DESCENDING)),
2347 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write polyhedron descending connectivities of mesh |" << _meshName.c_str() << "| in file |" << _fileName
2348 << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
2357 int MED_MESH_WRONLY_DRIVER22::writeFamilyNumbers() const {
2359 const char * LOC="int MED_MESH_WRONLY_DRIVER22::writeFamilyNumbers() const : ";
2362 med_2_2::med_err err;
2364 // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArrayNodeFamily DOIT ETRE ENLEVER DE LA CLASSE MESH
2366 { // Node related block
2368 // We build the array from the families list objects :
2369 int NumberOfNodes = _ptrMesh->getNumberOfNodes() ;
2370 int * MEDArrayNodeFamily = new int[NumberOfNodes] ;
2371 // family 0 by default
2372 for (int i=0; i<NumberOfNodes; i++)
2373 MEDArrayNodeFamily[i]=0;
2374 //vector<FAMILY*> myFamilies = _ptrMesh->getFamilies(MED_NODE);
2375 vector<FAMILY*> * myFamilies = &_ptrMesh->_familyNode;
2376 int NumberOfNodesFamilies = myFamilies->size() ;
2377 //bool ToDestroy = false;
2378 if (0 == NumberOfNodesFamilies) {
2379 //ToDestroy = true ;
2380 vector<GROUP*> myGroups = _ptrMesh->getGroups(MED_NODE);
2381 int NumberOfGroups = myGroups.size() ;
2382 // build families from groups
2383 for (int i=0; i<NumberOfGroups; i++) {
2384 SUPPORT * mySupport = myGroups[i] ;
2385 FAMILY* myFamily = new FAMILY(*mySupport);
2386 myFamily->setIdentifier(i+1);
2387 myFamilies->push_back(myFamily);
2389 NumberOfNodesFamilies=myFamilies->size() ;
2391 for (int i=0 ; i<NumberOfNodesFamilies; i++) {
2393 //SCRUTE(myFamilies[i]->getName());
2394 int FamilyIdentifier = (*myFamilies)[i]->getIdentifier() ;
2395 int TotalNumber = (*myFamilies)[i]->getNumberOfElements(MED_ALL_ELEMENTS) ;
2396 if ((*myFamilies)[i]->isOnAllElements())
2397 for (int j=0; j<TotalNumber; j++)
2398 MEDArrayNodeFamily[j]=FamilyIdentifier;
2400 const int * Number = (*myFamilies)[i]->getNumber(MED_ALL_ELEMENTS) ;
2401 for (int j=0; j<TotalNumber; j++)
2402 MEDArrayNodeFamily[Number[j]-1]=FamilyIdentifier ;
2406 for(int j=0; j<NumberOfNodes; j++) {
2407 SCRUTE(MEDArrayNodeFamily[j]);
2410 // if ( !_ptrMesh->getIsAGrid() )
2412 err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
2413 MEDArrayNodeFamily, NumberOfNodes, med_2_2::MED_NOEUD,
2414 (med_2_2::med_geometrie_element) MED_NONE);
2417 // err = MEDfamGridEcr(_medIdt,
2418 // const_cast <char *> (_ptrMesh->_name.c_str()),
2419 // MEDArrayNodeFamily,
2421 // MED_FR::MED_LECTURE_ECRITURE,
2422 // MED_FR::MED_NOEUD);
2424 if ( err != MED_VALID)
2425 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write node family for the |"<< NumberOfNodes
2426 << "| nodes in mesh |"
2427 << _ptrMesh->_name.c_str() << "|" ));
2428 delete[] MEDArrayNodeFamily;
2429 //if (true == ToDestroy)
2430 // for (int i=0; i<NumberOfNodesFamilies; i++)
2431 // delete myFamilies[i];
2434 { // CELLS RELATED BLOCK
2435 medEntityMesh entity=MED_EN::MED_CELL;
2436 // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArray____Family DOIT ETRE ENLEVER DE LA CLASSE MESH
2437 if ( ( _ptrMesh->existConnectivity(MED_NODAL,entity) )|( _ptrMesh->existConnectivity(MED_DESCENDING,entity) ) ) {
2439 int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ;
2440 const medGeometryElement * types = _ptrMesh->getTypes (entity) ;
2442 // We build the array from the families list objects :
2443 int NumberOfElements = _ptrMesh->getNumberOfElements(entity, MED_ALL_ELEMENTS);
2444 int * MEDArrayFamily = new int[NumberOfElements] ;
2445 // family 0 by default
2446 for (int i=0; i<NumberOfElements; i++)
2447 MEDArrayFamily[i]=0;
2448 //vector<FAMILY*> myFamilies = _ptrMesh->getFamilies(entity);
2449 vector<FAMILY*> * myFamilies = &_ptrMesh->_familyCell ;
2450 int NumberOfFamilies = myFamilies->size() ;
2451 //bool ToDestroy = false;
2452 if (0 == NumberOfFamilies) {
2453 //ToDestroy = true ;
2454 vector<GROUP*> myGroups = _ptrMesh->getGroups(entity);
2455 int NumberOfGroups = myGroups.size() ;
2456 // build families from groups
2457 for (int i=0; i<NumberOfGroups; i++) {
2458 SCRUTE( myGroups[i]->getName() );
2459 SUPPORT * mySupport = myGroups[i] ;
2460 FAMILY* myFamily = new FAMILY(*mySupport);
2461 myFamily->setIdentifier(-i-1);
2462 myFamilies->push_back(myFamily);
2464 NumberOfFamilies=myFamilies->size() ;
2466 for (int i=0 ; i<NumberOfFamilies; i++) {
2467 int FamilyIdentifier = (*myFamilies)[i]->getIdentifier() ;
2468 int TotalNumber = (*myFamilies)[i]->getNumberOfElements(MED_ALL_ELEMENTS) ;
2469 if ((*myFamilies)[i]->isOnAllElements())
2470 for (int ii=0; ii<TotalNumber; ii++)
2471 MEDArrayFamily[ii]=FamilyIdentifier;
2473 const int * Number = (*myFamilies)[i]->getNumber(MED_ALL_ELEMENTS) ;
2474 for (int ii=0; ii<TotalNumber; ii++)
2475 MEDArrayFamily[Number[ii]-1]=FamilyIdentifier ;
2479 const int * typeCount = _ptrMesh->getGlobalNumberingIndex(entity) ;
2480 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
2481 int lgth=NumberOfElements;
2482 med_2_2::med_int *temp=new med_2_2::med_int[lgth];
2483 for(int i2=0;i2<lgth;i2++)
2484 temp[i2]=(med_2_2::med_int) (MEDArrayFamily[i2]);
2486 for (int i=0; i<numberOfTypes; i++) {
2487 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
2488 err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
2489 temp+typeCount[i]-1,typeCount[i+1]-typeCount[i],
2491 (med_2_2::med_entite_maillage) entity,
2492 (med_2_2::med_geometrie_element) types[i]
2495 err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
2496 (MEDArrayFamily+typeCount[i]-1),
2497 (typeCount[i+1]-typeCount[i]),
2498 (med_2_2::med_entite_maillage) entity,
2499 (med_2_2::med_geometrie_element) types[i]);
2502 if ( err != MED_VALID)
2503 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write family for the |"<< _ptrMesh->getNumberOfElements(entity, types[i])
2504 << "| cells of geometric type |" << geoNames[types[i]] <<"|in mesh |"
2505 << _ptrMesh->_name.c_str() << "|" ));
2507 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
2510 delete[] MEDArrayFamily ;
2511 //if (true == ToDestroy) {
2512 // int NumberOfFamilies = myFamilies->size();
2513 // for (int i=0; i<NumberOfFamilies; i++)
2514 // delete myFamilies[i];
2519 { // FACE RELATED BLOCK
2520 medEntityMesh entity=MED_EN::MED_FACE;
2521 // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArray____Family DOIT ETRE ENLEVER DE LA CLASSE MESH
2522 if ( ( _ptrMesh->existConnectivity(MED_NODAL,entity) )|( _ptrMesh->existConnectivity(MED_DESCENDING,entity) ) ) {
2524 int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ;
2525 const medGeometryElement * types = _ptrMesh->getTypes (entity) ;
2526 SCRUTE(numberOfTypes);
2528 int numberOfElements = _ptrMesh->getNumberOfElements(entity, MED_ALL_ELEMENTS) ;
2529 int * familyArray = new int[numberOfElements] ;
2530 for (int i=0;i<numberOfElements;i++)
2533 int numberOfFamilies = _ptrMesh->getNumberOfFamilies(entity) ;
2534 //vector<FAMILY*> myFamilies = _ptrMesh->getFamilies(entity) ;
2535 vector<FAMILY*> * myFamilies = &_ptrMesh->_familyFace ;
2536 //bool ToDestroy = false;
2537 if (0 == numberOfFamilies) {
2538 //ToDestroy = true ;
2539 vector<GROUP*> myGroups = _ptrMesh->getGroups(entity);
2540 int NumberOfGroups = myGroups.size() ;
2541 // build families from groups
2542 for (int i=0; i<NumberOfGroups; i++) {
2543 SCRUTE( myGroups[i]->getName() );
2544 SUPPORT * mySupport = myGroups[i] ;
2545 FAMILY* myFamily = new FAMILY(*mySupport);
2546 myFamily->setIdentifier(-i-1000);
2547 myFamilies->push_back(myFamily);
2549 numberOfFamilies=myFamilies->size() ;
2551 for (int i=0;i<numberOfFamilies;i++) {
2552 int familyNumber = (*myFamilies)[i]->getIdentifier() ;
2553 int numberOfFamilyElements = (*myFamilies)[i]->getNumberOfElements(MED_ALL_ELEMENTS) ;
2554 if ((*myFamilies)[i]->isOnAllElements())
2555 for (int ii=0; ii<numberOfFamilyElements; ii++)
2556 familyArray[ii]=familyNumber;
2558 const int * myFamilyElements = (*myFamilies)[i]->getNumber(MED_ALL_ELEMENTS) ;
2559 for (int ii=0;ii<numberOfFamilyElements;ii++)
2560 familyArray[myFamilyElements[ii]-1]=familyNumber;
2564 const int * typeCount = _ptrMesh->getGlobalNumberingIndex(entity) ;
2565 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
2566 int lgth=numberOfElements;
2567 med_2_2::med_int *temp=new med_2_2::med_int[lgth];
2568 for(int i2=0;i2<lgth;i2++)
2569 temp[i2]=(med_2_2::med_int) (familyArray[i2]);
2571 for (int i=0; i<numberOfTypes; i++) {
2572 int typeNumberOfElements = typeCount[i+1] - typeCount[i] ;
2574 err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
2575 familyArray+typeCount[i]-1, typeNumberOfElements,
2576 (med_2_2::med_entite_maillage) entity,
2577 (med_2_2::med_geometrie_element) types[i]);
2579 if ( err != MED_VALID)
2580 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write family for the |"<< _ptrMesh->getNumberOfElements(entity, types[i])
2581 << "| faces of geometric type |" << geoNames[types[i]] <<"|in mesh |"
2582 << _ptrMesh->_name.c_str() << "|" ));
2584 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
2587 delete[] familyArray ;
2588 //if (true == ToDestroy) {
2589 // int NumberOfFamilies = myFamilies->size();
2590 // for (int i=0; i<NumberOfFamilies; i++)
2591 // delete myFamilies[i];
2596 { // EDGE RELATED BLOCK
2597 //medEntityMesh entity=MED_EN::MED_FACE;
2598 medEntityMesh entity=MED_EN::MED_EDGE;
2599 // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArray____Family DOIT ETRE ENLEVER DE LA CLASSE MESH
2600 if ( ( _ptrMesh->existConnectivity(MED_NODAL,entity) )|( _ptrMesh->existConnectivity(MED_DESCENDING,entity) ) ) {
2602 int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ;
2603 const medGeometryElement * types = _ptrMesh->getTypes (entity) ;
2605 int numberOfElements = _ptrMesh->getNumberOfElements(entity, MED_ALL_ELEMENTS) ;
2606 int * familyArray = new int[numberOfElements] ;
2607 for (int i=0;i<numberOfElements;i++)
2610 int numberOfFamilies = _ptrMesh->getNumberOfFamilies(entity) ;
2611 //vector<FAMILY*> myFamilies = _ptrMesh->getFamilies(entity) ;
2612 vector<FAMILY*> * myFamilies = &_ptrMesh->_familyEdge ;
2613 //bool ToDestroy = false;
2614 if (0 == numberOfFamilies) {
2615 //ToDestroy = true ;
2616 vector<GROUP*> myGroups = _ptrMesh->getGroups(entity);
2617 int NumberOfGroups = myGroups.size() ;
2618 // build families from groups
2619 for (int i=0; i<NumberOfGroups; i++) {
2620 SCRUTE( myGroups[i]->getName() );
2621 SUPPORT * mySupport = myGroups[i] ;
2622 FAMILY* myFamily = new FAMILY(*mySupport);
2623 myFamily->setIdentifier(-i-2000);
2624 myFamilies->push_back(myFamily);
2626 numberOfFamilies=myFamilies->size() ;
2628 for (int i=0;i<numberOfFamilies;i++) {
2629 int familyNumber = (*myFamilies)[i]->getIdentifier() ;
2630 int numberOfFamilyElements = (*myFamilies)[i]->getNumberOfElements(MED_ALL_ELEMENTS) ;
2631 if ((*myFamilies)[i]->isOnAllElements())
2632 for (int ii=0; ii<numberOfFamilyElements; ii++)
2633 familyArray[ii]=familyNumber;
2635 const int * myFamilyElements = (*myFamilies)[i]->getNumber(MED_ALL_ELEMENTS) ;
2636 for (int ii=0;ii<numberOfFamilyElements;ii++)
2637 familyArray[myFamilyElements[ii]-1]=familyNumber;
2641 const int * typeCount = _ptrMesh->getGlobalNumberingIndex(entity) ;
2642 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
2643 int lgth=numberOfElements;
2644 med_2_2::med_int *temp=new med_2_2::med_int[lgth];
2645 for(int i2=0;i2<lgth;i2++)
2646 temp[i2]=(med_2_2::med_int) (familyArray[i2]);
2648 for (int i=0; i<numberOfTypes; i++) {
2649 int typeNumberOfElements = typeCount[i+1] - typeCount[i] ;
2651 err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
2652 familyArray+typeCount[i]-1, typeNumberOfElements,
2653 (med_2_2::med_entite_maillage) entity,
2654 (med_2_2::med_geometrie_element) types[i]);
2656 if ( err != MED_VALID)
2657 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write family for the |"<< _ptrMesh->getNumberOfElements(entity, types[i])
2658 << "| edges of geometric type |" << geoNames[types[i]] <<"|in mesh |"
2659 << _ptrMesh->_name.c_str() << "|" ));
2661 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
2664 delete[] familyArray ;
2665 //if (true == ToDestroy) {
2666 // int NumberOfFamilies = myFamilies->size();
2667 // for (int i=0; i<NumberOfFamilies; i++)
2668 // delete myFamilies[i];
2677 int MED_MESH_WRONLY_DRIVER22::writeFamilies(vector<FAMILY*> & families ) const
2680 const char * LOC="int MED_MESH_WRONLY_DRIVER22::writeFamilies(vector<FAMILY*> families) const : ";
2683 med_2_2::med_err err;
2685 MESSAGE(LOC<<" families.size() :"<<families.size());
2687 for (unsigned int i=0; i< families.size(); i++) {
2689 int numberOfAttributes = families[i]->getNumberOfAttributes ();
2690 string attributesDescriptions = "";
2692 // Recompose the attributes descriptions arg for MED
2693 for (int j=0; j < numberOfAttributes; j++) {
2695 string attributeDescription = families[i]->getAttributeDescription(j+1);
2697 if ( attributeDescription.size() > MED_TAILLE_DESC )
2698 throw MEDEXCEPTION( LOCALIZED(STRING(LOC) << "The size of the attribute description n° |" << j+1 << "| of the family |" << families[i]->getName()
2699 << "| with identifier |" << families[i]->getIdentifier() << "| is |"
2700 << attributeDescription.size() <<"| and is more than |" << MED_TAILLE_DESC << "|")) ;
2702 attributesDescriptions += attributeDescription;
2706 int numberOfGroups = families[i]->getNumberOfGroups();
2707 string groupsNames(numberOfGroups*MED_TAILLE_LNOM,'\0') ;
2708 // Recompose the groups names arg for MED
2709 for (int j=0; j < numberOfGroups; j++) {
2711 string groupName = families[i]->getGroupName(j+1);
2713 if ( groupName.size() > MED_TAILLE_LNOM )
2714 throw MEDEXCEPTION( LOCALIZED(STRING(LOC) << "The size of the group name n° |" << j+1 << "| of the family |" << families[i]->getName()
2715 << "| with identifier |" << families[i]->getIdentifier() << "| is |"
2716 << groupName.size() <<"| and is more than |" << MED_TAILLE_LNOM << "|")) ;
2719 int length = min(MED_TAILLE_LNOM,(int)groupName.size());
2720 groupsNames.replace(j*MED_TAILLE_LNOM,length, groupName,0,length);
2724 // test if the family already exists (HDF trick waiting a MED evolution to be replaced)
2726 string dataGroupFam;
2727 if (families[i]->getEntity() == MED_NODE)
2728 dataGroupFam = "/ENS_MAA/"+_meshName+"/FAS/NOEUD/"+families[i]->getName()+"/";
2730 dataGroupFam = "/ENS_MAA/"+_meshName+"/FAS/ELEM/"+families[i]->getName()+"/";
2732 SCRUTE("|"<<dataGroupFam<<"|");
2733 err = med_2_2::_MEDdatagroupOuvrir(_medIdt,const_cast <char *> (dataGroupFam.c_str()) ) ;
2734 if ( err < MED_VALID ) {
2737 MESSAGE(LOC<<"families[i]->getName().c_str() : "<<families[i]->getName().c_str());
2738 MESSAGE(LOC<<"_meshName.c_str() : "<<_meshName.c_str());
2739 MESSAGE(LOC<<"families[i]->getIdentifier() : "<<families[i]->getIdentifier());
2740 MESSAGE(LOC<<"numberOfAttributes : "<<numberOfAttributes);
2742 //MESSAGE(LOC<<"families[i]->getAttributesIdentifiers() : "<<families[i]->getAttributesIdentifiers()[0]);
2743 //MESSAGE(LOC<<"families[i]->getAttributesValues() : "<<families[i]->getAttributesValues()[0]);
2744 MESSAGE(LOC<<"attributesDescriptions.c_str() : "<<attributesDescriptions.c_str());
2745 MESSAGE(LOC<<"numberOfGroups : "<<numberOfGroups);
2746 MESSAGE(LOC<<"groupsNames.c_str() : "<<groupsNames.c_str());
2747 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
2748 int lgth=families[i]->getNumberOfAttributes();
2749 med_2_2::med_int * AttributesIdentifier2 = new med_2_2::med_int[lgth] ;
2750 med_2_2::med_int * AttributesValues2 = new med_2_2::med_int[lgth] ;
2751 for(med_2_2::med_int i2=0;i2<lgth;i2++)
2753 AttributesIdentifier2[i2]=(med_2_2::med_int)(families[i]->getAttributesIdentifiers()[i2]);
2754 AttributesValues2[i2]=(med_2_2::med_int)(families[i]->getAttributesValues()[i2]);
2756 err = med_2_2::MEDfamCr( _medIdt,
2757 const_cast <char *> ( _meshName.c_str() ),
2758 const_cast <char *> ( families[i]->getName().c_str() ),
2759 families[i]->getIdentifier(),
2760 AttributesIdentifier2,
2762 const_cast <char *> (attributesDescriptions.c_str()),
2764 const_cast <char *> (groupsNames.c_str()),
2766 delete [] AttributesIdentifier2;
2767 delete [] AttributesValues2;
2769 err = med_2_2::MEDfamCr( _medIdt,
2770 const_cast <char *> ( _meshName.c_str() ),
2771 const_cast <char *> ( families[i]->getName().c_str() ),
2772 families[i]->getIdentifier(),
2773 families[i]->getAttributesIdentifiers(),
2774 families[i]->getAttributesValues(),
2775 const_cast <char *> (attributesDescriptions.c_str()),
2777 const_cast <char *> (groupsNames.c_str()),
2781 if ( err != MED_VALID)
2782 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't create family |" << families[i]->getName()
2783 << "| with identifier |" << families[i]->getIdentifier() << "| groups names |"
2784 << groupsNames <<"| and attributes descriptions |" << attributesDescriptions << "|")) ;
2787 med_2_2::_MEDdatagroupFermer(_medIdt);
2798 // A FAIRE POUR LES NOEUDS ET LES ELEMENTS ret = MEDfamEcr(
2802 /*--------------------- RDWR PART -------------------------------*/
2804 MED_MESH_RDWR_DRIVER22::MED_MESH_RDWR_DRIVER22()
2808 MED_MESH_RDWR_DRIVER22::MED_MESH_RDWR_DRIVER22(const string & fileName,
2810 MED_MESH_DRIVER(fileName,ptrMesh,MED_RDWR),
2811 IMED_MESH_RDONLY_DRIVER(fileName,ptrMesh),
2812 IMED_MESH_WRONLY_DRIVER(fileName,ptrMesh),
2813 IMED_MESH_RDWR_DRIVER(fileName,ptrMesh),
2814 MED_MESH_DRIVER22(fileName,ptrMesh,MED_RDWR),
2815 MED_MESH_RDONLY_DRIVER22(fileName,ptrMesh),
2816 MED_MESH_WRONLY_DRIVER22(fileName,ptrMesh)
2818 MESSAGE("MED_MESH_RDWR_DRIVER22::MED_MESH_RDWR_DRIVER22(const string & fileName, MESH * ptrMesh) has been created");
2821 MED_MESH_RDWR_DRIVER22::MED_MESH_RDWR_DRIVER22(const MED_MESH_RDWR_DRIVER22 & driver):
2822 MED_MESH_DRIVER(driver),
2823 IMED_MESH_RDONLY_DRIVER(driver),
2824 IMED_MESH_WRONLY_DRIVER(driver),
2825 IMED_MESH_RDWR_DRIVER(driver),
2826 MED_MESH_DRIVER22(driver),
2827 MED_MESH_RDONLY_DRIVER22(driver),
2828 MED_MESH_WRONLY_DRIVER22(driver)
2832 MED_MESH_RDWR_DRIVER22::~MED_MESH_RDWR_DRIVER22() {
2833 //MESSAGE("MED_MESH_RDWR_DRIVER22::MED_MESH_RDWR_DRIVER22(const string & fileName, MESH * ptrMesh) has been destroyed");
2836 GENDRIVER * MED_MESH_RDWR_DRIVER22::copy(void) const
2838 return new MED_MESH_RDWR_DRIVER22(*this);
2841 void MED_MESH_RDWR_DRIVER22::write(void) const
2843 MED_MESH_WRONLY_DRIVER22::write();
2845 void MED_MESH_RDWR_DRIVER22::read (void)
2847 MED_MESH_RDONLY_DRIVER22::read();