1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/
20 #include "MEDMEM_MedMeshDriver22.hxx"
22 #include "MEDMEM_DriversDef.hxx"
24 #include "MEDMEM_Family.hxx"
25 #include "MEDMEM_Group.hxx"
26 #include "MEDMEM_Coordinate.hxx"
27 #include "MEDMEM_Connectivity.hxx"
28 #include "MEDMEM_Mesh.hxx"
29 #include "MEDMEM_CellModel.hxx"
30 #include "MEDMEM_Grid.hxx"
33 using namespace MED_EN;
34 using namespace MEDMEM;
38 extern med_idt _MEDdatagroupOuvrir(med_idt pid, char *nom);
39 extern med_err _MEDdatagroupFermer(med_idt id);
43 // Every memory allocation made in the MedDriver members function are desallocated in the Mesh destructor
45 MED_MESH_DRIVER22::MED_MESH_DRIVER22(): _medIdt(MED_INVALID)
49 MED_MESH_DRIVER22::MED_MESH_DRIVER22(const string & fileName,
51 MED_EN::med_mode_acces accessMode):
52 _medIdt(MED_INVALID), MED_MESH_DRIVER(fileName,ptrMesh,accessMode)
56 MED_MESH_DRIVER22::MED_MESH_DRIVER22(const MED_MESH_DRIVER22 & driver):
57 MED_MESH_DRIVER(driver),_medIdt(driver._medIdt)
61 MED_MESH_DRIVER22::~MED_MESH_DRIVER22()
65 void MED_MESH_DRIVER22::open()
67 const char * LOC = "MED_MESH_DRIVER22::open()" ;
70 MESSAGE(LOC<<" : _fileName.c_str : "<< _fileName.c_str()<<",mode : "<< _accessMode);
71 _medIdt = med_2_2::MEDouvrir( (const_cast <char *> (_fileName.c_str())),(med_2_2::med_mode_acces) _accessMode);
72 MESSAGE(LOC<<" _medIdt : "<< _medIdt );
76 _medIdt = MED_INVALID;
78 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Could not open file "<<_fileName<<" in mode "<<_accessMode));
84 void MED_MESH_DRIVER22::close()
86 const char * LOC = "MED_MESH_DRIVER22::close() " ;
89 if ( _status == MED_OPENED) {
90 err = med_2_2::MEDfermer(_medIdt);
91 // san -- MED5873 : Calling H5close() here leads to failure of SALOMEDS::StudyManager_i::_SaveAs()
92 // method during study saving process. MEDfermer() seems sufficient for closing a file.
93 //H5close(); // If we call H5close() all the files are closed.
95 throw MEDEXCEPTION( LOCALIZED(STRING(LOC)
96 <<" Error when closing file !"
99 MESSAGE(LOC <<": _medIdt= " << _medIdt );
100 MESSAGE(LOC<<": MEDfermer : err = " << err );
101 _status = MED_CLOSED;
102 _medIdt = MED_INVALID;
107 //A FAIRE UTILISER LES MAPS...
108 const med_2_2::med_geometrie_element MED_MESH_DRIVER22::all_cell_type[MED_NBR_GEOMETRIE_MAILLE]=
109 { med_2_2::MED_POINT1,med_2_2::MED_SEG2,med_2_2::MED_SEG3,med_2_2::MED_TRIA3,med_2_2::MED_QUAD4,med_2_2::MED_TRIA6,med_2_2::MED_QUAD8,
110 med_2_2::MED_TETRA4,med_2_2::MED_PYRA5,med_2_2::MED_PENTA6,med_2_2::MED_HEXA8,med_2_2::MED_TETRA10,med_2_2::MED_PYRA13,
111 med_2_2::MED_PENTA15, med_2_2::MED_HEXA20};
113 const char * const MED_MESH_DRIVER22::all_cell_type_tab [MED_NBR_GEOMETRIE_MAILLE]=
114 { "MED_POINT1","MED_SEG2","MED_SEG3","MED_TRIA3","MED_QUAD4","MED_TRIA6","MED_QUAD8",
115 "MED_TETRA4","MED_PYRA5","MED_PENTA6","MED_HEXA8","MED_TETRA10","MED_PYRA13",
116 "MED_PENTA15","MED_HEXA20"};
119 //---------------------------------- RDONLY PART -------------------------------------------------------------
121 MED_MESH_RDONLY_DRIVER22::MED_MESH_RDONLY_DRIVER22()
125 MED_MESH_RDONLY_DRIVER22::MED_MESH_RDONLY_DRIVER22(const string & fileName,
127 IMED_MESH_RDONLY_DRIVER(fileName,ptrMesh),MED_MESH_DRIVER22(fileName,ptrMesh,MED_RDONLY),MED_MESH_DRIVER(fileName,ptrMesh,MED_RDONLY)
129 MESSAGE("MED_MESH_RDONLY_DRIVER22::MED_MESH_RDONLY_DRIVER22(const string & fileName, MESH * ptrMesh) has been created");
132 MED_MESH_RDONLY_DRIVER22::MED_MESH_RDONLY_DRIVER22(const MED_MESH_RDONLY_DRIVER22 & driver):
133 IMED_MESH_RDONLY_DRIVER(driver),MED_MESH_DRIVER22(driver),MED_MESH_DRIVER(driver)
137 MED_MESH_RDONLY_DRIVER22::~MED_MESH_RDONLY_DRIVER22()
139 //MESSAGE("MED_MESH_RDONLY_DRIVER22::~MED_MESH_RDONLY_DRIVER() has been destroyed");
142 GENDRIVER * MED_MESH_RDONLY_DRIVER22::copy(void) const
144 return new MED_MESH_RDONLY_DRIVER22(*this);
147 void MED_MESH_RDONLY_DRIVER22::read(void)
149 const char * LOC = "MED_MESH_RDONLY_DRIVER22::read() : " ;
151 if (_status!=MED_OPENED)
152 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The _idt of file " << _fileName << " is : " << _medIdt << " (the file is not opened)." )) ;
154 _ptrMesh->_name = _meshName;
156 SCRUTE(_ptrMesh->getIsAGrid());
158 if (_ptrMesh->getIsAGrid())
162 // always call getFAMILY : families are requiered !!!!
164 // int nbFam = MEDnFam(_medIdt,
165 // const_cast <char *> (_meshName.c_str()),
167 // MED_FR::MED_FAMILLE);
172 if (getFAMILY()!=MED_VALID)
173 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERREUR in getFAMILY when the mesh is a grid")) ;
175 buildAllGroups(_ptrMesh->_groupNode,_ptrMesh->_familyNode) ;
182 if (getCOORDINATE()!=MED_VALID)
183 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERREUR in getCOORDINATE" )) ;
185 if (getCONNECTIVITY()!=MED_VALID)
186 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERREUR in getCOONECTIVITY")) ;
188 if (getFAMILY()!=MED_VALID)
189 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERREUR in getFAMILY" )) ;
193 // we build all groups
195 buildAllGroups(_ptrMesh->_groupNode,_ptrMesh->_familyNode) ;
197 buildAllGroups(_ptrMesh->_groupCell,_ptrMesh->_familyCell) ;
199 if (_ptrMesh->_meshDimension == 3)
201 buildAllGroups(_ptrMesh->_groupFace,_ptrMesh->_familyFace) ;
202 else if (_ptrMesh->_meshDimension == 2)
204 buildAllGroups(_ptrMesh->_groupEdge,_ptrMesh->_familyEdge) ;
206 // MESSAGE(LOC<<"Checking of CellModel !!!!!!!");
208 // int nbOfTypes = _ptrMesh->_connectivity->_numberOfTypes;
209 // for(int i=0;i<nbOfTypes;i++)
211 // MESSAGE(LOC << _ptrMesh->_connectivity->_type[i]) ;
217 //=======================================================================
220 //=======================================================================
222 void MED_MESH_RDONLY_DRIVER22::getGRID()
224 const char * LOC = "MED_MESH_RDONLY_DRIVER22::getGRID() : " ;
227 if (_status!=MED_OPENED)
228 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "med file is not opened"));
230 GRID * ptrGrid = (GRID *) _ptrMesh;
236 int numberOfMeshesInFile = med_2_2::MEDnMaa(_medIdt);
238 if (numberOfMeshesInFile == MED_INVALID)
239 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Problem in File where the mesh " << _meshName << " is supposed to be stored"));
241 for (int index = 0; index < numberOfMeshesInFile; index++)
243 char meshName[MED_TAILLE_NOM+1]="";
244 char meshDescription[MED_TAILLE_DESC+1]="";
246 med_2_2::med_maillage meshType;
248 err = med_2_2::MEDmaaInfo(_medIdt, (index+1),meshName, &meshDim,
249 &meshType, meshDescription) ;
251 MESSAGE(LOC<<": Mesh n°"<< (index+1) <<" nammed "<< meshName << " with the description " << meshDescription << " is structured");
253 if (_meshName == string(meshName))
255 _ptrMesh->_description = meshDescription;
256 _ptrMesh->_name = meshName;
260 MED_EN::med_grid_type gridType = ptrGrid->getGridType();
262 MESSAGE(LOC<<": Mesh processed is nammed "<< _ptrMesh->_name << " with the description " << _ptrMesh->_description << " is structured with the type " << gridType);
264 // Read the dimension of the mesh <_meshName>
265 int MeshDimension = med_2_2::MEDdimLire(_medIdt, const_cast <char *>
266 (_meshName.c_str())) ;
268 if (MeshDimension == MED_INVALID)
269 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The mesh dimension |" <<
270 MeshDimension << "| seems to be incorrect " <<
271 "for the mesh : |" << _meshName << "|")) ;
273 _ptrMesh->_meshDimension = MeshDimension;
275 // Read or get the dimension of the space for the mesh <_meshName>
276 int SpaceDimension = MeshDimension;
278 int SpaceDimensionRead = med_2_2::MEDdimEspaceLire(_medIdt,
280 (_meshName.c_str())) ;
282 if (SpaceDimensionRead != MED_INVALID) SpaceDimension = SpaceDimensionRead;
284 _ptrMesh->_spaceDimension = SpaceDimension;
286 med_2_2::med_repere rep ;
287 string tmp_nom_coord (MED_TAILLE_PNOM22*(_ptrMesh->_spaceDimension)+1,' ');
288 string tmp_unit_coord(MED_TAILLE_PNOM22*(_ptrMesh->_spaceDimension)+1,' ');
289 char * tmp_nom = (const_cast <char *> ( tmp_nom_coord.c_str()) ) ;
290 char * tmp_unit= (const_cast <char *> ( tmp_unit_coord.c_str()) ) ;
293 int * ArrayLen[] = { & ptrGrid->_iArrayLength,
294 & ptrGrid->_jArrayLength,
295 & ptrGrid->_kArrayLength };
297 MESSAGE(LOC << "The mesh is a " << _ptrMesh->_meshDimension << "D mesh on a " << _ptrMesh->_spaceDimension << "D space");
301 // if (gridType == MED_EN::MED_GRILLE_STANDARD)
302 if (gridType == MED_EN::MED_BODY_FITTED)
304 int * structure = new int[MeshDimension];
306 err = med_2_2::MEDstructureCoordLire(_medIdt,
308 (_ptrMesh->_name.c_str()),
309 MeshDimension,structure);
311 if (err != MED_VALID)
312 throw MEDEXCEPTION(STRING(LOC) <<"Error in reading the structure of grid : |" << _meshName << "|" ) ;
316 for (int idim = 0; idim < MeshDimension; idim++)
318 MESSAGE(LOC<<"structure dim " << idim << " " << structure[idim]);
320 ArrayLen [idim][0] = structure[idim];
321 NumberOfNodes = NumberOfNodes*structure[idim];
326 // NumberOfNodes = MED_FR::MEDnEntMaa(_medIdt,
327 // const_cast <char *>
328 // (_ptrMesh->_name.c_str()),
329 // MED_FR::MED_COOR,MED_FR::MED_NOEUD,
330 // (MED_FR::med_geometrie_element) 0,
331 // (MED_FR::med_connectivite) 0);
333 if ( NumberOfNodes == MED_INVALID )
334 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"The number of nodes |" <<
336 "| seems to be incorrect "
337 << "for the mesh : |" <<
338 _meshName << "|" )) ;
340 _ptrMesh->_numberOfNodes = NumberOfNodes ;
342 // create coordinates and its structure
343 _ptrMesh->_coordinate = new COORDINATE(SpaceDimension,NumberOfNodes,
344 MED_EN::MED_FULL_INTERLACE);
346 err = MEDcoordLire(_medIdt,
347 const_cast <char *> (_ptrMesh->_name.c_str()),
348 _ptrMesh->_spaceDimension,
349 //const_cast <double *> ( _ptrMesh->_coordinate->_coordinate->get(MED_EN::MED_FULL_INTERLACE) ),
350 const_cast <double *> ( _ptrMesh->_coordinate->_coordinate.get(MED_EN::MED_FULL_INTERLACE) ),
351 med_2_2::MED_FULL_INTERLACE,
352 MED_ALL, // we read all the coordinates
353 NULL, // we don't use a profile
354 0, // so the profile's size is 0
355 &rep,tmp_nom,tmp_unit);
357 if (err != MED_VALID)
358 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't read coordinates of the |" <<
359 NumberOfNodes << "| nodes for the mesh : |" <<
360 _meshName << "| of space dimension |" <<
361 SpaceDimension << "| with units names |" <<
362 tmp_nom << "| and units |" <<
365 ptrGrid->_is_coordinates_filled = true;
367 else if ((gridType == MED_EN::MED_CARTESIAN) ||
368 (gridType == MED_EN::MED_POLAR))
372 double * Array[] = { (double*) 0, (double*) 0, (double*) 0 };
374 for (int idim = 0; idim < _ptrMesh->_meshDimension; ++idim)
376 med_2_2::med_table table;
377 if (idim == 0) table = med_2_2::MED_COOR_IND1;
378 else if (idim == 1) table = med_2_2::MED_COOR_IND2;
379 else if (idim == 2) table = med_2_2::MED_COOR_IND3;
381 int length = med_2_2::MEDnEntMaa(_medIdt,
382 const_cast <char *> (_ptrMesh->_name.c_str()),
383 table,med_2_2::MED_NOEUD,
386 if ( length <= MED_VALID )
387 throw MEDEXCEPTION(STRING(LOC) <<"The number of nodes |" << length <<
388 "| seems to be incorrect "
389 << "for the mesh : |" << _meshName << "|" ) ;
391 ArrayLen [idim][0] = length;
392 NumberOfNodes *= length;
394 Array [idim] = new double [ length ];
396 err = med_2_2::MEDindicesCoordLire(_medIdt, const_cast <char *>
397 (_ptrMesh->_name.c_str()),
398 _ptrMesh->_meshDimension,
399 Array [idim], length, (idim+1),
400 tmp_nom+(idim*MED_TAILLE_PNOM22),
401 tmp_unit+(idim*MED_TAILLE_PNOM22));
403 if (err != MED_VALID)
404 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Error in reading coordinates indices " <<
405 idim << "of the grid : |" <<
406 _meshName << "|" )) ;
409 ptrGrid->_iArray = Array[0];
410 ptrGrid->_jArray = Array[1];
411 ptrGrid->_kArray = Array[2];
413 _ptrMesh->_numberOfNodes = NumberOfNodes ;
415 // create coordinates
416 _ptrMesh->_coordinate = new COORDINATE(SpaceDimension,NumberOfNodes,
417 MED_EN::MED_FULL_INTERLACE);
419 if (gridType == MED_EN::MED_CARTESIAN)
420 rep = med_2_2::MED_CART;
421 else if (gridType == MED_EN::MED_POLAR)
423 if (SpaceDimension == 2) rep = med_2_2::MED_CYL;
424 else if (SpaceDimension == 3) rep = med_2_2::MED_SPHER;
428 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<" bad grid type : " << gridType));
430 // set coordinate names
432 for (i=0; i<_ptrMesh->_spaceDimension; ++i ) {
433 string myStringName(tmp_nom_coord,i*MED_TAILLE_PNOM22,MED_TAILLE_PNOM22) ;
434 string myStringUnit(tmp_unit_coord,i*MED_TAILLE_PNOM22,MED_TAILLE_PNOM22) ;
435 // suppress space at the end
437 for(j=MED_TAILLE_PNOM22-1;j>=0;j--)
438 if (myStringName[j] != ' ') break ;
439 _ptrMesh->_coordinate->_coordinateName[i]=string(myStringName,0,j+1);
440 for(j=MED_TAILLE_PNOM22-1;j>=0;j--)
441 if (myStringUnit[j] != ' ') break ;
442 _ptrMesh->_coordinate->_coordinateUnit[i]=string(myStringUnit,0,j+1);
445 string coordinateSystem = "UNDEFINED";
447 if( rep == med_2_2::MED_CART) coordinateSystem = "CARTESIAN";
448 else if ( rep == med_2_2::MED_CYL) coordinateSystem = "CYLINDRICAL";
449 else if ( rep == med_2_2::MED_SPHER) coordinateSystem = "SPHERICAL";
451 _ptrMesh->_coordinate->setCoordinatesSystem(coordinateSystem);
456 //=======================================================================
457 //function : getCOORDINATE
458 // A FAIRE : RENVOYER DU VOID
459 //=======================================================================
460 int MED_MESH_RDONLY_DRIVER22::getCOORDINATE()
462 const char * LOC = "MED_MESH_RDONLY_DRIVER22::getCOORDINATE() : " ;
466 if (_status==MED_OPENED)
470 int numberOfMeshesInFile = med_2_2::MEDnMaa(_medIdt);
472 if (numberOfMeshesInFile == MED_INVALID)
473 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Problem in File where the mesh " << _meshName << " is supposed to be stored"));
475 for (int index = 0; index < numberOfMeshesInFile; index++)
477 char meshName[MED_TAILLE_NOM+1]="";
478 char meshDescription[MED_TAILLE_DESC+1]="";
480 med_2_2::med_maillage meshType;
482 err = med_2_2::MEDmaaInfo(_medIdt, (index+1), meshName, &meshDim,
483 &meshType, meshDescription) ;
485 MESSAGE(LOC<<": Mesh n°"<< (index+1) <<" nammed "<< meshName << " with the description " << meshDescription << " is structured");
487 if (_meshName == string(meshName))
489 _ptrMesh->_description = meshDescription;
494 // Read the dimension of the mesh <_meshName>
495 int MeshDimension = med_2_2::MEDdimLire(_medIdt, const_cast <char *>
496 (_meshName.c_str())) ;
498 if ( MeshDimension == MED_INVALID )
499 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The mesh dimension |" <<
501 "| seems to be incorrect " <<
502 "for the mesh : |" << _meshName << "|")) ;
504 _ptrMesh->_meshDimension = MeshDimension;
506 // Read or get the dimension of the space for the mesh <_meshName>
507 int SpaceDimension = MeshDimension;
509 int SpaceDimensionRead = med_2_2::MEDdimEspaceLire(_medIdt,
511 (_meshName.c_str())) ;
513 if (SpaceDimensionRead != MED_INVALID)
514 SpaceDimension = SpaceDimensionRead;
516 _ptrMesh->_spaceDimension = SpaceDimension;
518 // Read the number of nodes used in the mesh <_meshName>
519 // to be able to create a COORDINATE object
520 int NumberOfNodes=MEDnEntMaa(_medIdt,
521 const_cast <char *> (_meshName.c_str()),
524 (med_2_2::med_geometrie_element) MED_NONE,
525 (med_2_2::med_connectivite) MED_NONE);
526 if ( NumberOfNodes <= MED_VALID )
527 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"The number of nodes |" << NumberOfNodes << "| seems to be incorrect "
528 << "for the mesh : |" << _meshName << "|" )) ;
529 _ptrMesh->_numberOfNodes = NumberOfNodes ;
531 // create a COORDINATE object
532 _ptrMesh->_coordinate = new COORDINATE(SpaceDimension, NumberOfNodes, MED_EN::MED_FULL_INTERLACE);
534 med_2_2::med_repere rep ; // ATTENTION ---> DOIT ETRE INTEGRE DS MESH EF: FAIT NON?
535 string tmp_nom_coord (MED_TAILLE_PNOM22*(_ptrMesh->_spaceDimension)+1,'\0');
536 string tmp_unit_coord(MED_TAILLE_PNOM22*(_ptrMesh->_spaceDimension)+1,'\0');
537 char * tmp_nom = (const_cast <char *> ( tmp_nom_coord.c_str()) ) ;
538 char * tmp_unit= (const_cast <char *> ( tmp_unit_coord.c_str()) ) ;
540 err=MEDcoordLire(_medIdt,
541 const_cast <char *> (_ptrMesh->_name.c_str()),
542 _ptrMesh->_spaceDimension,
543 //const_cast <double *> ( _ptrMesh->_coordinate->_coordinate->get(MED_EN::MED_FULL_INTERLACE) ),
544 const_cast <double *> ( _ptrMesh->_coordinate->_coordinate.get(MED_EN::MED_FULL_INTERLACE) ),
545 med_2_2::MED_FULL_INTERLACE,
546 MED_ALL, // we read all the coordinates
547 NULL, // we don't use a profile
548 0, // so the profile's size is 0
549 &rep,tmp_nom,tmp_unit);
550 if (err != MED_VALID)
551 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't read coordinates of the |" << NumberOfNodes << "| nodes "
552 << "for the mesh : |" << _meshName
553 << "| of space dimension |" << SpaceDimension
554 << "| with units names |" << tmp_nom
555 << "| and units |" << tmp_unit
559 for (int i=0;i<_ptrMesh->_spaceDimension;i++) {
560 string myStringName(tmp_nom_coord,i*MED_TAILLE_PNOM22,MED_TAILLE_PNOM22) ;
561 string myStringUnit(tmp_unit_coord,i*MED_TAILLE_PNOM22,MED_TAILLE_PNOM22) ;
562 // suppress space at the end
564 for(j=MED_TAILLE_PNOM22-1;j>=0;j--)
565 if (myStringName[j] != ' ') break ;
566 _ptrMesh->_coordinate->_coordinateName[i]=string(myStringName,0,j+1);
567 for(j=MED_TAILLE_PNOM22-1;j>=0;j--)
568 if (myStringUnit[j] != ' ') break ;
569 _ptrMesh->_coordinate->_coordinateUnit[i]=string(myStringUnit,0,j+1);
572 // Pourquoi le stocker sous forme de chaîne ?
575 case med_2_2::MED_CART :
577 _ptrMesh->_coordinate->_coordinateSystem = "CARTESIAN";
580 case med_2_2::MED_CYL :
582 _ptrMesh->_coordinate->_coordinateSystem = "CYLINDRICAL";
585 case med_2_2::MED_SPHER :
587 _ptrMesh->_coordinate->_coordinateSystem = "SPHERICAL";
592 _ptrMesh->_coordinate->_coordinateSystem = "UNDEFINED"; // ?Erreur ?
597 // Read the unused optional node Names
598 char * tmp_node_name = new char[NumberOfNodes*MED_TAILLE_PNOM22+1];
599 tmp_node_name[NumberOfNodes]='\0' ;
600 err=MEDnomLire(_medIdt,const_cast <char*> (_ptrMesh->_name.c_str()),
601 tmp_node_name,NumberOfNodes*MED_TAILLE_PNOM22,med_2_2::MED_NOEUD,
602 (med_2_2::med_geometrie_element) MED_NONE);
603 if (err == MED_VALID)
604 MESSAGE(LOC<<"MED_MESH_RDONLY_DRIVER::getNoeuds() : WARNING : Nodes have names but we do not read them !");
605 delete[] tmp_node_name ;
608 // ??? Read the unused optional node Numbers ???
609 med_2_2::med_int * tmp_node_number = new med_2_2::med_int[NumberOfNodes] ;
610 err=MEDnumLire(_medIdt,const_cast <char*> (_ptrMesh->_name.c_str()),
611 tmp_node_number,NumberOfNodes,med_2_2::MED_NOEUD,(med_2_2::med_geometrie_element)0);
612 if (err == MED_VALID) {
613 // INFOS(LOC<<"WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING");
614 // INFOS(LOC<<"MED_MESH_RDONLY_DRIVER::getNoeuds() : WARNING : Nodes have numbers but we do not take care of them !");
615 // INFOS(LOC<<"WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING");
616 MESSAGE(LOC<<"MED_MESH_RDONLY_DRIVER::getNoeuds() : Nodes have numbers, we DO TAKE care of them !");
617 _ptrMesh->_coordinate->_nodeNumber.set(NumberOfNodes) ;
618 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
619 for(med_2_2::med_int i2=0;i2<NumberOfNodes;i2++)
620 _ptrMesh->_coordinate->_nodeNumber[i2]=(int)(tmp_node_number[i2]);
622 memcpy((int*)_ptrMesh->_coordinate->_nodeNumber,tmp_node_number,sizeof(int)*NumberOfNodes) ;
625 //////////////////////////////////////////////////////////////////////////////////////
626 /// Modification pour prise en compte de la numérotation optionnelle des noeuds ///
627 //////////////////////////////////////////////////////////////////////////////////////
629 /// Calcule _optionnalToCanonicNodesNumbers de telle sorte que _optionnalToCanonicNodesNumbers[OptionnalNumber]==CanonicNumber
631 // _ptrMesh->_arePresentOptionnalNodesNumbers=1;
632 // for (int canonicNumber=1;canonicNumber<=NumberOfNodes;canonicNumber++) _ptrMesh->_optionnalToCanonicNodesNumbers[tmp_node_number[canonicNumber-1]]=canonicNumber;
633 // ICI RETOUR A LA NORMALE::: AUCUNE PRISE EN COMPTE D'UN NUMEROTATION OPTIONNEL
634 _ptrMesh->_arePresentOptionnalNodesNumbers=0;
636 else _ptrMesh->_arePresentOptionnalNodesNumbers=0;
638 //////////////////////////////////////////////////////////////////////////////////////
640 delete[] tmp_node_number ;
649 int MED_MESH_RDONLY_DRIVER22::getCONNECTIVITY()
651 const char * LOC = "MED_MESH_RDONLY_DRIVER22::getCONNECTIVITY : " ;
654 if (_status==MED_OPENED)
658 // read MED_CELL connectivity
659 CONNECTIVITY * Connectivity = new CONNECTIVITY(MED_CELL) ;
660 Connectivity->_numberOfNodes = _ptrMesh->_numberOfNodes ; // EF : Pourquoi cet attribut est-il dans MESH et non dans COORDINATE ?
662 // Try to read nodal connectivity of the cells <Connectivity->_nodal>
663 // then try to read descending connectivity <Connectivity->_descending>
664 // if neither nodal nor descending connectivity exists
665 // throw an exception.
666 err = getNodalConnectivity(Connectivity) ;
669 Connectivity->_typeConnectivity = MED_DESCENDING ;
670 err = getDescendingConnectivity(Connectivity) ;
673 getDescendingConnectivity(Connectivity) ; // we read it if there is one
677 delete Connectivity ;
678 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "We could not read " <<
679 "any Connectivity")) ;
682 if (Connectivity->_entityDimension != _ptrMesh->_meshDimension)
683 MESSAGE(LOC << "Small mesh dimension problem on the med file mounted in memory : diim stored " << _ptrMesh->_meshDimension << " dim computed using the connectivity " << Connectivity->_entityDimension);
685 _ptrMesh->_meshDimension = Connectivity->_entityDimension ;
687 // At this point Connectivity->_typeConnectivity is either NODAL or DESCENDING
688 // If both connectivities are found Connectivity->_typeConnectivity is NODAL
689 // If space dimension is 3
690 // try to read the nodal connectivity of the faces <ConnectivityFace->_nodal> then
691 // try to read the descending connectivity <ConnectivityFace->_descending>
692 // if there is no descending connectivity and the CELLS are
693 // defined in descending mode then throw an exception
695 // PROVISOIRE : if we have some face or edge in MED_MAILLE, we don't read more. There could not be have face or edge !!!!
697 if(Connectivity->_constituent==NULL) {
699 SCRUTE(_ptrMesh->_meshDimension);
700 SCRUTE(Connectivity->_entityDimension);
701 if (_ptrMesh->_meshDimension == 3) {
702 MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DES FACES..." );
703 CONNECTIVITY * ConnectivityFace = new CONNECTIVITY(MED_EN::MED_FACE) ;
704 ConnectivityFace->_typeConnectivity = Connectivity->_typeConnectivity ; // NODAL or DESCENDING
705 SCRUTE(ConnectivityFace->_typeConnectivity);
706 if (Connectivity->_typeConnectivity == MED_DESCENDING) {
707 MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DESCENDANTE DES FACES" );
708 err = getDescendingConnectivity(ConnectivityFace) ;
710 throw MEDEXCEPTION ( LOCALIZED(STRING(LOC) << "No FACE in descending connectivity")) ;
711 getNodalConnectivity(ConnectivityFace) ; // if any !
713 MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE NODALE DES FACES" );
714 err = getNodalConnectivity(ConnectivityFace) ;
715 if (err!=MED_VALID) { // or error ????? we are in NODAL mode.
716 err = getDescendingConnectivity(ConnectivityFace) ;
718 getDescendingConnectivity(ConnectivityFace); // if any !
720 if (err!=MED_VALID) {
721 delete ConnectivityFace ;
722 MESSAGE(LOC<<"No FACE defined.") ;
724 MESSAGE(LOC<<" SAUVEGARDE DE LA CONNECTIVITE DES FACES DANS L'OBJET CONNECTIVITY" );
725 Connectivity->_constituent=ConnectivityFace ;
729 // read MED_EDGE connectivity
730 if (_ptrMesh->_meshDimension > 1) { // we are in 3 or 2D
731 MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DES ARRETES...." );
732 CONNECTIVITY * ConnectivityEdge = new CONNECTIVITY(MED_EDGE) ;
733 ConnectivityEdge->_typeConnectivity = Connectivity->_typeConnectivity ;
734 if (Connectivity->_typeConnectivity == MED_DESCENDING) {
735 MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DESCENDANTE DES ARRETES" );
736 err = getDescendingConnectivity(ConnectivityEdge) ;
738 throw MEDEXCEPTION ( LOCALIZED(STRING(LOC) << "No EDGE in descending connectivity")) ;
739 getNodalConnectivity(ConnectivityEdge) ; // if any !
741 MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE NODALE DES ARRETES" );
742 err = getNodalConnectivity(ConnectivityEdge) ;
743 if (err!=MED_VALID) { // or error ????? we are in NODAL mode.
744 err = getDescendingConnectivity(ConnectivityEdge) ;
746 getDescendingConnectivity(ConnectivityEdge) ; // if any !
748 if (err!=MED_VALID) {
749 delete ConnectivityEdge ;
750 MESSAGE(LOC<<"No EDGE defined.") ;
752 if (_ptrMesh->_meshDimension == 3)
753 if (Connectivity->_constituent != NULL)
754 Connectivity->_constituent->_constituent=ConnectivityEdge ;
756 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<< "EDGE defined but there are no FACE !")) ;
758 MESSAGE(LOC<<" SAUVEGARDE DE LA CONNECTIVITE DES ARETES DANS L'OBJET CONNECTIVITY" );
759 Connectivity->_constituent=ConnectivityEdge ;
764 _ptrMesh->_connectivity = Connectivity ;
768 // we have read all connectivity in file, now we must build descending connectivity if necessary !
770 // If connectivity descending is defined, we have nothing to do, all constituent are defined !
771 // If connectivity is only nodal, we must rebuild descending if we have some contituent !
774 // if (Connectivity->_descending == NULL)
775 // if (Connectivity->_constituent != NULL){
776 // // update Connectivity->_constituent
777 // CONNECTIVITY * myConstituentOld = Connectivity->_constituent ;
778 // Connectivity->_constituent = (CONNECTIVITY *)NULL ;
779 // Connectivity->calculateDescendingConnectivity() ;
789 int MED_MESH_RDONLY_DRIVER22::getNodalConnectivity(CONNECTIVITY * Connectivity)
791 const char * LOC = "MED_MESH_RDONLY_DRIVER22::getNodalConnectivity : " ;
794 int spaceDimension = _ptrMesh->_spaceDimension;
796 if (_status==MED_OPENED)
798 // Get the type of entity to work on (previously set in the Connectivity Object)
799 med_2_2::med_entite_maillage Entity = (med_2_2::med_entite_maillage) Connectivity->getEntity();
801 // Get the number of cells of each type & store it in <tmp_cells_count>.
802 int * tmp_cells_count = new int[MED_NBR_GEOMETRIE_MAILLE] ;
804 for (i=1;i<MED_NBR_GEOMETRIE_MAILLE;i++)
805 { // EF :ON SCANNE DES GEOMETRIES INUTILES, UTILISER LES MAPS
806 tmp_cells_count[i]=MEDnEntMaa(_medIdt,(const_cast <char *> (_ptrMesh->_name.c_str())),
807 med_2_2::MED_CONN,(med_2_2::med_entite_maillage) Entity,
808 all_cell_type[i],med_2_2::MED_NOD);
811 // Get the greatest dimension of the cells : Connectivity->_entityDimension
812 // We suppose there is no cells used as faces in MED 2.2.x , this is forbidden !!!
813 // In version prior to 2.2.x, it is possible
814 if (tmp_cells_count[i]>0)
816 Connectivity->_entityDimension=all_cell_type[i]/100;
817 Connectivity->_numberOfTypes++;
823 // begin classic geometric types
824 if (Connectivity->_numberOfTypes > 0)
826 // if MED version < 2.2.x, we read only entity with dimention = Connectivity->_entityDimension. Lesser dimension are face or edge !
828 med_int major, minor, release;
830 if ( med_2_2::MEDversionLire(_medIdt, &major, &minor, &release) != 0 )
832 // error : we suppose we have not a good med file !
833 delete[] tmp_cells_count ;
837 // we get MED version number
838 // If MED version is < 2.2 then the cells which dimension
839 // is lesser than the main dimension ( Connectivity->_entityDimension )
840 // are either faces or edges
842 // string medVersion(version_med);
844 int * tmpEdgeCount = new int[MED_NBR_GEOMETRIE_MAILLE] ;
845 tmpEdgeCount[0] = 0 ;
846 int numberOfEdgesTypes = 0;
847 int * tmpFaceCount = new int[MED_NBR_GEOMETRIE_MAILLE] ;
848 tmpFaceCount[0] = 0 ;
849 int numberOfFacesTypes = 0;
851 // if ((version_med != "2.2")&(Entity==MED_FR::MED_MAILLE))
853 // Connectivity->_numberOfTypes=0;
855 // for ( i=1;i<MED_NBR_GEOMETRIE_MAILLE;i++)
857 // tmpFaceCount[i]=0;
858 // tmpEdgeCount[i]=0;
859 // if (tmp_cells_count[i]!=0)
861 // int dimension = all_cell_type[i]/100 ;
862 // if (Connectivity->_entityDimension==dimension)
863 // Connectivity->_numberOfTypes++ ;
865 // if (dimension == 2)
866 // if (Connectivity->_entityDimension==3)
868 // tmpFaceCount[i]=tmp_cells_count[i] ;
869 // tmp_cells_count[i]=0 ;
870 // numberOfFacesTypes++;
872 // if (dimension == 1)
873 // if (Connectivity->_entityDimension>dimension)
875 // tmpEdgeCount[i]=tmp_cells_count[i] ;
876 // tmp_cells_count[i]=0;
877 // numberOfEdgesTypes++ ;
883 if (Entity==med_2_2::MED_MAILLE)
885 Connectivity->_numberOfTypes=0;
887 for ( i=1;i<MED_NBR_GEOMETRIE_MAILLE;i++)
891 if (tmp_cells_count[i]!=0)
893 int dimension = all_cell_type[i]/100 ;
894 if (Connectivity->_entityDimension==dimension)
895 Connectivity->_numberOfTypes++ ;
898 if (Connectivity->_entityDimension==3)
900 tmpFaceCount[i]=tmp_cells_count[i] ;
901 //tmp_cells_count[i]=0 ;
902 //Connectivity->_numberOfTypes++ ;
903 numberOfFacesTypes++;
906 if (Connectivity->_entityDimension>dimension)
908 tmpEdgeCount[i]=tmp_cells_count[i] ;
909 //tmp_cells_count[i]=0;
910 //Connectivity->_numberOfTypes++ ;
911 numberOfEdgesTypes++ ;
917 // bloc to read CELL :
919 // Prepare an array of indexes on the different cell types to create a MEDSKYLINEARRAY
920 // We use <tmp_cells_count> to calculate <Connectivity->_count> then we release it
921 Connectivity->_geometricTypes = new MED_EN::medGeometryElement [Connectivity->_numberOfTypes] ; // Double emploi pour des raisons pratiques
922 Connectivity->_type = new CELLMODEL [Connectivity->_numberOfTypes] ; //
923 Connectivity->_count = new int [Connectivity->_numberOfTypes+1] ;
924 Connectivity->_count[0] = 1;
929 for ( i=1;i<MED_NBR_GEOMETRIE_MAILLE;i++)
930 { // no point1 cell type (?)
931 int dimension = all_cell_type[i]/100 ;
932 if ((tmp_cells_count[i]>0) && (Connectivity->_entityDimension == dimension))
934 Connectivity->_count[typeNumber]=Connectivity->_count[typeNumber-1]+tmp_cells_count[i];
936 CELLMODEL t( (MED_EN::medGeometryElement) MED_MESH_DRIVER22::all_cell_type[i]) ;
938 Connectivity->_type[typeNumber-1] = t ;
940 Connectivity->_geometricTypes[typeNumber-1]=( MED_EN::medGeometryElement) MED_MESH_DRIVER22::all_cell_type[i] ;
942 // probleme avec les mailles de dimension < a dimension du maillage :
943 // 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 !!!
946 size+=tmp_cells_count[i]*((MED_MESH_DRIVER22::all_cell_type[i])%100) ;
949 << Connectivity->_count[typeNumber]-1 << " cells of type "
950 << all_cell_type_tab[i] );
955 // Creation of the MEDSKYLINEARRAY
956 //Connectivity->_nodal = new MEDSKYLINEARRAY(Connectivity->_count[Connectivity->_numberOfTypes]-1,size) ;
957 //int * NodalIndex = Connectivity->_nodal->getIndex() ;
958 int * NodalValue = new int[size] ;
959 int * NodalIndex = new int[Connectivity->_count[Connectivity->_numberOfTypes]] ;
962 // Fill the MEDSKYLINEARRAY by reading the MED file.
964 for ( i=0;i<Connectivity->_numberOfTypes;i++)
967 med_2_2::med_geometrie_element med_type = (med_2_2::med_geometrie_element) Connectivity->_type[i].getType() ;
968 // if ( Connectivity->_type[i].getDimension() < Connectivity->_entityDimension)
969 // if (Connectivity->_entity == MED_CELL)
970 // if ( Connectivity->_type[i].getDimension() < _ptrMesh->_spaceDimension)
973 // int NumberOfCell = Connectivity->_count[i+1]-Connectivity->_count[i] ;
974 int NumberOfNodeByCell = Connectivity->_type[i].getNumberOfNodes() ;
977 for ( j=Connectivity->_count[i]; j<Connectivity->_count[i+1];j++)
978 NodalIndex[j]=NodalIndex[j-1]+NumberOfNodeByCell ;
980 int tmp_numberOfCells = Connectivity->_count[i+1]-Connectivity->_count[i] ;
981 int * tmp_ConnectivityArray = new int[(NumberOfNodeByCell+multi)*tmp_numberOfCells];
983 // int err=MEDconnLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
984 // Connectivity->_entityDimension,tmp_ConnectivityArray,
985 // MED_FR::MED_FULL_INTERLACE,NULL,0,Entity,med_type,MED_FR::MED_NOD);
986 int err=MEDconnLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
987 spaceDimension,tmp_ConnectivityArray,
988 med_2_2::MED_FULL_INTERLACE,NULL,0,Entity,med_type,med_2_2::MED_NOD);
990 if ( err != MED_VALID)
992 delete[] tmp_ConnectivityArray;
993 delete[] tmp_cells_count;
994 delete[] tmpFaceCount;
995 delete[] tmpEdgeCount;
996 MESSAGE(LOC<<": MEDconnLire returns "<<err) ;
1000 int * ConnectivityArray = NodalValue + NodalIndex[Connectivity->_count[i]-1]-1 ;
1002 // version originale sans prise en compte des numéros optionnels
1004 for ( j=0; j<tmp_numberOfCells; j++) for (int k=0; k<NumberOfNodeByCell; k++)
1005 ConnectivityArray[j*NumberOfNodeByCell+k]=tmp_ConnectivityArray[j*(NumberOfNodeByCell+multi)+k] ;
1007 //////////////////////////////////////////////////////////////////////////////
1008 // Modification pour prise en compte de la numérotation optionnelle des noeuds ///
1009 //////////////////////////////////////////////////////////////////////////////
1011 // Rénumérote le tableau temporaire tmp_ConnectivityArray en utilisant _optionnalToCanonicNodesNumbers
1012 // Le traitement est identique à la version originelle s'il n'y a pas de numérotation optionnelle
1014 // if (_ptrMesh->_arePresentOptionnalNodesNumbers==1)
1016 // for ( j=0; j<tmp_numberOfCells; j++) for (int k=0; k<NumberOfNodeByCell; k++)
1017 // ConnectivityArray[j*NumberOfNodeByCell+k]=_ptrMesh->_optionnalToCanonicNodesNumbers[tmp_ConnectivityArray[j*(NumberOfNodeByCell+multi)+k]] ;
1021 // for ( j=0; j<tmp_numberOfCells; j++) for (int k=0; k<NumberOfNodeByCell; k++)
1022 // ConnectivityArray[j*NumberOfNodeByCell+k]=tmp_ConnectivityArray[j*(NumberOfNodeByCell+multi)+k] ;
1024 ////////////////////////////////////////////////////////////////////////////
1026 delete[] tmp_ConnectivityArray;
1030 Connectivity->_nodal = new MEDSKYLINEARRAY(Connectivity->_count[Connectivity->_numberOfTypes]-1,
1035 delete[] NodalIndex;
1036 delete[] NodalValue;
1038 } // end of bloc to read CELL
1044 if (numberOfFacesTypes!=0)
1047 // Create a CONNECTIVITY constituent to put in the top level CONNECTIVITY recursive class
1048 CONNECTIVITY * constituent = new CONNECTIVITY(numberOfFacesTypes,MED_EN::MED_FACE) ;
1049 constituent->_entityDimension = 2 ;
1050 constituent->_count[0]=1 ;
1052 // In order to create the MEDSKYLINEARRAY of the constituent object we need :
1054 // To initialize the _count array of the constituent object (containning cumulated face count by geometric type)
1055 // _count[0]=1 and _count[_numberOfTypes] give the size of NodalIndex
1057 // To calculate the total number of face nodes whatever the geometric type is.
1058 // The result is the size of the array containning all the nodes : NodalValue
1060 // To calculate the starting indexes of the different face types in NodalValue,
1061 // this is the NodalIndex array.
1064 int typeNumber = 1 ;
1066 for ( i=1; i < MED_NBR_GEOMETRIE_MAILLE; i++)
1067 { // no point1 cell type (?)
1068 if (tmpFaceCount[i]>0)
1070 constituent->_count[typeNumber] = constituent->_count[typeNumber-1] + tmpFaceCount[i];
1071 CELLMODEL t( (MED_EN::medGeometryElement) MED_MESH_DRIVER22::all_cell_type[i]) ;
1072 constituent->_type[typeNumber-1]=t ;
1074 constituent->_geometricTypes[typeNumber-1]=( MED_EN::medGeometryElement) MED_MESH_DRIVER22::all_cell_type[i] ;
1076 size+=tmpFaceCount[i]*((MED_MESH_DRIVER22::all_cell_type[i])%100) ;
1081 // Creation of the MEDSKYLINEARRAY
1082 //constituent->_nodal = new MEDSKYLINEARRAY(constituent->_count[constituent->_numberOfTypes]-1,size) ;
1083 //int * NodalIndex = constituent->_nodal->getIndex() ;
1084 int * NodalValue = new int[size] ;
1085 int * NodalIndex = new int[constituent->_count[constituent->_numberOfTypes]] ;
1088 // Fill the MEDSKYLINEARRAY by reading the MED file.
1089 for ( i=0; i<constituent->_numberOfTypes; i++)
1091 med_2_2::med_geometrie_element med_type = (med_2_2::med_geometrie_element) constituent->_type[i].getType() ;
1093 int NumberOfNodeByFace = constituent->_type[i].getNumberOfNodes() ;
1095 // initialise NodalIndex
1096 for (int j=constituent->_count[i]; j<constituent->_count[i+1];j++)
1097 NodalIndex[j]=NodalIndex[j-1]+NumberOfNodeByFace ;
1099 int tmp_numberOfFaces = constituent->_count[i+1]-constituent->_count[i] ;
1100 // Il faut ajouter 1 pour le zero a la lecture !!!
1101 // ATTENTION UNIQUEMENT POUR MED < 2.2.x
1102 int * tmp_constituentArray = NULL;
1104 MESSAGE(LOC << "Med file version used here " << major << " " << minor << " " << release);
1106 if ((major == 2) && (minor <= 1))
1107 tmp_constituentArray = new int[(NumberOfNodeByFace+1)*tmp_numberOfFaces] ;
1108 else if ((major == 2) && (minor >= 2))
1110 tmp_constituentArray = new int[NumberOfNodeByFace*tmp_numberOfFaces] ;
1111 MESSAGE(LOC<<": WE ARE USING MED2.2 so there is no +1 for calculating the size of tmp_constituentArray !") ;
1114 int err=MEDconnLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
1115 Connectivity->_entityDimension,tmp_constituentArray,
1116 med_2_2::MED_FULL_INTERLACE,NULL,0,med_2_2::MED_MAILLE,med_type,med_2_2::MED_NOD);
1118 if ( err != MED_VALID)
1120 MESSAGE(LOC<<": MEDconnLire returns "<<err) ;
1121 delete constituent ;
1122 delete[] tmp_constituentArray;
1123 delete[] tmpFaceCount;
1124 delete[] tmpEdgeCount;
1128 int * constituentArray = NodalValue + NodalIndex[constituent->_count[i]-1]-1 ;
1130 // version originale sans prise en compte des numéros optionnels
1132 int multi = 0; // quand est-ce que multi vaut 1 ?? en MED-fichier < 2.2 ??
1133 MESSAGE(LOC << "Med file version used here " << major << " " << minor << " " << release);
1135 if ((major == 2) && (minor <= 1))
1136 for (int j=0; j<tmp_numberOfFaces; j++)
1137 for (int k=0; k<NumberOfNodeByFace; k++)
1138 constituentArray[j*NumberOfNodeByFace+k]=tmp_constituentArray[j*(NumberOfNodeByFace+1)+k] ;
1139 else if ((major == 2) && (minor >= 2))
1140 for (int j=0; j<tmp_numberOfFaces; j++)
1141 for (int k=0; k<NumberOfNodeByFace; k++)
1142 constituentArray[j*NumberOfNodeByFace+k]=tmp_constituentArray[j*(NumberOfNodeByFace+multi)+k] ;
1144 //////////////////////////////////////////////////////////////////////////////////////
1145 /// Modification pour prise en compte de la numérotation optionnelle des noeuds ///
1146 //////////////////////////////////////////////////////////////////////////////////////
1148 /// Rénumérote le tableau temporaire tmp_constituentArray en utilisant _optionnalToCanonicNodesNumbers
1149 /// Le traitement est identique à la version originelle s'il n'y a pas de numérotation optionnelle
1151 // if (_ptrMesh->_arePresentOptionnalNodesNumbers)
1153 // for (int j=0; j<tmp_numberOfFaces; j++) for (int k=0; k<NumberOfNodeByFace; k++)
1154 // constituentArray[j*NumberOfNodeByFace+k]=_ptrMesh->_optionnalToCanonicNodesNumbers[tmp_constituentArray[j*(NumberOfNodeByFace+1)+k]] ;
1158 // for (int j=0; j<tmp_numberOfFaces; j++) for (int k=0; k<NumberOfNodeByFace; k++)
1159 // constituentArray[j*NumberOfNodeByFace+k]=tmp_constituentArray[j*(NumberOfNodeByFace+1)+k] ;
1162 //////////////////////////////////////////////////////////////////////////////////////
1164 delete[] tmp_constituentArray;
1167 constituent->_nodal = new MEDSKYLINEARRAY(constituent->_count[constituent->_numberOfTypes]-1,
1171 delete[] NodalIndex ;
1172 delete[] NodalValue ;
1175 Connectivity->_constituent = constituent ;
1178 delete[] tmpFaceCount;
1183 if (numberOfEdgesTypes!=0)
1185 CONNECTIVITY * constituent = new CONNECTIVITY(numberOfEdgesTypes,MED_EDGE) ;
1186 constituent->_entityDimension = 1 ;
1187 constituent->_count[0]=1 ;
1191 // if you declare a variable <i> in two <for> initialization statement,
1192 // compiler gcc2.95.3 says nothing but there are two <i> variables in the same block
1193 //and the value you get in the common block seems to be the value of the first variable !
1196 for ( i=1; i<MED_NBR_GEOMETRIE_MAILLE; i++)
1197 { // no point1 cell type (?)
1198 if (tmpEdgeCount[i]>0)
1201 constituent->_count[typeNumber]=constituent->_count[typeNumber-1]+tmpEdgeCount[i];
1202 CELLMODEL t( (MED_EN::medGeometryElement) MED_MESH_DRIVER22::all_cell_type[i]) ;
1203 constituent->_type[typeNumber-1]=t ;
1205 constituent->_geometricTypes[typeNumber-1]=( MED_EN::medGeometryElement) MED_MESH_DRIVER22::all_cell_type[i] ;
1207 size+=tmpEdgeCount[i]*((MED_MESH_DRIVER22::all_cell_type[i])%100) ;
1212 // Creation of the MEDSKYLINEARRAY
1213 //constituent->_nodal = new MEDSKYLINEARRAY(constituent->_count[constituent->_numberOfTypes]-1,size) ;
1214 //int * NodalIndex = constituent->_nodal->getIndex() ;
1215 int * NodalValue = new int[size] ;
1216 int * NodalIndex = new int[constituent->_count[constituent->_numberOfTypes]] ;
1219 // Fill the MEDSKYLINEARRAY by reading the MED file.
1220 for ( i=0; i<constituent->_numberOfTypes; i++)
1222 med_2_2::med_geometrie_element med_type = (med_2_2::med_geometrie_element) constituent->_type[i].getType() ;
1224 int NumberOfNodeByEdge = constituent->_type[i].getNumberOfNodes() ;
1227 for (int j=constituent->_count[i]; j<constituent->_count[i+1];j++)
1228 NodalIndex[j]=NodalIndex[j-1]+NumberOfNodeByEdge ;
1230 int tmp_numberOfEdges = constituent->_count[i+1]-constituent->_count[i] ;
1231 // Il faut ajouter 1 pour le zero a la lecture !!!
1233 // ATTENTION UNIQUEMENT POUR MED < 2.2.x
1234 int * tmp_constituentArray = NULL;
1236 MESSAGE(LOC << "Med file version used here " << major << " " << minor << " " << release);
1238 if ((major == 2) && (minor <= 1))
1239 tmp_constituentArray = new int[(NumberOfNodeByEdge+1)*tmp_numberOfEdges] ;
1240 else if ((major == 2) && (minor >= 2))
1242 tmp_constituentArray = new int[NumberOfNodeByEdge*tmp_numberOfEdges] ;
1243 MESSAGE(LOC<<": WE ARE USING MED2.2 so there is no +1 for calculating the size of tmp_constituentArray !") ;
1246 int err=MEDconnLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
1247 spaceDimension,tmp_constituentArray,
1248 med_2_2::MED_FULL_INTERLACE,NULL,0,med_2_2::MED_MAILLE,med_type,med_2_2::MED_NOD);
1249 if ( err != MED_VALID)
1251 MESSAGE(LOC<<": MEDconnLire returns "<<err) ;
1252 delete constituent ;
1253 delete[] tmp_constituentArray;
1254 delete[] tmpEdgeCount;
1258 int * constituentArray = NodalValue + NodalIndex[constituent->_count[i]-1]-1 ;
1260 // version originale sans prise en compte des numéros optionnels
1262 int multi = 0; // quand est-ce que multi vaut 1 ?? en MED-fichier < 2.2 ??
1263 MESSAGE(LOC << "Med file version used here " << major << " " << minor << " " << release);
1265 if ((major == 2) && (minor <= 1))
1266 for (int j=0; j<tmp_numberOfEdges; j++)
1267 for (int k=0; k<NumberOfNodeByEdge; k++)
1268 constituentArray[j*NumberOfNodeByEdge+k]=tmp_constituentArray[j*(NumberOfNodeByEdge+multi)+k] ;
1269 else if ((major == 2) && (minor >= 2))
1270 for (int j=0; j<tmp_numberOfEdges; j++)
1271 for (int k=0; k<NumberOfNodeByEdge; k++)
1272 constituentArray[j*NumberOfNodeByEdge+k]=tmp_constituentArray[j*(NumberOfNodeByEdge)+k] ;
1274 //////////////////////////////////////////////////////////////////////////////////////
1275 /// Modification pour prise en compte de la numérotation optionnelle des noeuds ///
1276 //////////////////////////////////////////////////////////////////////////////////////
1278 /// Rénumérote le tableau temporaire tmp_constituentArray en utilisant _optionnalToCanonicNodesNumbers
1279 /// Le traitement est identique à la version originelle s'il n'y a pas de numérotation optionnelle
1281 // if (_ptrMesh->_arePresentOptionnalNodesNumbers)
1283 // for (int j=0; j<tmp_numberOfEdges; j++) for (int k=0; k<NumberOfNodeByEdge; k++)
1284 // constituentArray[j*NumberOfNodeByEdge+k]=_ptrMesh->_optionnalToCanonicNodesNumbers[tmp_constituentArray[j*(NumberOfNodeByEdge+1)+k]] ;
1288 // for (int j=0; j<tmp_numberOfEdges; j++) for (int k=0; k<NumberOfNodeByEdge; k++)
1289 // constituentArray[j*NumberOfNodeByEdge+k]=tmp_constituentArray[j*(NumberOfNodeByEdge+1)+k] ;
1292 //////////////////////////////////////////////////////////////////////////////////////
1294 delete[] tmp_constituentArray;
1297 constituent->_nodal = new MEDSKYLINEARRAY(constituent->_count[constituent->_numberOfTypes]-1,
1302 delete[] NodalIndex ;
1303 delete[] NodalValue ;
1305 if (Connectivity->_entityDimension == 3)
1307 if (Connectivity->_constituent==NULL)
1308 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Edges are defined but there are no Faces !"));
1309 Connectivity->_constituent->_constituent = constituent ;
1311 Connectivity->_constituent = constituent ;
1314 delete[] tmpEdgeCount;
1317 } // end classic geometric types
1318 delete[] tmp_cells_count;
1322 // Lecture des polygones MED_CELL
1323 int NumberOfPolygons = MEDnEntMaa(_medIdt,
1324 const_cast <char *> (_ptrMesh->_name.c_str()),
1327 med_2_2::MED_POLYGONE,
1330 // Correction to permit the loading of mesh dimensionned at 2 even
1331 // if it has only MED_POLYGON elements
1333 if (NumberOfPolygons > 0)
1335 if (Connectivity->_entityDimension < 2) Connectivity->_entityDimension = 2;
1338 if (NumberOfPolygons > 0)
1340 // By consequence this exception will never occur
1341 if (Connectivity->_entityDimension == 1)
1342 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"In a 2D mesh, polygons need at least one 2D cell of a classic geometric type !"));
1343 med_int ConnectivitySize;
1344 med_err err1 = MEDpolygoneInfo(_medIdt,
1345 const_cast <char *> (_ptrMesh->_name.c_str()),
1349 if (err1 != MED_VALID)
1351 MESSAGE(LOC<<": MEDpolygoneInfo returns "<<err1);
1355 med_int* PolygonsConnectivity = new med_int[ConnectivitySize];
1356 med_int* PolygonsConnectivityIndex = new med_int[NumberOfPolygons+1];
1358 med_err err2 = MEDpolygoneConnLire(_medIdt,
1359 const_cast <char *> (_ptrMesh->_name.c_str()),
1360 PolygonsConnectivityIndex,
1362 PolygonsConnectivity,
1365 if (err2 != MED_VALID)
1367 MESSAGE(LOC<<": MEDpolygoneConnLire returns "<<err2);
1371 if (Connectivity->_entityDimension == 2) // 2D mesh : polygons in Connectivity
1372 Connectivity->setPolygonsConnectivity(MED_NODAL,(medEntityMesh) Entity,PolygonsConnectivity,PolygonsConnectivityIndex,ConnectivitySize,NumberOfPolygons);
1373 else if (Connectivity->_entityDimension == 3)
1375 if (Connectivity->_constituent == NULL) // 3D mesh : polygons in Connectivity->_constituent
1376 Connectivity->_constituent = new CONNECTIVITY(MED_FACE);
1377 Connectivity->_constituent->setPolygonsConnectivity(MED_NODAL,MED_FACE,PolygonsConnectivity,PolygonsConnectivityIndex,ConnectivitySize,NumberOfPolygons);
1380 delete[] PolygonsConnectivity;
1381 delete[] PolygonsConnectivityIndex;
1386 // Lecture des polyedres MED_CELL
1387 med_int NumberOfPolyhedron = MEDnEntMaa(_medIdt,
1388 const_cast <char *> (_ptrMesh->_name.c_str()),
1391 med_2_2::MED_POLYEDRE,
1394 // Correction to permit the loading of mesh dimensionned at 3 even
1395 // if it has only MED_POLYEDRE elements
1397 if (NumberOfPolyhedron > 0)
1399 Connectivity->_entityDimension = 3;
1402 if (NumberOfPolyhedron > 0)
1404 // By consequence this exception will never occur
1405 if (Connectivity->_entityDimension == 2 || Connectivity->_entityDimension == 1)
1406 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"In a 3D mesh, polyhedron need at least one 3D cell of a classic geometric type !"));
1407 med_int FacesIndexSize, NumberOfNodes, NumberOfFaces;
1408 med_err err3 = MEDpolyedreInfo(_medIdt,
1409 const_cast <char *> (_ptrMesh->_name.c_str()),
1413 NumberOfFaces = FacesIndexSize-1;
1414 if (err3 != MED_VALID)
1416 MESSAGE(LOC<<": MEDpolyhedreInfo returns "<<err3);
1420 med_int* Nodes = new med_int[NumberOfNodes];
1421 med_int* FacesIndex = new med_int[NumberOfFaces+1];
1422 med_int* PolyhedronIndex = new med_int[NumberOfPolyhedron+1];
1424 med_err err4 = MEDpolyedreConnLire(_medIdt,
1425 const_cast <char *> (_ptrMesh->_name.c_str()),
1427 NumberOfPolyhedron+1,
1432 if (err4 != MED_VALID)
1434 MESSAGE(LOC<<": MEDpolyedreConnLire returns "<<err4);
1438 Connectivity->setPolyhedronConnectivity(MED_NODAL,Nodes,PolyhedronIndex,NumberOfNodes,NumberOfPolyhedron,FacesIndex,NumberOfFaces);
1441 delete[] FacesIndex;
1442 delete[] PolyhedronIndex;
1447 // If there is no nodal connectivity, we return MED_ERROR !
1448 if (Connectivity->_numberOfTypes == 0 && NumberOfPolygons == 0 && NumberOfPolyhedron == 0)
1457 int MED_MESH_RDONLY_DRIVER22::getFAMILY()
1459 const char * LOC = "MED_MESH_RDONLY_DRIVER22::getFAMILY() : " ;
1462 if (_status==MED_OPENED)
1466 int * MEDArrayNodeFamily = NULL ;
1467 int ** MEDArrayCellFamily = NULL ;
1468 int ** MEDArrayFaceFamily = NULL ;
1469 int ** MEDArrayEdgeFamily = NULL ;
1472 MEDArrayNodeFamily = new int[_ptrMesh->getNumberOfNodes()] ;
1474 err = getNodesFamiliesNumber(MEDArrayNodeFamily) ;
1475 // error only if (_status!=MED_OPENED), other case exeception !
1478 MESSAGE(LOC << "error returned from getNodesFamiliesNumber " << err);
1480 MEDArrayCellFamily = new int* [_ptrMesh->getNumberOfTypesWithPoly(MED_CELL)] ;
1481 // ET SI IL N'Y A PAS DE CELLS ?
1483 medGeometryElement * myTypes = _ptrMesh->getTypesWithPoly(MED_CELL);
1484 for (int i=0;i<_ptrMesh->getNumberOfTypesWithPoly(MED_CELL);i++)
1485 MEDArrayCellFamily[i] = new
1486 int[_ptrMesh->getNumberOfElementsWithPoly(MED_CELL,myTypes[i])] ;
1488 err = getCellsFamiliesNumber(MEDArrayCellFamily,
1489 _ptrMesh->_connectivity,MED_CELL) ;
1492 MESSAGE(LOC << "error returned from getCellsFamiliesNumber for Cells " << err);
1494 if (_ptrMesh->_connectivity->_constituent != NULL)
1496 if (_ptrMesh->_connectivity->_constituent->_entity == MED_EN::MED_FACE)
1499 MEDArrayFaceFamily = new
1500 int* [_ptrMesh->getNumberOfTypesWithPoly(MED_FACE)] ;
1502 myTypes = _ptrMesh->getTypesWithPoly(MED_FACE);
1503 for (int i=0;i<_ptrMesh->getNumberOfTypesWithPoly(MED_FACE);i++)
1504 MEDArrayFaceFamily[i] = new
1505 int[_ptrMesh->getNumberOfElementsWithPoly(MED_FACE,myTypes[i])] ;
1508 getCellsFamiliesNumber(MEDArrayFaceFamily,
1509 _ptrMesh->_connectivity->_constituent,MED_FACE) ;
1511 MESSAGE(LOC << "error returned from getCellsFamiliesNumber for Faces " << err);
1516 MEDArrayEdgeFamily = new
1517 int* [_ptrMesh->getNumberOfTypes(MED_EDGE)] ;
1519 const medGeometryElement *myTypes2 = _ptrMesh->getTypes(MED_EDGE);
1520 for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_EDGE);i++)
1521 MEDArrayEdgeFamily[i] = new
1522 int[_ptrMesh->getNumberOfElements(MED_EDGE,myTypes2[i])] ;
1525 getCellsFamiliesNumber(MEDArrayEdgeFamily,
1526 _ptrMesh->_connectivity->_constituent,MED_FACE) ;
1528 MESSAGE(LOC << "error returned from getCellsFamiliesNumber for Edges in 2D " << err);
1531 if (_ptrMesh->_connectivity->_constituent->_constituent != NULL)
1533 MEDArrayEdgeFamily = new
1534 int* [_ptrMesh->getNumberOfTypes(MED_EDGE)] ;
1536 const medGeometryElement *myTypes2 = _ptrMesh->getTypes(MED_EDGE);
1537 for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_EDGE);i++)
1538 MEDArrayEdgeFamily[i] = new
1539 int[_ptrMesh->getNumberOfElements(MED_EDGE,myTypes2[i])] ;
1542 getCellsFamiliesNumber(MEDArrayEdgeFamily,
1543 _ptrMesh->_connectivity->_constituent->_constituent,MED_EDGE);
1546 MESSAGE(LOC << "error returned from getCellsFamiliesNumber for Edges in 3D " << err);
1551 int NumberOfFamilies = med_2_2::MEDnFam(_medIdt, const_cast <char *>
1552 (_meshName.c_str())) ;
1554 if ( NumberOfFamilies < 1 ) // at least family 0 must exist
1555 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"There is no FAMILY, FAMILY 0 must exists" ));
1557 SCRUTE(NumberOfFamilies);
1559 vector<FAMILY*> &NodeFamilyVector = _ptrMesh->_familyNode ;
1560 vector<FAMILY*> &CellFamilyVector = _ptrMesh->_familyCell ;
1561 vector<FAMILY*> &FaceFamilyVector = _ptrMesh->_familyFace ;
1562 vector<FAMILY*> &EdgeFamilyVector = _ptrMesh->_familyEdge ;
1564 int numberOfNodesFamilies = 0 ;
1565 int numberOfCellsFamilies = 0 ;
1566 int numberOfFacesFamilies = 0 ;
1567 int numberOfEdgesFamilies = 0 ;
1569 for (int i=0;i<NumberOfFamilies;i++)
1571 int NumberOfAttributes = med_2_2::MEDnAttribut(_medIdt,
1573 (_meshName.c_str()),
1576 if (NumberOfAttributes < 0)
1577 throw MEDEXCEPTION("MED_MESH_RDONLY_DRIVER22::getFAMILY() : NumberOfAttributes" );
1579 int NumberOfGroups = med_2_2::MEDnGroupe(_medIdt, const_cast <char *>
1580 (_meshName.c_str()),(i+1)) ;
1582 if (NumberOfGroups < 0)
1583 throw MEDEXCEPTION("MED_MESH_RDONLY_DRIVER22::getFAMILY() : NumberOfGroups" );
1585 int FamilyIdentifier ;
1586 string FamilyName(MED_TAILLE_NOM,'\0');
1587 int * AttributesIdentifier = new int[NumberOfAttributes] ;
1588 int * AttributesValues = new int[NumberOfAttributes] ;
1589 string AttributesDescription(MED_TAILLE_DESC*NumberOfAttributes,' ') ;
1590 string GroupsNames(MED_TAILLE_LNOM*NumberOfGroups+1,'\0') ;
1591 err = med_2_2::MEDfamInfo(_medIdt,const_cast <char *>
1592 (_meshName.c_str()),
1593 (i+1),const_cast <char *>
1594 (FamilyName.c_str()), &FamilyIdentifier,
1595 AttributesIdentifier,AttributesValues,
1597 (AttributesDescription.c_str()),
1598 &NumberOfAttributes, const_cast <char *>
1599 (GroupsNames.c_str()),&NumberOfGroups);
1602 SCRUTE(GroupsNames);
1607 if (err != MED_VALID)
1608 throw MEDEXCEPTION("MED_MESH_RDONLY_DRIVER22::getFAMILY() : ERROR when get FAMILY informations" );
1610 if (FamilyIdentifier != 0 )
1612 FAMILY * Family = new FAMILY(_ptrMesh,FamilyIdentifier,FamilyName,
1614 AttributesIdentifier,
1616 AttributesDescription,
1617 NumberOfGroups,GroupsNames,
1621 MEDArrayEdgeFamily) ;
1624 // if nothing found, delete Family
1626 if (Family->getNumberOfTypes() == 0)
1628 MESSAGE(LOC<<"Nothing found for family "<<FamilyName<<
1633 switch (Family->getEntity())
1635 case MED_EN::MED_NODE :
1636 NodeFamilyVector.push_back(Family) ;
1637 numberOfNodesFamilies++ ;
1639 case MED_EN::MED_CELL :
1640 CellFamilyVector.push_back(Family) ;
1641 numberOfCellsFamilies++ ;
1643 case MED_EN::MED_FACE :
1644 FaceFamilyVector.push_back(Family) ;
1645 numberOfFacesFamilies++ ;
1647 case MED_EN::MED_EDGE :
1648 EdgeFamilyVector.push_back(Family) ;
1649 numberOfEdgesFamilies++ ;
1652 // MESSAGE(LOC << (*Family));
1655 delete [] AttributesIdentifier ;
1656 delete [] AttributesValues ;
1659 if (MEDArrayNodeFamily != NULL)
1660 delete[] MEDArrayNodeFamily ;
1662 if (MEDArrayCellFamily != NULL)
1664 for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_CELL);i++)
1665 delete[] MEDArrayCellFamily[i] ;
1666 delete[] MEDArrayCellFamily ;
1669 if (MEDArrayFaceFamily != NULL)
1671 for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_FACE);i++)
1672 delete[] MEDArrayFaceFamily[i] ;
1673 delete[] MEDArrayFaceFamily ;
1676 if (MEDArrayEdgeFamily != NULL)
1678 for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_EDGE);i++)
1679 delete[] MEDArrayEdgeFamily[i] ;
1680 delete[] MEDArrayEdgeFamily ;
1690 int MED_MESH_RDONLY_DRIVER22::getNodesFamiliesNumber(int * MEDArrayNodeFamily)
1692 const char * LOC = "MED_MESH_RDONLY_DRIVER22::getNodesFamiliesNumber() : " ;
1696 if (_status==MED_OPENED)
1700 err = MEDfamLire(_medIdt, const_cast <char *>
1701 (_ptrMesh->_name.c_str()), MEDArrayNodeFamily,
1702 _ptrMesh->getNumberOfNodes(), med_2_2::MED_NOEUD,
1703 (med_2_2::med_geometrie_element) MED_NONE);
1705 if ( err != MED_VALID)
1706 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "There is no family for the |"<< _ptrMesh->getNumberOfNodes() << "| nodes in mesh |" << _ptrMesh->_name.c_str() << "|"));
1715 int MED_MESH_RDONLY_DRIVER22::getCellsFamiliesNumber(int **MEDArrayFamily,
1716 CONNECTIVITY *Connectivity,
1717 MED_EN::medEntityMesh entity)
1719 const char * LOC = "MED_MESH_RDONLY_DRIVER22::getCellsFamiliesNumber " ;
1723 if (_status==MED_OPENED)
1726 MED_EN::medGeometryElement *types=Connectivity->getGeometricTypesWithPoly(Connectivity->_entity);
1727 for (i=0;i<Connectivity->getNumberOfTypesWithPoly(Connectivity->_entity);i++)
1729 int NumberOfCell=Connectivity->getNumberOfElementsWithPoly(Connectivity->_entity,types[i]);
1730 err=MEDfamLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
1731 MEDArrayFamily[i],NumberOfCell,
1732 (med_2_2::med_entite_maillage) Connectivity->_entity,
1733 (med_2_2::med_geometrie_element)types[i]);
1734 if (err != MED_VALID)
1736 err=MEDfamLire(_medIdt,const_cast <char *>
1737 (_ptrMesh->_name.c_str()),
1738 MEDArrayFamily[i],NumberOfCell,
1739 med_2_2::MED_MAILLE,
1740 (med_2_2::med_geometrie_element)types[i]);
1741 if (err != MED_VALID)
1742 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Family not found for entity "<<Connectivity->_entity<<" and geometric type "<<Connectivity->_geometricTypes[i]));
1751 /*--------------------- WRONLY PART -------------------------------*/
1753 MED_MESH_WRONLY_DRIVER22::MED_MESH_WRONLY_DRIVER22()
1757 MED_MESH_WRONLY_DRIVER22::MED_MESH_WRONLY_DRIVER22(const string & fileName,
1759 MED_MESH_DRIVER22(fileName,ptrMesh,MED_WRONLY),IMED_MESH_WRONLY_DRIVER(fileName,ptrMesh),MED_MESH_DRIVER(fileName,ptrMesh,MED_WRONLY)
1761 MESSAGE("MED_MESH_WRONLY_DRIVER22::MED_MESH_WRONLY_DRIVER22(const string & fileName, MESH * ptrMesh) has been created");
1764 MED_MESH_WRONLY_DRIVER22::MED_MESH_WRONLY_DRIVER22(const MED_MESH_WRONLY_DRIVER22 & driver):
1765 IMED_MESH_WRONLY_DRIVER(driver),MED_MESH_DRIVER22(driver),MED_MESH_DRIVER(driver)
1769 MED_MESH_WRONLY_DRIVER22::~MED_MESH_WRONLY_DRIVER22()
1771 //MESSAGE("MED_MESH_WRONLY_DRIVER22::MED_MESH_WRONLY_DRIVER22(const string & fileName, MESH * ptrMesh) has been destroyed");
1774 GENDRIVER * MED_MESH_WRONLY_DRIVER22::copy(void) const
1776 return new MED_MESH_WRONLY_DRIVER22(*this);
1779 void MED_MESH_WRONLY_DRIVER22::write(void) const
1781 const char * LOC = "void MED_MESH_WRONLY_DRIVER22::write(void) const : ";
1784 // we must first create mesh !!
1785 MESSAGE(LOC << "MeshName : |" << _meshName << "| FileName : |"<<_fileName<<"| MedIdt : | "<< _medIdt << "|");
1787 if (_status!=MED_OPENED)
1788 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "File "<<_fileName<<" is not open. Open it before write !"));
1790 if (_ptrMesh->getIsAGrid())
1792 if ( writeGRID() != MED_VALID )
1793 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeGRID()" )) ;
1797 if (writeCoordinates()!=MED_VALID)
1798 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeCoordinates()" )) ;
1800 if (writeConnectivities(MED_EN::MED_CELL)!=MED_VALID)
1801 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeConnectivities(MED_CELL)" )) ;
1802 if (writeConnectivities(MED_EN::MED_FACE)!=MED_VALID)
1803 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeConnectivities(MED_FACE)" )) ;
1804 if (writeConnectivities(MED_EN::MED_EDGE)!=MED_VALID)
1805 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeConnectivities(MED_EDGE)" )) ;
1808 if (writeFamilyNumbers() !=MED_VALID)
1809 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilyNumbers()" )) ;
1812 // well we must first write zero family :
1813 if (_status==MED_OPENED) {
1815 // test if the family already exists (HDF trick waiting a MED evolution to be replaced)
1816 string dataGroupFam = "/ENS_MAA/"+_meshName+"/FAS/FAMILLE_ZERO/";
1817 MESSAGE("|"<<dataGroupFam<<"|");
1818 err =med_2_2::_MEDdatagroupOuvrir(_medIdt,const_cast <char *> (dataGroupFam.c_str()) );
1819 if ( err < MED_VALID ) {
1822 char familyName[MED_TAILLE_NOM+1];
1823 // strcpy(familyName,"FAMILLE_ZERO");
1824 err = med_2_2::MEDfamCr( _medIdt,
1825 const_cast <char *> ( _meshName.c_str() ),
1827 (int*)NULL, (int*)NULL, (char*)NULL, 0,
1832 if ( err != MED_VALID)
1833 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't create family |FAMILLE_ZERO| with identifier |0| groups names || and attributes descriptions ||")) ;
1836 med_2_2::_MEDdatagroupFermer(_medIdt);
1840 MESSAGE(LOC<<"writeFamilies(_ptrMesh->_familyNode)");
1841 if (writeFamilies(_ptrMesh->_familyNode) !=MED_VALID)
1842 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilies(_ptrMesh->_familyNode)" )) ;
1844 MESSAGE(LOC<<"writeFamilies(_ptrMesh->_familyCell)");
1845 if (writeFamilies(_ptrMesh->_familyCell) !=MED_VALID)
1846 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilies(_ptrMesh->_familyCell)" )) ;
1848 MESSAGE(LOC<<"writeFamilies(_ptrMesh->_familyFace)");
1849 if (writeFamilies(_ptrMesh->_familyFace) !=MED_VALID)
1850 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilies(_ptrMesh->_familyFace)" )) ;
1852 MESSAGE(LOC<<"writeFamilies(_ptrMesh->_familyEdge)");
1853 if (writeFamilies(_ptrMesh->_familyEdge) !=MED_VALID)
1854 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilies(_ptrMesh->_familyEdge)" )) ;
1859 //=======================================================================
1860 //function : writeGRID
1862 //=======================================================================
1864 int MED_MESH_WRONLY_DRIVER22::writeGRID() const
1866 const char * LOC = "MED_MESH_WRONLY_DRIVER22::writeGRID() : " ;
1869 if (_status!=MED_OPENED)
1871 MESSAGE (LOC<<" Not open !!!");
1874 GRID * ptrGrid = (GRID*) _ptrMesh;
1876 med_2_2::med_err err = MED_ERROR;
1877 med_2_2::med_repere rep;
1878 string tmp_name(_ptrMesh->_spaceDimension*MED_TAILLE_PNOM22,' ');
1879 string tmp_unit(_ptrMesh->_spaceDimension*MED_TAILLE_PNOM22,' ');
1881 // Test if the mesh <_meshName> already exists
1882 // If it doesn't exists create it
1883 // If it already exists verify if its space and mesh dimensions are the same
1884 // as <_ptrMesh->_spaceDimension>, <_ptrMesh->_meshDimension> respectively
1885 // rem : <_meshName> is the driver meshName not <ptrMesh->_meshName>
1887 int spaceDimension = med_2_2::MEDdimEspaceLire(_medIdt, const_cast <char *>
1888 (_meshName.c_str()) );
1890 int meshDimension = med_2_2::MEDdimLire(_medIdt, const_cast <char *>
1891 (_meshName.c_str()) );
1894 MESSAGE(LOC << "spacedim " << spaceDimension << " meshdim " << meshDimension);
1896 MESSAGE(LOC << "From the mesh spacedim " << _ptrMesh->_spaceDimension << " meshdim " << _ptrMesh->_meshDimension);
1898 if ((spaceDimension <= MED_VALID) && (meshDimension <= MED_VALID))
1900 err = MEDmaaCr(_medIdt,
1901 const_cast <char *> (_meshName.c_str()),
1902 _ptrMesh->_meshDimension,med_2_2::MED_STRUCTURE,
1903 const_cast <char *> (_ptrMesh->_description.c_str()));
1905 meshDimension = _ptrMesh->_meshDimension;
1907 if (err != MED_VALID)
1908 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Unable to create Grid"));
1910 MESSAGE(LOC<<"Grid "<<_meshName<<" created in file "<<_fileName<<" !");
1912 else if ((spaceDimension != _ptrMesh->_spaceDimension) &&
1913 (meshDimension != _ptrMesh->_meshDimension))
1914 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Grid |" << _meshName.c_str() <<
1915 "| already exists in file |" << _fileName <<
1916 "| with space dimension |" << spaceDimension <<
1917 "| and mesh dimension |" << meshDimension <<
1918 "| but the space dimension and the mesh dimension of the mesh we want to write are respectively |"
1919 << _ptrMesh->_spaceDimension <<"|" <<
1920 _ptrMesh->_meshDimension <<"|" )) ;
1922 MED_EN::med_grid_type gridType = ptrGrid->getGridType();
1924 err = med_2_2::MEDnatureGrilleEcr(_medIdt,
1925 const_cast <char *> (_meshName.c_str()),
1926 (med_2_2::med_type_grille) gridType);
1928 if (err != MED_VALID)
1929 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Unable to write the type of the Grid"));
1931 // Recompose the <_spaceDimension> strings in 1 string
1933 string valueString ;
1934 for (int i=0;i<_ptrMesh->_spaceDimension;i++) {
1936 valueString = _ptrMesh->_coordinate->_coordinateName[i] ;
1937 lengthString = (MED_TAILLE_PNOM22<valueString.size())?MED_TAILLE_PNOM22:valueString.size() ;
1938 tmp_name.replace(i*MED_TAILLE_PNOM22,i*MED_TAILLE_PNOM22+lengthString,valueString,0,lengthString);
1939 valueString = _ptrMesh->_coordinate->_coordinateUnit[i];
1940 lengthString = (MED_TAILLE_PNOM22<valueString.size())?MED_TAILLE_PNOM22:valueString.size() ;
1941 tmp_unit.replace(i*MED_TAILLE_PNOM22,i*MED_TAILLE_PNOM22+lengthString,valueString,0,lengthString);
1944 // Pourquoi le stocker sous forme de chaîne ?
1945 const string & coordinateSystem = _ptrMesh->_coordinate->_coordinateSystem;
1946 if (coordinateSystem == "CARTESIAN")
1947 rep = med_2_2::MED_CART;
1948 else if ( coordinateSystem == "CYLINDRICAL")
1949 rep = med_2_2::MED_CYL;
1950 else if ( coordinateSystem == "SPHERICAL" )
1951 rep = med_2_2::MED_SPHER;
1953 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Grid |" << _meshName.c_str() <<
1954 "| doesn't have a valid coordinate system : |"
1955 << _ptrMesh->_coordinate->_coordinateSystem
1958 med_2_2::med_int ArrayLen[] = { (med_2_2::med_int) ptrGrid->_iArrayLength,
1959 (med_2_2::med_int) ptrGrid->_jArrayLength,
1960 (med_2_2::med_int) ptrGrid->_kArrayLength };
1962 // Write node coordinates for MED_BODY_FITTED grid
1963 if (gridType == MED_EN::MED_BODY_FITTED)
1965 // Write Coordinates and families
1966 // double * coo = const_cast <double *>
1967 // (_ptrMesh->_coordinate->getCoordinates(MED_EN::MED_FULL_INTERLACE));
1969 err = MEDcoordEcr(_medIdt, const_cast <char *> (_meshName.c_str()),
1970 _ptrMesh->_spaceDimension,
1971 //const_cast <double *> ( _ptrMesh->_coordinate->_coordinate->get(MED_EN::MED_FULL_INTERLACE) ),
1972 const_cast <double *> ( _ptrMesh->_coordinate->_coordinate.get(MED_EN::MED_FULL_INTERLACE) ),
1973 med_2_2::MED_FULL_INTERLACE, _ptrMesh->_numberOfNodes,
1974 // _ptrMesh->_coordinate->_numberOfNodes
1975 rep, const_cast <char *> (tmp_name.c_str()),
1976 const_cast <char *> (tmp_unit.c_str()));
1978 if (err != MED_VALID)
1979 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write coordinates of the grid |" << _meshName.c_str() << "| in file |" << _fileName
1980 << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
1981 << " with units names |" << tmp_name
1982 << "| and units |" << tmp_unit
1985 int* structure = new int [meshDimension];
1987 for (int idim = 0; idim < meshDimension; ++idim)
1988 structure[idim] = ArrayLen [idim];
1991 err = med_2_2::MEDstructureCoordEcr(_medIdt, const_cast <char *>
1992 (_meshName.c_str()), meshDimension,
1995 if (err != MED_VALID)
1996 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"error in writing the structure of the grid |" << _meshName.c_str()));
2000 else if ((gridType == MED_EN::MED_CARTESIAN) ||
2001 (gridType == MED_EN::MED_POLAR))
2003 // Write Arrays of Cartesian or Polar Grid
2005 double * Array[] = { ptrGrid->_iArray,
2009 for (int idim = 0; idim < _ptrMesh->_meshDimension; ++idim)
2011 string str_name = string (tmp_name,idim*MED_TAILLE_PNOM22,
2013 string str_unit = string (tmp_unit,idim*MED_TAILLE_PNOM22,
2016 err = med_2_2::MEDindicesCoordEcr(_medIdt, const_cast <char *>
2017 (_ptrMesh->_name.c_str()),
2018 _ptrMesh->_meshDimension,
2019 Array[idim], ArrayLen[idim],
2020 (idim+1), const_cast <char *>
2023 (str_unit.c_str()));
2025 if (err != MED_VALID)
2026 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<
2027 "Can't write grid coordinates for " <<
2028 idim << "-th dimention"));
2030 } // end Write Cartesian or Polar Grid
2036 //=======================================================================
2037 //function : writeCoordinates
2039 //=======================================================================
2041 int MED_MESH_WRONLY_DRIVER22::writeCoordinates() const {
2043 const char * LOC = "int MED_MESH_WRONLY_DRIVER22::writeCoordinates() const : ";
2046 med_2_2::med_err err = MED_ERROR;
2047 med_2_2::med_repere rep;
2048 string tmp_name(_ptrMesh->_spaceDimension*MED_TAILLE_PNOM22,' ');
2049 string tmp_unit(_ptrMesh->_spaceDimension*MED_TAILLE_PNOM22,' ');
2051 // Recompose the <_spaceDimension> strings in 1 string
2053 string valueString ;
2054 for (int i=0;i<_ptrMesh->_spaceDimension;i++) {
2055 valueString = _ptrMesh->_coordinate->_coordinateName[i] ;
2056 lengthString = (MED_TAILLE_PNOM22<valueString.size())?MED_TAILLE_PNOM22:valueString.size() ;
2057 tmp_name.replace(i*MED_TAILLE_PNOM22,i*MED_TAILLE_PNOM22+lengthString,valueString,0,lengthString);
2058 valueString = _ptrMesh->_coordinate->_coordinateUnit[i];
2059 lengthString = (MED_TAILLE_PNOM22<valueString.size())?MED_TAILLE_PNOM22:valueString.size() ;
2060 tmp_unit.replace(i*MED_TAILLE_PNOM22,i*MED_TAILLE_PNOM22+lengthString,valueString,0,lengthString);
2063 // Test if the mesh <_meshName> already exists
2064 // If it doesn't exists create it
2065 // If it already exists verify if its space and mesh dimensions are the same
2066 // as <_ptrMesh->_spaceDimension>, <_ptrMesh->_meshDimension> respectively
2067 // rem : <_meshName> is the driver meshName not <ptrMesh->_meshName>
2069 int spaceDimension = med_2_2::MEDdimEspaceLire(_medIdt, const_cast <char *>
2070 (_meshName.c_str()));
2072 int meshDimension = med_2_2::MEDdimLire(_medIdt, const_cast <char *>
2073 (_meshName.c_str()) );
2075 if ((spaceDimension != MED_VALID) && (meshDimension != MED_VALID))
2077 err = MEDmaaCr(_medIdt, const_cast <char *> (_meshName.c_str()),
2078 _ptrMesh->_meshDimension, med_2_2::MED_NON_STRUCTURE,
2079 const_cast <char *> (_ptrMesh->_description.c_str()));
2081 if (err != MED_VALID)
2082 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Unable to create Mesh : |" << _meshName << "|"));
2084 MESSAGE(LOC<<"Mesh "<<_meshName<<" created in file "<<_fileName<<" !");
2086 else if ((spaceDimension != _ptrMesh->_spaceDimension) &&
2087 (meshDimension != _ptrMesh->_meshDimension))
2088 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Mesh |" << _meshName.c_str() <<
2089 "| already exists in file |" << _fileName <<
2090 "| with space dimension |" << spaceDimension <<
2091 "| and mesh dimension |" << meshDimension <<
2092 "| but the space dimension and the mesh dimension of the mesh we want to write are respectively |"
2093 << _ptrMesh->_spaceDimension <<"|" <<
2094 _ptrMesh->_meshDimension << "|")) ;
2096 // Pourquoi le stocker sous forme de chaîne ?
2097 const string & coordinateSystem = _ptrMesh->_coordinate->_coordinateSystem;
2098 if (coordinateSystem == "CARTESIAN")
2099 rep = med_2_2::MED_CART;
2100 else if ( coordinateSystem == "CYLINDRICAL")
2101 rep = med_2_2::MED_CYL;
2102 else if ( coordinateSystem == "SPHERICAL" )
2103 rep = med_2_2::MED_SPHER;
2105 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Mesh |" << _meshName.c_str() << "| doesn't have a valid coordinate system : |"
2106 << _ptrMesh->_coordinate->_coordinateSystem
2109 // err = MEDcoordEcr(_medIdt, const_cast <char *> (_meshName.c_str()),
2110 // _ptrMesh->_spaceDimension,
2111 // //const_cast <double *> ( _ptrMesh->_coordinate->_coordinate->get(MED_EN::MED_FULL_INTERLACE) ),
2112 // const_cast <double *> ( _ptrMesh->_coordinate->_coordinate.get(MED_EN::MED_FULL_INTERLACE) ),
2113 // MED_FR::MED_FULL_INTERLACE,
2114 // _ptrMesh->_numberOfNodes, // _ptrMesh->_coordinate->_numberOfNodes
2115 // MED_FR::MED_LECTURE_ECRITURE,
2117 // const_cast <char *> (tmp_name.c_str()),
2118 // const_cast <char *> (tmp_unit.c_str())
2121 err = MEDcoordEcr(_medIdt, const_cast <char *> (_meshName.c_str()),
2122 _ptrMesh->_spaceDimension,
2123 //const_cast <double *> ( _ptrMesh->_coordinate->_coordinate->get(MED_EN::MED_FULL_INTERLACE) ),
2124 const_cast <double *> ( _ptrMesh->_coordinate->_coordinate.get(MED_EN::MED_FULL_INTERLACE) ),
2125 med_2_2::MED_FULL_INTERLACE, _ptrMesh->_numberOfNodes,
2126 // _ptrMesh->_coordinate->_numberOfNodes
2127 rep, const_cast <char *> (tmp_name.c_str()),
2128 const_cast <char *> (tmp_unit.c_str()));
2131 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write coordinates of mesh |" << _meshName.c_str() << "| in file |" << _fileName
2132 << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
2133 << " with units names |" << tmp_name
2134 << "| and units |" << tmp_unit
2138 //////////////////////////////////////////////////////////////////////////////////////
2139 /// Modification pour prise en compte de la numérotation optionnelle des noeuds ///
2140 //////////////////////////////////////////////////////////////////////////////////////
2142 /// Ecrit les numéros optionnels des noeuds
2143 /// Le traitement est identique à la version originelle s'il n'y a pas de numérotation optionnelle
2146 if (_ptrMesh->_arePresentOptionnalNodesNumbers==1) {
2148 err = MEDnumEcr(_medIdt, const_cast <char *> (_meshName.c_str()),
2149 const_cast <med_int *> (_ptrMesh->_coordinate->getNodesNumbers() ),
2150 _ptrMesh->_numberOfNodes, med_2_2::MED_NOEUD,
2151 med_2_2::med_geometrie_element(0) );
2153 if (err != MED_VALID)
2154 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write optionnal numbers of mesh |" <<
2155 _meshName.c_str() << "| in file |" <<
2156 _fileName << " |")) ;
2158 //////////////////////////////////////////////////////////////////////////////////////
2168 int MED_MESH_WRONLY_DRIVER22::writeConnectivities(medEntityMesh entity) const
2170 const char * LOC="int MED_MESH_WRONLY_DRIVER22::writeConnectivities() const : ";
2173 med_2_2::med_err err;
2175 // REM SI LA METHODE EST APPELEE DIRECTEMENT ET QUE LE MAILLAGE N'EST PAS CREE IL Y A PB !
2176 // PG : IMPOSSIBLE : LA METHODE EST PRIVEE !
2178 // A FAIRE : A tester surtout dans les methodes de MESH.
2179 // if ( _ptrMesh->_connectivity == (CONNECTIVITY *) MED_INVALID )
2180 if ( _ptrMesh->_connectivity == (CONNECTIVITY *) NULL )
2181 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The connectivity is not defined in the MESH object ")) ;
2184 // Nodal connectivity for classic geometric types
2185 if ( _ptrMesh->existConnectivity(MED_NODAL,entity) )
2188 int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ;
2189 const medGeometryElement * types = _ptrMesh->getTypes (entity) ;
2191 for (int i=0; i<numberOfTypes; i++)
2194 int numberOfElements = _ptrMesh->getNumberOfElements (entity,types[i]);
2195 const int * connectivity = _ptrMesh->getConnectivity (MED_EN::MED_FULL_INTERLACE,
2196 MED_NODAL, entity, types[i]); // ?? et SI MED_NODAL n'existe pas, recalcul auto ??
2198 // Pour l'instant la class utilise le multi.....
2200 // if (entity==MED_EN::MED_CELL)
2201 // if ( (types[i]/ 100) < _ptrMesh->_spaceDimension)
2203 int numberOfNodes = types[i]%100 ;
2204 int * connectivityArray = new int[numberOfElements*(numberOfNodes+multi)];
2206 // version originale sans prise en compte des numéros optionnels
2208 for (int j=0 ; j<numberOfElements; j++)
2210 for (int k=0; k<numberOfNodes; k++)
2211 connectivityArray[j*(numberOfNodes+multi)+k]=connectivity[j*numberOfNodes+k] ;
2213 if (multi>0) connectivityArray[j*(numberOfNodes+multi)+numberOfNodes]=0;
2216 //////////////////////////////////////////////////////////////////////////////////////
2217 /// Modification pour prise en compte de la numérotation optionnelle des noeuds ///
2218 //////////////////////////////////////////////////////////////////////////////////////
2220 /// Dénumérote les sommets des mailles pour leur rendre leurs numéros optionnels
2221 /// Le traitement est identique à la version originelle s'il n'y a pas de numérotation optionnelle
2223 // if (_ptrMesh->_arePresentOptionnalNodesNumbers==1)
2225 // const int * nodesNumbers = _ptrMesh->_coordinate->getNodesNumbers();
2226 // for (int j=0 ; j<numberOfElements; j++)
2228 // for (int k=0; k<numberOfNodes; k++) connectivityArray[j*(numberOfNodes+multi)+k]=nodesNumbers[connectivity[j*numberOfNodes+k]-1] ;
2229 // if (multi>0) connectivityArray[j*(numberOfNodes+multi)+numberOfNodes]=0;
2234 // for (int j=0 ; j<numberOfElements; j++)
2236 // for (int k=0; k<numberOfNodes; k++) connectivityArray[j*(numberOfNodes+multi)+k]=connectivity[j*numberOfNodes+k] ;
2237 // if (multi>0) connectivityArray[j*(numberOfNodes+multi)+numberOfNodes]=0;
2241 //////////////////////////////////////////////////////////////////////////////////////
2243 // err = MEDconnEcr( _medIdt, const_cast <char *> ( _meshName.c_str()), _ptrMesh->_spaceDimension,
2244 // connectivityArray, MED_FR::MED_FULL_INTERLACE , numberOfElements,
2245 // MED_FR::MED_LECTURE_ECRITURE,
2246 // (MED_FR::med_entite_maillage ) entity,
2247 // (MED_FR::med_geometrie_element) types[i], MED_FR::MED_NOD );
2249 // err = MEDconnEcr(_medIdt, const_cast <char *> ( _meshName.c_str()),
2250 // _ptrMesh->_spaceDimension, connectivityArray,
2251 // MED_FR::MED_FULL_INTERLACE , numberOfElements,
2252 // (MED_FR::med_entite_maillage ) entity,
2253 // (MED_FR::med_geometrie_element) types[i],
2254 // med_2_2::MED_NOD);
2256 err = MEDconnEcr(_medIdt, const_cast <char *> ( _meshName.c_str()),
2257 _ptrMesh->_spaceDimension, connectivityArray,
2258 med_2_2::MED_FULL_INTERLACE , numberOfElements,
2259 (med_2_2::med_entite_maillage ) MED_CELL,
2260 (med_2_2::med_geometrie_element) types[i],
2263 delete[] connectivityArray ;
2265 if (err<0) // ETENDRE LES EXPLICATIONS
2266 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write connectivities of mesh |" << _meshName.c_str() << "| in file |" << _fileName
2267 << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
2275 if (_ptrMesh->existPolygonsConnectivity(MED_NODAL,entity))
2277 err = MEDpolygoneConnEcr(_medIdt,
2278 const_cast <char *> (_meshName.c_str()),
2279 const_cast <med_int*> (_ptrMesh->getPolygonsConnectivityIndex(MED_NODAL,entity)),
2280 _ptrMesh->getNumberOfPolygons()+1,
2281 const_cast <med_int*> (_ptrMesh->getPolygonsConnectivity(MED_NODAL,entity)),
2282 (med_2_2::med_entite_maillage) entity,
2286 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write polygons nodal connectivities of mesh |" << _meshName.c_str() << "| in file |" << _fileName
2287 << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
2292 // Polyhedron writing
2293 if (_ptrMesh->existPolyhedronConnectivity(MED_NODAL,entity))
2295 err = MEDpolyedreConnEcr(_medIdt,
2296 const_cast <char *> (_meshName.c_str()),
2297 const_cast <med_int*> (_ptrMesh->getPolyhedronIndex(MED_NODAL)),
2298 _ptrMesh->getNumberOfPolyhedron()+1,
2299 const_cast <med_int*> (_ptrMesh->getPolyhedronFacesIndex()),
2300 _ptrMesh->getNumberOfPolyhedronFaces()+1,
2301 const_cast <med_int*> (_ptrMesh->getPolyhedronConnectivity(MED_NODAL)),
2305 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write polyhedron nodal connectivities of mesh |" << _meshName.c_str() << "| in file |" << _fileName
2306 << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
2311 // Descending connectivity for classic geometric types
2312 if ( _ptrMesh->existConnectivity(MED_DESCENDING,entity) )
2315 int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ;
2316 const medGeometryElement * types = _ptrMesh->getTypes (entity) ;
2318 for (int i=0; i<numberOfTypes; i++)
2321 int numberOfElements = _ptrMesh->getNumberOfElements (entity,types[i]);
2322 const int * connectivity = _ptrMesh->getConnectivity(MED_EN::MED_FULL_INTERLACE, MED_DESCENDING, entity, types[i]);
2324 // Pour l'instant la class utilise le multi.....
2325 // err = MED_FR::MEDconnEcr( _medIdt,
2326 // const_cast <char *> ( _meshName.c_str()),
2327 // _ptrMesh->_spaceDimension,
2328 // const_cast <int *> (connectivity),
2329 // MED_FR::MED_FULL_INTERLACE,
2330 // numberOfElements,
2331 // MED_FR::MED_LECTURE_ECRITURE,
2332 // (MED_FR::med_entite_maillage ) entity,
2333 // (MED_FR::med_geometrie_element) types[i],
2334 // MED_FR::MED_DESC );
2336 err = med_2_2::MEDconnEcr(_medIdt,
2337 const_cast <char *> ( _meshName.c_str()),
2338 _ptrMesh->_spaceDimension,
2339 const_cast <int *> (connectivity),
2340 med_2_2::MED_FULL_INTERLACE,
2342 (med_2_2::med_entite_maillage ) entity,
2343 (med_2_2::med_geometrie_element) types[i],
2344 med_2_2::MED_DESC );
2346 if (err<0) // ETENDRE LES EXPLICATIONS
2347 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write connectivities of mesh |" << _meshName.c_str() << "| in file |" << _fileName
2348 << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
2356 if (_ptrMesh->existPolygonsConnectivity(MED_DESCENDING,entity))
2358 err = MEDpolygoneConnEcr(_medIdt,
2359 const_cast <char *> (_meshName.c_str()),
2360 const_cast <med_int*> (_ptrMesh->getPolygonsConnectivityIndex(MED_DESCENDING,entity)),
2361 _ptrMesh->getNumberOfPolygons()+1,
2362 const_cast <med_int*> (_ptrMesh->getPolygonsConnectivity(MED_DESCENDING,entity)),
2363 (med_2_2::med_entite_maillage) entity,
2367 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write polygons descending connectivities of mesh |" << _meshName.c_str() << "| in file |" << _fileName
2368 << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
2373 // Polyhedron writing
2374 if (_ptrMesh->existPolyhedronConnectivity(MED_DESCENDING,entity))
2376 med_int NumberOfFaces = _ptrMesh->getPolyhedronIndex(MED_DESCENDING)[_ptrMesh->getNumberOfPolyhedron()]-1;
2377 vector<med_int> FacesGeometricTypes(NumberOfFaces,MED_POLYGON); // by default all polyhedron faces are polygons
2379 err = MEDpolyedreConnEcr(_medIdt,
2380 const_cast <char *> (_meshName.c_str()),
2381 const_cast <med_int*> (_ptrMesh->getPolyhedronIndex(MED_DESCENDING)),
2382 _ptrMesh->getNumberOfPolyhedron()+1,
2383 &FacesGeometricTypes[0],
2385 const_cast <med_int*> (_ptrMesh->getPolyhedronConnectivity(MED_DESCENDING)),
2389 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write polyhedron descending connectivities of mesh |" << _meshName.c_str() << "| in file |" << _fileName
2390 << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
2399 int MED_MESH_WRONLY_DRIVER22::writeFamilyNumbers() const {
2401 const char * LOC="int MED_MESH_WRONLY_DRIVER22::writeFamilyNumbers() const : ";
2404 med_2_2::med_err err;
2406 // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArrayNodeFamily DOIT ETRE ENLEVER DE LA CLASSE MESH
2408 { // Node related block
2410 // We build the array from the families list objects :
2411 int NumberOfNodes = _ptrMesh->getNumberOfNodes() ;
2412 int * MEDArrayNodeFamily = new int[NumberOfNodes] ;
2413 // family 0 by default
2414 for (int i=0; i<NumberOfNodes; i++)
2415 MEDArrayNodeFamily[i]=0;
2416 //vector<FAMILY*> myFamilies = _ptrMesh->getFamilies(MED_NODE);
2417 vector<FAMILY*> * myFamilies = &_ptrMesh->_familyNode;
2418 int NumberOfNodesFamilies = myFamilies->size() ;
2419 //bool ToDestroy = false;
2420 if (0 == NumberOfNodesFamilies) {
2421 //ToDestroy = true ;
2422 vector<GROUP*> myGroups = _ptrMesh->getGroups(MED_NODE);
2423 int NumberOfGroups = myGroups.size() ;
2424 // build families from groups
2425 for (int i=0; i<NumberOfGroups; i++) {
2426 SUPPORT * mySupport = myGroups[i] ;
2427 FAMILY* myFamily = new FAMILY(*mySupport);
2428 myFamily->setIdentifier(i+1);
2429 myFamilies->push_back(myFamily);
2431 NumberOfNodesFamilies=myFamilies->size() ;
2433 for (int i=0 ; i<NumberOfNodesFamilies; i++) {
2435 //SCRUTE(myFamilies[i]->getName());
2436 int FamilyIdentifier = (*myFamilies)[i]->getIdentifier() ;
2437 int TotalNumber = (*myFamilies)[i]->getNumberOfElements(MED_ALL_ELEMENTS) ;
2438 if ((*myFamilies)[i]->isOnAllElements())
2439 for (int j=0; j<TotalNumber; j++)
2440 MEDArrayNodeFamily[j]=FamilyIdentifier;
2442 const int * Number = (*myFamilies)[i]->getNumber(MED_ALL_ELEMENTS) ;
2443 for (int j=0; j<TotalNumber; j++)
2444 MEDArrayNodeFamily[Number[j]-1]=FamilyIdentifier ;
2448 for(int j=0; j<NumberOfNodes; j++) {
2449 SCRUTE(MEDArrayNodeFamily[j]);
2452 // if ( !_ptrMesh->getIsAGrid() )
2454 err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
2455 MEDArrayNodeFamily, NumberOfNodes, med_2_2::MED_NOEUD,
2456 (med_2_2::med_geometrie_element) MED_NONE);
2459 // err = MEDfamGridEcr(_medIdt,
2460 // const_cast <char *> (_ptrMesh->_name.c_str()),
2461 // MEDArrayNodeFamily,
2463 // MED_FR::MED_LECTURE_ECRITURE,
2464 // MED_FR::MED_NOEUD);
2466 if ( err != MED_VALID)
2467 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write node family for the |"<< NumberOfNodes
2468 << "| nodes in mesh |"
2469 << _ptrMesh->_name.c_str() << "|" ));
2470 delete[] MEDArrayNodeFamily;
2471 //if (true == ToDestroy)
2472 // for (int i=0; i<NumberOfNodesFamilies; i++)
2473 // delete myFamilies[i];
2476 { // CELLS RELATED BLOCK
2477 medEntityMesh entity=MED_EN::MED_CELL;
2478 // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArray____Family DOIT ETRE ENLEVER DE LA CLASSE MESH
2479 if ( ( _ptrMesh->existConnectivity(MED_NODAL,entity) )|( _ptrMesh->existConnectivity(MED_DESCENDING,entity) ) ) {
2481 int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ;
2482 const medGeometryElement * types = _ptrMesh->getTypes (entity) ;
2484 // We build the array from the families list objects :
2485 int NumberOfElements = _ptrMesh->getNumberOfElements(entity, MED_ALL_ELEMENTS);
2486 int * MEDArrayFamily = new int[NumberOfElements] ;
2487 // family 0 by default
2488 for (int i=0; i<NumberOfElements; i++)
2489 MEDArrayFamily[i]=0;
2490 //vector<FAMILY*> myFamilies = _ptrMesh->getFamilies(entity);
2491 vector<FAMILY*> * myFamilies = &_ptrMesh->_familyCell ;
2492 int NumberOfFamilies = myFamilies->size() ;
2493 //bool ToDestroy = false;
2494 if (0 == NumberOfFamilies) {
2495 //ToDestroy = true ;
2496 vector<GROUP*> myGroups = _ptrMesh->getGroups(entity);
2497 int NumberOfGroups = myGroups.size() ;
2498 // build families from groups
2499 for (int i=0; i<NumberOfGroups; i++) {
2500 SCRUTE( myGroups[i]->getName() );
2501 SUPPORT * mySupport = myGroups[i] ;
2502 FAMILY* myFamily = new FAMILY(*mySupport);
2503 myFamily->setIdentifier(-i-1);
2504 myFamilies->push_back(myFamily);
2506 NumberOfFamilies=myFamilies->size() ;
2508 for (int i=0 ; i<NumberOfFamilies; i++) {
2509 int FamilyIdentifier = (*myFamilies)[i]->getIdentifier() ;
2510 int TotalNumber = (*myFamilies)[i]->getNumberOfElements(MED_ALL_ELEMENTS) ;
2511 if ((*myFamilies)[i]->isOnAllElements())
2512 for (int ii=0; ii<TotalNumber; ii++)
2513 MEDArrayFamily[ii]=FamilyIdentifier;
2515 const int * Number = (*myFamilies)[i]->getNumber(MED_ALL_ELEMENTS) ;
2516 for (int ii=0; ii<TotalNumber; ii++)
2517 MEDArrayFamily[Number[ii]-1]=FamilyIdentifier ;
2521 const int * typeCount = _ptrMesh->getGlobalNumberingIndex(entity) ;
2522 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
2523 int lgth=NumberOfElements;
2524 med_2_2::med_int *temp=new med_2_2::med_int[lgth];
2525 for(int i2=0;i2<lgth;i2++)
2526 temp[i2]=(med_2_2::med_int) (MEDArrayFamily[i2]);
2528 for (int i=0; i<numberOfTypes; i++) {
2529 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
2530 err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
2531 temp+typeCount[i]-1,typeCount[i+1]-typeCount[i],
2533 (med_2_2::med_entite_maillage) entity,
2534 (med_2_2::med_geometrie_element) types[i]
2537 err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
2538 (MEDArrayFamily+typeCount[i]-1),
2539 (typeCount[i+1]-typeCount[i]),
2540 (med_2_2::med_entite_maillage) entity,
2541 (med_2_2::med_geometrie_element) types[i]);
2544 if ( err != MED_VALID)
2545 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write family for the |"<< _ptrMesh->getNumberOfElements(entity, types[i])
2546 << "| cells of geometric type |" << geoNames[types[i]] <<"|in mesh |"
2547 << _ptrMesh->_name.c_str() << "|" ));
2549 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
2552 delete[] MEDArrayFamily ;
2553 //if (true == ToDestroy) {
2554 // int NumberOfFamilies = myFamilies->size();
2555 // for (int i=0; i<NumberOfFamilies; i++)
2556 // delete myFamilies[i];
2561 { // FACE RELATED BLOCK
2562 medEntityMesh entity=MED_EN::MED_FACE;
2563 // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArray____Family DOIT ETRE ENLEVER DE LA CLASSE MESH
2564 if ( ( _ptrMesh->existConnectivity(MED_NODAL,entity) )|( _ptrMesh->existConnectivity(MED_DESCENDING,entity) ) ) {
2566 int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ;
2567 const medGeometryElement * types = _ptrMesh->getTypes (entity) ;
2568 SCRUTE(numberOfTypes);
2570 int numberOfElements = _ptrMesh->getNumberOfElements(entity, MED_ALL_ELEMENTS) ;
2571 int * familyArray = new int[numberOfElements] ;
2572 for (int i=0;i<numberOfElements;i++)
2575 int numberOfFamilies = _ptrMesh->getNumberOfFamilies(entity) ;
2576 //vector<FAMILY*> myFamilies = _ptrMesh->getFamilies(entity) ;
2577 vector<FAMILY*> * myFamilies = &_ptrMesh->_familyFace ;
2578 //bool ToDestroy = false;
2579 if (0 == numberOfFamilies) {
2580 //ToDestroy = true ;
2581 vector<GROUP*> myGroups = _ptrMesh->getGroups(entity);
2582 int NumberOfGroups = myGroups.size() ;
2583 // build families from groups
2584 for (int i=0; i<NumberOfGroups; i++) {
2585 SCRUTE( myGroups[i]->getName() );
2586 SUPPORT * mySupport = myGroups[i] ;
2587 FAMILY* myFamily = new FAMILY(*mySupport);
2588 myFamily->setIdentifier(-i-1000);
2589 myFamilies->push_back(myFamily);
2591 numberOfFamilies=myFamilies->size() ;
2593 for (int i=0;i<numberOfFamilies;i++) {
2594 int familyNumber = (*myFamilies)[i]->getIdentifier() ;
2595 int numberOfFamilyElements = (*myFamilies)[i]->getNumberOfElements(MED_ALL_ELEMENTS) ;
2596 if ((*myFamilies)[i]->isOnAllElements())
2597 for (int ii=0; ii<numberOfFamilyElements; ii++)
2598 familyArray[ii]=familyNumber;
2600 const int * myFamilyElements = (*myFamilies)[i]->getNumber(MED_ALL_ELEMENTS) ;
2601 for (int ii=0;ii<numberOfFamilyElements;ii++)
2602 familyArray[myFamilyElements[ii]-1]=familyNumber;
2606 const int * typeCount = _ptrMesh->getGlobalNumberingIndex(entity) ;
2607 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
2608 int lgth=numberOfElements;
2609 med_2_2::med_int *temp=new med_2_2::med_int[lgth];
2610 for(int i2=0;i2<lgth;i2++)
2611 temp[i2]=(med_2_2::med_int) (familyArray[i2]);
2613 for (int i=0; i<numberOfTypes; i++) {
2614 int typeNumberOfElements = typeCount[i+1] - typeCount[i] ;
2616 err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
2617 familyArray+typeCount[i]-1, typeNumberOfElements,
2618 (med_2_2::med_entite_maillage) entity,
2619 (med_2_2::med_geometrie_element) types[i]);
2621 if ( err != MED_VALID)
2622 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write family for the |"<< _ptrMesh->getNumberOfElements(entity, types[i])
2623 << "| faces of geometric type |" << geoNames[types[i]] <<"|in mesh |"
2624 << _ptrMesh->_name.c_str() << "|" ));
2626 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
2629 delete[] familyArray ;
2630 //if (true == ToDestroy) {
2631 // int NumberOfFamilies = myFamilies->size();
2632 // for (int i=0; i<NumberOfFamilies; i++)
2633 // delete myFamilies[i];
2638 { // EDGE RELATED BLOCK
2639 //medEntityMesh entity=MED_EN::MED_FACE;
2640 medEntityMesh entity=MED_EN::MED_EDGE;
2641 // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArray____Family DOIT ETRE ENLEVER DE LA CLASSE MESH
2642 if ( ( _ptrMesh->existConnectivity(MED_NODAL,entity) )|( _ptrMesh->existConnectivity(MED_DESCENDING,entity) ) ) {
2644 int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ;
2645 const medGeometryElement * types = _ptrMesh->getTypes (entity) ;
2647 int numberOfElements = _ptrMesh->getNumberOfElements(entity, MED_ALL_ELEMENTS) ;
2648 int * familyArray = new int[numberOfElements] ;
2649 for (int i=0;i<numberOfElements;i++)
2652 int numberOfFamilies = _ptrMesh->getNumberOfFamilies(entity) ;
2653 //vector<FAMILY*> myFamilies = _ptrMesh->getFamilies(entity) ;
2654 vector<FAMILY*> * myFamilies = &_ptrMesh->_familyEdge ;
2655 //bool ToDestroy = false;
2656 if (0 == numberOfFamilies) {
2657 //ToDestroy = true ;
2658 vector<GROUP*> myGroups = _ptrMesh->getGroups(entity);
2659 int NumberOfGroups = myGroups.size() ;
2660 // build families from groups
2661 for (int i=0; i<NumberOfGroups; i++) {
2662 SCRUTE( myGroups[i]->getName() );
2663 SUPPORT * mySupport = myGroups[i] ;
2664 FAMILY* myFamily = new FAMILY(*mySupport);
2665 myFamily->setIdentifier(-i-2000);
2666 myFamilies->push_back(myFamily);
2668 numberOfFamilies=myFamilies->size() ;
2670 for (int i=0;i<numberOfFamilies;i++) {
2671 int familyNumber = (*myFamilies)[i]->getIdentifier() ;
2672 int numberOfFamilyElements = (*myFamilies)[i]->getNumberOfElements(MED_ALL_ELEMENTS) ;
2673 if ((*myFamilies)[i]->isOnAllElements())
2674 for (int ii=0; ii<numberOfFamilyElements; ii++)
2675 familyArray[ii]=familyNumber;
2677 const int * myFamilyElements = (*myFamilies)[i]->getNumber(MED_ALL_ELEMENTS) ;
2678 for (int ii=0;ii<numberOfFamilyElements;ii++)
2679 familyArray[myFamilyElements[ii]-1]=familyNumber;
2683 const int * typeCount = _ptrMesh->getGlobalNumberingIndex(entity) ;
2684 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
2685 int lgth=numberOfElements;
2686 med_2_2::med_int *temp=new med_2_2::med_int[lgth];
2687 for(int i2=0;i2<lgth;i2++)
2688 temp[i2]=(med_2_2::med_int) (familyArray[i2]);
2690 for (int i=0; i<numberOfTypes; i++) {
2691 int typeNumberOfElements = typeCount[i+1] - typeCount[i] ;
2693 err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
2694 familyArray+typeCount[i]-1, typeNumberOfElements,
2695 (med_2_2::med_entite_maillage) entity,
2696 (med_2_2::med_geometrie_element) types[i]);
2698 if ( err != MED_VALID)
2699 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write family for the |"<< _ptrMesh->getNumberOfElements(entity, types[i])
2700 << "| edges of geometric type |" << geoNames[types[i]] <<"|in mesh |"
2701 << _ptrMesh->_name.c_str() << "|" ));
2703 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
2706 delete[] familyArray ;
2707 //if (true == ToDestroy) {
2708 // int NumberOfFamilies = myFamilies->size();
2709 // for (int i=0; i<NumberOfFamilies; i++)
2710 // delete myFamilies[i];
2719 int MED_MESH_WRONLY_DRIVER22::writeFamilies(vector<FAMILY*> & families ) const
2722 const char * LOC="int MED_MESH_WRONLY_DRIVER22::writeFamilies(vector<FAMILY*> families) const : ";
2725 med_2_2::med_err err;
2727 MESSAGE(LOC<<" families.size() :"<<families.size());
2729 for (unsigned int i=0; i< families.size(); i++) {
2731 int numberOfAttributes = families[i]->getNumberOfAttributes ();
2732 string attributesDescriptions = "";
2734 // Recompose the attributes descriptions arg for MED
2735 for (int j=0; j < numberOfAttributes; j++) {
2737 string attributeDescription = families[i]->getAttributeDescription(j+1);
2739 if ( attributeDescription.size() > MED_TAILLE_DESC )
2740 throw MEDEXCEPTION( LOCALIZED(STRING(LOC) << "The size of the attribute description n° |" << j+1 << "| of the family |" << families[i]->getName()
2741 << "| with identifier |" << families[i]->getIdentifier() << "| is |"
2742 << attributeDescription.size() <<"| and is more than |" << MED_TAILLE_DESC << "|")) ;
2744 attributesDescriptions += attributeDescription;
2748 int numberOfGroups = families[i]->getNumberOfGroups();
2749 string groupsNames(numberOfGroups*MED_TAILLE_LNOM,'\0') ;
2750 // Recompose the groups names arg for MED
2751 for (int j=0; j < numberOfGroups; j++) {
2753 string groupName = families[i]->getGroupName(j+1);
2755 if ( groupName.size() > MED_TAILLE_LNOM )
2756 throw MEDEXCEPTION( LOCALIZED(STRING(LOC) << "The size of the group name n° |" << j+1 << "| of the family |" << families[i]->getName()
2757 << "| with identifier |" << families[i]->getIdentifier() << "| is |"
2758 << groupName.size() <<"| and is more than |" << MED_TAILLE_LNOM << "|")) ;
2761 int length = min(MED_TAILLE_LNOM,(int)groupName.size());
2762 groupsNames.replace(j*MED_TAILLE_LNOM,length, groupName,0,length);
2766 // test if the family already exists (HDF trick waiting a MED evolution to be replaced)
2768 string dataGroupFam;
2769 if (families[i]->getEntity() == MED_NODE)
2770 dataGroupFam = "/ENS_MAA/"+_meshName+"/FAS/NOEUD/"+families[i]->getName()+"/";
2772 dataGroupFam = "/ENS_MAA/"+_meshName+"/FAS/ELEM/"+families[i]->getName()+"/";
2774 SCRUTE("|"<<dataGroupFam<<"|");
2775 err = med_2_2::_MEDdatagroupOuvrir(_medIdt,const_cast <char *> (dataGroupFam.c_str()) ) ;
2776 if ( err < MED_VALID ) {
2779 MESSAGE(LOC<<"families[i]->getName().c_str() : "<<families[i]->getName().c_str());
2780 MESSAGE(LOC<<"_meshName.c_str() : "<<_meshName.c_str());
2781 MESSAGE(LOC<<"families[i]->getIdentifier() : "<<families[i]->getIdentifier());
2782 MESSAGE(LOC<<"numberOfAttributes : "<<numberOfAttributes);
2784 //MESSAGE(LOC<<"families[i]->getAttributesIdentifiers() : "<<families[i]->getAttributesIdentifiers()[0]);
2785 //MESSAGE(LOC<<"families[i]->getAttributesValues() : "<<families[i]->getAttributesValues()[0]);
2786 MESSAGE(LOC<<"attributesDescriptions.c_str() : "<<attributesDescriptions.c_str());
2787 MESSAGE(LOC<<"numberOfGroups : "<<numberOfGroups);
2788 MESSAGE(LOC<<"groupsNames.c_str() : "<<groupsNames.c_str());
2789 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
2790 int lgth=families[i]->getNumberOfAttributes();
2791 med_2_2::med_int * AttributesIdentifier2 = new med_2_2::med_int[lgth] ;
2792 med_2_2::med_int * AttributesValues2 = new med_2_2::med_int[lgth] ;
2793 for(med_2_2::med_int i2=0;i2<lgth;i2++)
2795 AttributesIdentifier2[i2]=(med_2_2::med_int)(families[i]->getAttributesIdentifiers()[i2]);
2796 AttributesValues2[i2]=(med_2_2::med_int)(families[i]->getAttributesValues()[i2]);
2798 err = med_2_2::MEDfamCr( _medIdt,
2799 const_cast <char *> ( _meshName.c_str() ),
2800 const_cast <char *> ( families[i]->getName().c_str() ),
2801 families[i]->getIdentifier(),
2802 AttributesIdentifier2,
2804 const_cast <char *> (attributesDescriptions.c_str()),
2806 const_cast <char *> (groupsNames.c_str()),
2808 delete [] AttributesIdentifier2;
2809 delete [] AttributesValues2;
2811 err = med_2_2::MEDfamCr( _medIdt,
2812 const_cast <char *> ( _meshName.c_str() ),
2813 const_cast <char *> ( families[i]->getName().c_str() ),
2814 families[i]->getIdentifier(),
2815 families[i]->getAttributesIdentifiers(),
2816 families[i]->getAttributesValues(),
2817 const_cast <char *> (attributesDescriptions.c_str()),
2819 const_cast <char *> (groupsNames.c_str()),
2823 if ( err != MED_VALID)
2824 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't create family |" << families[i]->getName()
2825 << "| with identifier |" << families[i]->getIdentifier() << "| groups names |"
2826 << groupsNames <<"| and attributes descriptions |" << attributesDescriptions << "|")) ;
2829 med_2_2::_MEDdatagroupFermer(_medIdt);
2840 // A FAIRE POUR LES NOEUDS ET LES ELEMENTS ret = MEDfamEcr(
2844 /*--------------------- RDWR PART -------------------------------*/
2846 MED_MESH_RDWR_DRIVER22::MED_MESH_RDWR_DRIVER22()
2850 MED_MESH_RDWR_DRIVER22::MED_MESH_RDWR_DRIVER22(const string & fileName,
2852 MED_MESH_DRIVER(fileName,ptrMesh,MED_RDWR),
2853 IMED_MESH_RDONLY_DRIVER(fileName,ptrMesh),
2854 IMED_MESH_WRONLY_DRIVER(fileName,ptrMesh),
2855 IMED_MESH_RDWR_DRIVER(fileName,ptrMesh),
2856 MED_MESH_DRIVER22(fileName,ptrMesh,MED_RDWR),
2857 MED_MESH_RDONLY_DRIVER22(fileName,ptrMesh),
2858 MED_MESH_WRONLY_DRIVER22(fileName,ptrMesh)
2860 MESSAGE("MED_MESH_RDWR_DRIVER22::MED_MESH_RDWR_DRIVER22(const string & fileName, MESH * ptrMesh) has been created");
2863 MED_MESH_RDWR_DRIVER22::MED_MESH_RDWR_DRIVER22(const MED_MESH_RDWR_DRIVER22 & driver):
2864 MED_MESH_DRIVER(driver),
2865 IMED_MESH_RDONLY_DRIVER(driver),
2866 IMED_MESH_WRONLY_DRIVER(driver),
2867 IMED_MESH_RDWR_DRIVER(driver),
2868 MED_MESH_DRIVER22(driver),
2869 MED_MESH_RDONLY_DRIVER22(driver),
2870 MED_MESH_WRONLY_DRIVER22(driver)
2874 MED_MESH_RDWR_DRIVER22::~MED_MESH_RDWR_DRIVER22() {
2875 //MESSAGE("MED_MESH_RDWR_DRIVER22::MED_MESH_RDWR_DRIVER22(const string & fileName, MESH * ptrMesh) has been destroyed");
2878 GENDRIVER * MED_MESH_RDWR_DRIVER22::copy(void) const
2880 return new MED_MESH_RDWR_DRIVER22(*this);
2883 void MED_MESH_RDWR_DRIVER22::write(void) const
2885 MED_MESH_WRONLY_DRIVER22::write();
2887 void MED_MESH_RDWR_DRIVER22::read (void)
2889 MED_MESH_RDONLY_DRIVER22::read();