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/ or email : webmaster.salome@opencascade.com
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 if ( ( _meshName.empty() ) && ( _ptrMesh->_name.empty() ) )
155 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)
156 <<" neither <meshName> is set in driver nor in object MESH.")) ;
158 // If _meshName is not set in driver, try to use _ptrMesh->_name
159 if ( ( _meshName.empty() ) && ( !_ptrMesh->_name.empty() ) )
160 _meshName=_ptrMesh->_name;
162 if ( _meshName.size() > MED_TAILLE_NOM )
163 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)
164 <<" <meshName> size in object driver MESH is > MED_TAILLE_NOM ."));
167 _ptrMesh->_name = _meshName;
169 SCRUTE(_ptrMesh->getIsAGrid());
171 if (_ptrMesh->getIsAGrid())
175 // always call getFAMILY : families are requiered !!!!
177 // int nbFam = MEDnFam(_medIdt,
178 // const_cast <char *> (_meshName.c_str()),
180 // MED_FR::MED_FAMILLE);
185 if (getFAMILY()!=MED_VALID)
186 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERREUR in getFAMILY when the mesh is a grid")) ;
188 buildAllGroups(_ptrMesh->_groupNode,_ptrMesh->_familyNode) ;
195 if (getCOORDINATE()!=MED_VALID)
196 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERREUR in getCOORDINATE" )) ;
198 if (getCONNECTIVITY()!=MED_VALID)
199 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERREUR in getCOONECTIVITY")) ;
201 if (getFAMILY()!=MED_VALID)
202 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERREUR in getFAMILY" )) ;
206 // we build all groups
208 buildAllGroups(_ptrMesh->_groupNode,_ptrMesh->_familyNode) ;
210 buildAllGroups(_ptrMesh->_groupCell,_ptrMesh->_familyCell) ;
212 if (_ptrMesh->_meshDimension == 3)
214 buildAllGroups(_ptrMesh->_groupFace,_ptrMesh->_familyFace) ;
215 else if (_ptrMesh->_meshDimension == 2)
217 buildAllGroups(_ptrMesh->_groupEdge,_ptrMesh->_familyEdge) ;
219 // MESSAGE(LOC<<"Checking of CellModel !!!!!!!");
221 // int nbOfTypes = _ptrMesh->_connectivity->_numberOfTypes;
222 // for(int i=0;i<nbOfTypes;i++)
224 // MESSAGE(LOC << _ptrMesh->_connectivity->_type[i]) ;
230 //=======================================================================
233 //=======================================================================
235 void MED_MESH_RDONLY_DRIVER22::getGRID()
237 const char * LOC = "MED_MESH_RDONLY_DRIVER22::getGRID() : " ;
240 if (_status!=MED_OPENED)
241 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "med file is not opened"));
243 GRID * ptrGrid = (GRID *) _ptrMesh;
249 int numberOfMeshesInFile = med_2_2::MEDnMaa(_medIdt);
251 if (numberOfMeshesInFile == MED_INVALID)
252 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Problem in File where the mesh " << _meshName << " is supposed to be stored"));
254 for (int index = 0; index < numberOfMeshesInFile; index++)
256 char meshName[MED_TAILLE_NOM+1]="";
257 char meshDescription[MED_TAILLE_DESC+1]="";
259 med_2_2::med_int meshDim;
260 med_2_2::med_maillage meshType;
262 err = med_2_2::MEDmaaInfo(_medIdt, (index+1),meshName, &meshDim,
263 &meshType, meshDescription) ;
265 MESSAGE(LOC<<": Mesh n°"<< (index+1) <<" nammed "<< meshName << " with the description " << meshDescription << " is structured");
267 if (_meshName == string(meshName))
269 _ptrMesh->_description = meshDescription;
270 _ptrMesh->_name = meshName;
274 MED_EN::med_grid_type gridType = ptrGrid->getGridType();
276 MESSAGE(LOC<<": Mesh processed is nammed "<< _ptrMesh->_name << " with the description " << _ptrMesh->_description << " is structured with the type " << gridType);
278 // Read the dimension of the mesh <_meshName>
279 int MeshDimension = med_2_2::MEDdimLire(_medIdt, const_cast <char *>
280 (_meshName.c_str())) ;
282 if (MeshDimension == MED_INVALID)
283 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The mesh dimension |" <<
284 MeshDimension << "| seems to be incorrect " <<
285 "for the mesh : |" << _meshName << "|")) ;
287 _ptrMesh->_meshDimension = MeshDimension;
289 // Read or get the dimension of the space for the mesh <_meshName>
290 int SpaceDimension = MeshDimension;
292 int SpaceDimensionRead = med_2_2::MEDdimEspaceLire(_medIdt,
294 (_meshName.c_str())) ;
296 if (SpaceDimensionRead != MED_INVALID) SpaceDimension = SpaceDimensionRead;
298 _ptrMesh->_spaceDimension = SpaceDimension;
300 med_2_2::med_repere rep ;
301 string tmp_nom_coord (MED_TAILLE_PNOM22*(_ptrMesh->_spaceDimension)+1,' ');
302 string tmp_unit_coord(MED_TAILLE_PNOM22*(_ptrMesh->_spaceDimension)+1,' ');
303 char * tmp_nom = (const_cast <char *> ( tmp_nom_coord.c_str()) ) ;
304 char * tmp_unit= (const_cast <char *> ( tmp_unit_coord.c_str()) ) ;
307 int * ArrayLen[] = { & ptrGrid->_iArrayLength,
308 & ptrGrid->_jArrayLength,
309 & ptrGrid->_kArrayLength };
311 MESSAGE(LOC << "The mesh is a " << _ptrMesh->_meshDimension << "D mesh on a " << _ptrMesh->_spaceDimension << "D space");
315 // if (gridType == MED_EN::MED_GRILLE_STANDARD)
316 if (gridType == MED_EN::MED_BODY_FITTED)
318 //CCRT int * structure = new int[MeshDimension];
319 med_int * structure = new med_int[MeshDimension];
321 err = med_2_2::MEDstructureCoordLire(_medIdt,
323 (_ptrMesh->_name.c_str()),
324 MeshDimension,structure);
326 if (err != MED_VALID)
327 throw MEDEXCEPTION(STRING(LOC) <<"Error in reading the structure of grid : |" << _meshName << "|" ) ;
331 for (int idim = 0; idim < MeshDimension; idim++)
333 MESSAGE(LOC<<"structure dim " << idim << " " << structure[idim]);
335 ArrayLen [idim][0] = structure[idim];
336 NumberOfNodes = NumberOfNodes*structure[idim];
341 // NumberOfNodes = MED_FR::MEDnEntMaa(_medIdt,
342 // const_cast <char *>
343 // (_ptrMesh->_name.c_str()),
344 // MED_FR::MED_COOR,MED_FR::MED_NOEUD,
345 // (MED_FR::med_geometrie_element) 0,
346 // (MED_FR::med_connectivite) 0);
348 if ( NumberOfNodes == MED_INVALID )
349 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"The number of nodes |" <<
351 "| seems to be incorrect "
352 << "for the mesh : |" <<
353 _meshName << "|" )) ;
355 _ptrMesh->_numberOfNodes = NumberOfNodes ;
357 // create coordinates and its structure
358 _ptrMesh->_coordinate = new COORDINATE(SpaceDimension,NumberOfNodes,
359 MED_EN::MED_FULL_INTERLACE);
361 err = MEDcoordLire(_medIdt,
362 const_cast <char *> (_ptrMesh->_name.c_str()),
363 _ptrMesh->_spaceDimension,
364 //const_cast <double *> ( _ptrMesh->_coordinate->_coordinate->get(MED_EN::MED_FULL_INTERLACE) ),
365 const_cast <double *> ( _ptrMesh->_coordinate->_coordinate.get(MED_EN::MED_FULL_INTERLACE) ),
366 med_2_2::MED_FULL_INTERLACE,
367 MED_ALL, // we read all the coordinates
368 NULL, // we don't use a profile
369 0, // so the profile's size is 0
370 &rep,tmp_nom,tmp_unit);
372 if (err != MED_VALID)
373 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't read coordinates of the |" <<
374 NumberOfNodes << "| nodes for the mesh : |" <<
375 _meshName << "| of space dimension |" <<
376 SpaceDimension << "| with units names |" <<
377 tmp_nom << "| and units |" <<
380 ptrGrid->_is_coordinates_filled = true;
382 else if ((gridType == MED_EN::MED_CARTESIAN) ||
383 (gridType == MED_EN::MED_POLAR))
387 double * Array[] = { (double*) 0, (double*) 0, (double*) 0 };
389 for (int idim = 0; idim < _ptrMesh->_meshDimension; ++idim)
391 med_2_2::med_table table;
392 if (idim == 0) table = med_2_2::MED_COOR_IND1;
393 else if (idim == 1) table = med_2_2::MED_COOR_IND2;
394 else if (idim == 2) table = med_2_2::MED_COOR_IND3;
396 int length = med_2_2::MEDnEntMaa(_medIdt,
397 const_cast <char *> (_ptrMesh->_name.c_str()),
398 table,med_2_2::MED_NOEUD,
401 if ( length <= MED_VALID )
402 throw MEDEXCEPTION(STRING(LOC) <<"The number of nodes |" << length <<
403 "| seems to be incorrect "
404 << "for the mesh : |" << _meshName << "|" ) ;
406 ArrayLen [idim][0] = length;
407 NumberOfNodes *= length;
409 Array [idim] = new double [ length ];
411 err = med_2_2::MEDindicesCoordLire(_medIdt, const_cast <char *>
412 (_ptrMesh->_name.c_str()),
413 _ptrMesh->_meshDimension,
414 Array [idim], length, (idim+1),
415 tmp_nom+(idim*MED_TAILLE_PNOM22),
416 tmp_unit+(idim*MED_TAILLE_PNOM22));
418 if (err != MED_VALID)
419 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Error in reading coordinates indices " <<
420 idim << "of the grid : |" <<
421 _meshName << "|" )) ;
424 ptrGrid->_iArray = Array[0];
425 ptrGrid->_jArray = Array[1];
426 ptrGrid->_kArray = Array[2];
428 _ptrMesh->_numberOfNodes = NumberOfNodes ;
430 // create coordinates
431 _ptrMesh->_coordinate = new COORDINATE(SpaceDimension,NumberOfNodes,
432 MED_EN::MED_FULL_INTERLACE);
434 if (gridType == MED_EN::MED_CARTESIAN)
435 rep = med_2_2::MED_CART;
436 else if (gridType == MED_EN::MED_POLAR)
438 if (SpaceDimension == 2) rep = med_2_2::MED_CYL;
439 else if (SpaceDimension == 3) rep = med_2_2::MED_SPHER;
443 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<" bad grid type : " << gridType));
445 // set coordinate names
447 for (i=0; i<_ptrMesh->_spaceDimension; ++i ) {
448 string myStringName(tmp_nom_coord,i*MED_TAILLE_PNOM22,MED_TAILLE_PNOM22) ;
449 string myStringUnit(tmp_unit_coord,i*MED_TAILLE_PNOM22,MED_TAILLE_PNOM22) ;
450 // suppress space at the end
452 for(j=MED_TAILLE_PNOM22-1;j>=0;j--)
453 if (myStringName[j] != ' ') break ;
454 _ptrMesh->_coordinate->_coordinateName[i]=string(myStringName,0,j+1);
455 for(j=MED_TAILLE_PNOM22-1;j>=0;j--)
456 if (myStringUnit[j] != ' ') break ;
457 _ptrMesh->_coordinate->_coordinateUnit[i]=string(myStringUnit,0,j+1);
460 string coordinateSystem = "UNDEFINED";
462 if( rep == med_2_2::MED_CART) coordinateSystem = "CARTESIAN";
463 else if ( rep == med_2_2::MED_CYL) coordinateSystem = "CYLINDRICAL";
464 else if ( rep == med_2_2::MED_SPHER) coordinateSystem = "SPHERICAL";
466 _ptrMesh->_coordinate->setCoordinatesSystem(coordinateSystem);
471 //=======================================================================
472 //function : getCOORDINATE
473 // A FAIRE : RENVOYER DU VOID
474 //=======================================================================
475 int MED_MESH_RDONLY_DRIVER22::getCOORDINATE()
477 const char * LOC = "MED_MESH_RDONLY_DRIVER22::getCOORDINATE() : " ;
481 if (_status==MED_OPENED)
485 int numberOfMeshesInFile = med_2_2::MEDnMaa(_medIdt);
487 if (numberOfMeshesInFile == MED_INVALID)
488 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Problem in File where the mesh " << _meshName << " is supposed to be stored"));
490 for (int index = 0; index < numberOfMeshesInFile; index++)
492 char meshName[MED_TAILLE_NOM+1]="";
493 char meshDescription[MED_TAILLE_DESC+1]="";
495 med_2_2::med_int meshDim;
496 med_2_2::med_maillage meshType;
498 err = med_2_2::MEDmaaInfo(_medIdt, (index+1), meshName, &meshDim,
499 &meshType, meshDescription) ;
501 MESSAGE(LOC<<": Mesh n°"<< (index+1) <<" nammed "<< meshName << " with the description " << meshDescription << " is structured");
503 if (_meshName == string(meshName))
505 _ptrMesh->_description = meshDescription;
510 // Read the dimension of the mesh <_meshName>
511 int MeshDimension = med_2_2::MEDdimLire(_medIdt, const_cast <char *>
512 (_meshName.c_str())) ;
514 if ( MeshDimension == MED_INVALID )
515 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The mesh dimension |" <<
517 "| seems to be incorrect " <<
518 "for the mesh : |" << _meshName << "|")) ;
520 _ptrMesh->_meshDimension = MeshDimension;
522 // Read or get the dimension of the space for the mesh <_meshName>
523 int SpaceDimension = MeshDimension;
525 int SpaceDimensionRead = med_2_2::MEDdimEspaceLire(_medIdt,
527 (_meshName.c_str())) ;
529 if (SpaceDimensionRead != MED_INVALID)
530 SpaceDimension = SpaceDimensionRead;
532 _ptrMesh->_spaceDimension = SpaceDimension;
534 // Read the number of nodes used in the mesh <_meshName>
535 // to be able to create a COORDINATE object
536 int NumberOfNodes=MEDnEntMaa(_medIdt,
537 const_cast <char *> (_meshName.c_str()),
540 (med_2_2::med_geometrie_element) MED_NONE,
541 (med_2_2::med_connectivite) MED_NONE);
542 if ( NumberOfNodes <= MED_VALID )
543 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"The number of nodes |" << NumberOfNodes << "| seems to be incorrect "
544 << "for the mesh : |" << _meshName << "|" )) ;
545 _ptrMesh->_numberOfNodes = NumberOfNodes ;
547 // create a COORDINATE object
548 _ptrMesh->_coordinate = new COORDINATE(SpaceDimension, NumberOfNodes, MED_EN::MED_FULL_INTERLACE);
550 med_2_2::med_repere rep ; // ATTENTION ---> DOIT ETRE INTEGRE DS MESH EF: FAIT NON?
551 string tmp_nom_coord (MED_TAILLE_PNOM22*(_ptrMesh->_spaceDimension)+1,'\0');
552 string tmp_unit_coord(MED_TAILLE_PNOM22*(_ptrMesh->_spaceDimension)+1,'\0');
553 char * tmp_nom = (const_cast <char *> ( tmp_nom_coord.c_str()) ) ;
554 char * tmp_unit= (const_cast <char *> ( tmp_unit_coord.c_str()) ) ;
556 err=MEDcoordLire(_medIdt,
557 const_cast <char *> (_ptrMesh->_name.c_str()),
558 _ptrMesh->_spaceDimension,
559 //const_cast <double *> ( _ptrMesh->_coordinate->_coordinate->get(MED_EN::MED_FULL_INTERLACE) ),
560 const_cast <double *> ( _ptrMesh->_coordinate->_coordinate.get(MED_EN::MED_FULL_INTERLACE) ),
561 med_2_2::MED_FULL_INTERLACE,
562 MED_ALL, // we read all the coordinates
563 NULL, // we don't use a profile
564 0, // so the profile's size is 0
565 &rep,tmp_nom,tmp_unit);
566 if (err != MED_VALID)
567 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't read coordinates of the |" << NumberOfNodes << "| nodes "
568 << "for the mesh : |" << _meshName
569 << "| of space dimension |" << SpaceDimension
570 << "| with units names |" << tmp_nom
571 << "| and units |" << tmp_unit
575 for (int i=0;i<_ptrMesh->_spaceDimension;i++) {
576 string myStringName(tmp_nom_coord,i*MED_TAILLE_PNOM22,MED_TAILLE_PNOM22) ;
577 string myStringUnit(tmp_unit_coord,i*MED_TAILLE_PNOM22,MED_TAILLE_PNOM22) ;
578 // suppress space at the end
580 for(j=MED_TAILLE_PNOM22-1;j>=0;j--)
581 if (myStringName[j] != ' ') break ;
582 _ptrMesh->_coordinate->_coordinateName[i]=string(myStringName,0,j+1);
583 for(j=MED_TAILLE_PNOM22-1;j>=0;j--)
584 if (myStringUnit[j] != ' ') break ;
585 _ptrMesh->_coordinate->_coordinateUnit[i]=string(myStringUnit,0,j+1);
588 // Pourquoi le stocker sous forme de chaîne ?
591 case med_2_2::MED_CART :
593 _ptrMesh->_coordinate->_coordinateSystem = "CARTESIAN";
596 case med_2_2::MED_CYL :
598 _ptrMesh->_coordinate->_coordinateSystem = "CYLINDRICAL";
601 case med_2_2::MED_SPHER :
603 _ptrMesh->_coordinate->_coordinateSystem = "SPHERICAL";
608 _ptrMesh->_coordinate->_coordinateSystem = "UNDEFINED"; // ?Erreur ?
613 // Read the unused optional node Names
614 char * tmp_node_name = new char[NumberOfNodes*MED_TAILLE_PNOM22+1];
615 tmp_node_name[NumberOfNodes]='\0' ;
616 err=MEDnomLire(_medIdt,const_cast <char*> (_ptrMesh->_name.c_str()),
617 tmp_node_name,NumberOfNodes*MED_TAILLE_PNOM22,med_2_2::MED_NOEUD,
618 (med_2_2::med_geometrie_element) MED_NONE);
619 if (err == MED_VALID)
620 MESSAGE(LOC<<"MED_MESH_RDONLY_DRIVER::getNoeuds() : WARNING : Nodes have names but we do not read them !");
621 delete[] tmp_node_name ;
624 // ??? Read the unused optional node Numbers ???
625 med_2_2::med_int * tmp_node_number = new med_2_2::med_int[NumberOfNodes] ;
626 err=MEDnumLire(_medIdt,const_cast <char*> (_ptrMesh->_name.c_str()),
627 tmp_node_number,NumberOfNodes,med_2_2::MED_NOEUD,(med_2_2::med_geometrie_element)0);
628 if (err == MED_VALID) {
629 // INFOS(LOC<<"WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING");
630 // INFOS(LOC<<"MED_MESH_RDONLY_DRIVER::getNoeuds() : WARNING : Nodes have numbers but we do not take care of them !");
631 // INFOS(LOC<<"WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING");
632 MESSAGE(LOC<<"MED_MESH_RDONLY_DRIVER::getNoeuds() : Nodes have numbers, we DO TAKE care of them !");
633 _ptrMesh->_coordinate->_nodeNumber.set(NumberOfNodes) ;
634 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
635 for(med_2_2::med_int i2=0;i2<NumberOfNodes;i2++)
636 _ptrMesh->_coordinate->_nodeNumber[i2]=(int)(tmp_node_number[i2]);
638 memcpy((int*)_ptrMesh->_coordinate->_nodeNumber,tmp_node_number,sizeof(int)*NumberOfNodes) ;
641 //////////////////////////////////////////////////////////////////////////////////////
642 /// Modification pour prise en compte de la numérotation optionnelle des noeuds ///
643 //////////////////////////////////////////////////////////////////////////////////////
645 /// Calcule _optionnalToCanonicNodesNumbers de telle sorte que _optionnalToCanonicNodesNumbers[OptionnalNumber]==CanonicNumber
647 // _ptrMesh->_arePresentOptionnalNodesNumbers=1;
648 // for (int canonicNumber=1;canonicNumber<=NumberOfNodes;canonicNumber++) _ptrMesh->_optionnalToCanonicNodesNumbers[tmp_node_number[canonicNumber-1]]=canonicNumber;
649 // ICI RETOUR A LA NORMALE::: AUCUNE PRISE EN COMPTE D'UN NUMEROTATION OPTIONNEL
650 _ptrMesh->_arePresentOptionnalNodesNumbers=0;
652 else _ptrMesh->_arePresentOptionnalNodesNumbers=0;
654 //////////////////////////////////////////////////////////////////////////////////////
656 delete[] tmp_node_number ;
665 int MED_MESH_RDONLY_DRIVER22::getCONNECTIVITY()
667 const char * LOC = "MED_MESH_RDONLY_DRIVER22::getCONNECTIVITY : " ;
670 if (_status==MED_OPENED)
674 // read MED_CELL connectivity
675 CONNECTIVITY * Connectivity = new CONNECTIVITY(MED_CELL) ;
676 Connectivity->_numberOfNodes = _ptrMesh->_numberOfNodes ; // EF : Pourquoi cet attribut est-il dans MESH et non dans COORDINATE ?
678 // Try to read nodal connectivity of the cells <Connectivity->_nodal>
679 // then try to read descending connectivity <Connectivity->_descending>
680 // if neither nodal nor descending connectivity exists
681 // throw an exception.
682 err = getNodalConnectivity(Connectivity) ;
685 Connectivity->_typeConnectivity = MED_DESCENDING ;
686 err = getDescendingConnectivity(Connectivity) ;
689 getDescendingConnectivity(Connectivity) ; // we read it if there is one
693 delete Connectivity ;
694 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "We could not read " <<
695 "any Connectivity")) ;
698 if (Connectivity->_entityDimension != _ptrMesh->_meshDimension)
699 MESSAGE(LOC << "Small mesh dimension problem on the med file mounted in memory : diim stored " << _ptrMesh->_meshDimension << " dim computed using the connectivity " << Connectivity->_entityDimension);
701 _ptrMesh->_meshDimension = Connectivity->_entityDimension ;
703 // At this point Connectivity->_typeConnectivity is either NODAL or DESCENDING
704 // If both connectivities are found Connectivity->_typeConnectivity is NODAL
705 // If space dimension is 3
706 // try to read the nodal connectivity of the faces <ConnectivityFace->_nodal> then
707 // try to read the descending connectivity <ConnectivityFace->_descending>
708 // if there is no descending connectivity and the CELLS are
709 // defined in descending mode then throw an exception
711 // PROVISOIRE : if we have some face or edge in MED_MAILLE, we don't read more. There could not be have face or edge !!!!
713 if(Connectivity->_constituent==NULL) {
715 SCRUTE(_ptrMesh->_meshDimension);
716 SCRUTE(Connectivity->_entityDimension);
717 if (_ptrMesh->_meshDimension == 3) {
718 MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DES FACES..." );
719 CONNECTIVITY * ConnectivityFace = new CONNECTIVITY(MED_EN::MED_FACE) ;
720 ConnectivityFace->_typeConnectivity = Connectivity->_typeConnectivity ; // NODAL or DESCENDING
721 SCRUTE(ConnectivityFace->_typeConnectivity);
722 if (Connectivity->_typeConnectivity == MED_DESCENDING) {
723 MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DESCENDANTE DES FACES" );
724 err = getDescendingConnectivity(ConnectivityFace) ;
726 throw MEDEXCEPTION ( LOCALIZED(STRING(LOC) << "No FACE in descending connectivity")) ;
727 getNodalConnectivity(ConnectivityFace) ; // if any !
729 MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE NODALE DES FACES" );
730 err = getNodalConnectivity(ConnectivityFace) ;
731 if (err!=MED_VALID) { // or error ????? we are in NODAL mode.
732 err = getDescendingConnectivity(ConnectivityFace) ;
734 getDescendingConnectivity(ConnectivityFace); // if any !
736 if (err!=MED_VALID) {
737 delete ConnectivityFace ;
738 MESSAGE(LOC<<"No FACE defined.") ;
740 MESSAGE(LOC<<" SAUVEGARDE DE LA CONNECTIVITE DES FACES DANS L'OBJET CONNECTIVITY" );
741 Connectivity->_constituent=ConnectivityFace ;
745 // read MED_EDGE connectivity
746 if (_ptrMesh->_meshDimension > 1) { // we are in 3 or 2D
747 MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DES ARRETES...." );
748 CONNECTIVITY * ConnectivityEdge = new CONNECTIVITY(MED_EDGE) ;
749 ConnectivityEdge->_typeConnectivity = Connectivity->_typeConnectivity ;
750 if (Connectivity->_typeConnectivity == MED_DESCENDING) {
751 MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DESCENDANTE DES ARRETES" );
752 err = getDescendingConnectivity(ConnectivityEdge) ;
754 throw MEDEXCEPTION ( LOCALIZED(STRING(LOC) << "No EDGE in descending connectivity")) ;
755 getNodalConnectivity(ConnectivityEdge) ; // if any !
757 MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE NODALE DES ARRETES" );
758 err = getNodalConnectivity(ConnectivityEdge) ;
759 if (err!=MED_VALID) { // or error ????? we are in NODAL mode.
760 err = getDescendingConnectivity(ConnectivityEdge) ;
762 getDescendingConnectivity(ConnectivityEdge) ; // if any !
764 if (err!=MED_VALID) {
765 delete ConnectivityEdge ;
766 MESSAGE(LOC<<"No EDGE defined.") ;
768 if (_ptrMesh->_meshDimension == 3)
769 if (Connectivity->_constituent != NULL)
770 Connectivity->_constituent->_constituent=ConnectivityEdge ;
772 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<< "EDGE defined but there are no FACE !")) ;
774 MESSAGE(LOC<<" SAUVEGARDE DE LA CONNECTIVITE DES ARETES DANS L'OBJET CONNECTIVITY" );
775 Connectivity->_constituent=ConnectivityEdge ;
780 _ptrMesh->_connectivity = Connectivity ;
784 // we have read all connectivity in file, now we must build descending connectivity if necessary !
786 // If connectivity descending is defined, we have nothing to do, all constituent are defined !
787 // If connectivity is only nodal, we must rebuild descending if we have some contituent !
790 // if (Connectivity->_descending == NULL)
791 // if (Connectivity->_constituent != NULL){
792 // // update Connectivity->_constituent
793 // CONNECTIVITY * myConstituentOld = Connectivity->_constituent ;
794 // Connectivity->_constituent = (CONNECTIVITY *)NULL ;
795 // Connectivity->calculateDescendingConnectivity() ;
805 int MED_MESH_RDONLY_DRIVER22::getNodalConnectivity(CONNECTIVITY * Connectivity)
807 const char * LOC = "MED_MESH_RDONLY_DRIVER22::getNodalConnectivity : " ;
810 if (_status==MED_OPENED)
812 int spaceDimension = _ptrMesh->_spaceDimension;
814 // Get the type of entity to work on (previously set in the Connectivity Object)
815 med_2_2::med_entite_maillage Entity = (med_2_2::med_entite_maillage) Connectivity->getEntity();
817 // Get the number of cells of each type & store it in <tmp_cells_count>.
818 int * tmp_cells_count = new int[MED_NBR_GEOMETRIE_MAILLE] ;
820 for (i=1;i<MED_NBR_GEOMETRIE_MAILLE;i++)
821 { // EF :ON SCANNE DES GEOMETRIES INUTILES, UTILISER LES MAPS
822 tmp_cells_count[i]=MEDnEntMaa(_medIdt,(const_cast <char *> (_ptrMesh->_name.c_str())),
823 med_2_2::MED_CONN,(med_2_2::med_entite_maillage) Entity,
824 all_cell_type[i],med_2_2::MED_NOD);
827 // Get the greatest dimension of the cells : Connectivity->_entityDimension
828 // We suppose there is no cells used as faces in MED 2.2.x , this is forbidden !!!
829 // In version prior to 2.2.x, it is possible
830 if (tmp_cells_count[i]>0)
832 Connectivity->_entityDimension=all_cell_type[i]/100;
833 Connectivity->_numberOfTypes++;
839 // begin classic geometric types
840 if (Connectivity->_numberOfTypes > 0)
842 // if MED version < 2.2.x, we read only entity with dimention = Connectivity->_entityDimension. Lesser dimension are face or edge !
844 med_int major, minor, release;
846 if ( med_2_2::MEDversionLire(_medIdt, &major, &minor, &release) != 0 )
848 // error : we suppose we have not a good med file !
849 delete[] tmp_cells_count ;
853 // we get MED version number
854 // If MED version is < 2.2 then the cells which dimension
855 // is lesser than the main dimension ( Connectivity->_entityDimension )
856 // are either faces or edges
858 // string medVersion(version_med);
860 int * tmpEdgeCount = new int[MED_NBR_GEOMETRIE_MAILLE] ;
861 tmpEdgeCount[0] = 0 ;
862 int numberOfEdgesTypes = 0;
863 int * tmpFaceCount = new int[MED_NBR_GEOMETRIE_MAILLE] ;
864 tmpFaceCount[0] = 0 ;
865 int numberOfFacesTypes = 0;
867 // if ((version_med != "2.2")&(Entity==MED_FR::MED_MAILLE))
869 // Connectivity->_numberOfTypes=0;
871 // for ( i=1;i<MED_NBR_GEOMETRIE_MAILLE;i++)
873 // tmpFaceCount[i]=0;
874 // tmpEdgeCount[i]=0;
875 // if (tmp_cells_count[i]!=0)
877 // int dimension = all_cell_type[i]/100 ;
878 // if (Connectivity->_entityDimension==dimension)
879 // Connectivity->_numberOfTypes++ ;
881 // if (dimension == 2)
882 // if (Connectivity->_entityDimension==3)
884 // tmpFaceCount[i]=tmp_cells_count[i] ;
885 // tmp_cells_count[i]=0 ;
886 // numberOfFacesTypes++;
888 // if (dimension == 1)
889 // if (Connectivity->_entityDimension>dimension)
891 // tmpEdgeCount[i]=tmp_cells_count[i] ;
892 // tmp_cells_count[i]=0;
893 // numberOfEdgesTypes++ ;
899 if (Entity==med_2_2::MED_MAILLE)
901 Connectivity->_numberOfTypes=0;
903 for ( i=1;i<MED_NBR_GEOMETRIE_MAILLE;i++)
907 if (tmp_cells_count[i]!=0)
909 int dimension = all_cell_type[i]/100 ;
910 if (Connectivity->_entityDimension==dimension)
911 Connectivity->_numberOfTypes++ ;
914 if (Connectivity->_entityDimension==3)
916 tmpFaceCount[i]=tmp_cells_count[i] ;
917 //tmp_cells_count[i]=0 ;
918 //Connectivity->_numberOfTypes++ ;
919 numberOfFacesTypes++;
922 if (Connectivity->_entityDimension>dimension)
924 tmpEdgeCount[i]=tmp_cells_count[i] ;
925 //tmp_cells_count[i]=0;
926 //Connectivity->_numberOfTypes++ ;
927 numberOfEdgesTypes++ ;
933 // bloc to read CELL :
935 // Prepare an array of indexes on the different cell types to create a MEDSKYLINEARRAY
936 // We use <tmp_cells_count> to calculate <Connectivity->_count> then we release it
937 Connectivity->_geometricTypes = new MED_EN::medGeometryElement [Connectivity->_numberOfTypes] ; // Double emploi pour des raisons pratiques
938 Connectivity->_type = new CELLMODEL [Connectivity->_numberOfTypes] ; //
939 Connectivity->_count = new int [Connectivity->_numberOfTypes+1] ;
940 Connectivity->_count[0] = 1;
945 for ( i=1;i<MED_NBR_GEOMETRIE_MAILLE;i++)
946 { // no point1 cell type (?)
947 int dimension = all_cell_type[i]/100 ;
948 if ((tmp_cells_count[i]>0) && (Connectivity->_entityDimension == dimension))
950 Connectivity->_count[typeNumber]=Connectivity->_count[typeNumber-1]+tmp_cells_count[i];
952 CELLMODEL t( (MED_EN::medGeometryElement) MED_MESH_DRIVER22::all_cell_type[i]) ;
954 Connectivity->_type[typeNumber-1] = t ;
956 Connectivity->_geometricTypes[typeNumber-1]=( MED_EN::medGeometryElement) MED_MESH_DRIVER22::all_cell_type[i] ;
958 // probleme avec les mailles de dimension < a dimension du maillage :
959 // Il faut oter le zero a la lecture est le remettre a l'ecriture : ce n'est pas fait !!!!! On interdit ce cas pour l'instant !!!
962 size+=tmp_cells_count[i]*((MED_MESH_DRIVER22::all_cell_type[i])%100) ;
965 << Connectivity->_count[typeNumber]-1 << " cells of type "
966 << all_cell_type_tab[i] );
971 // Creation of the MEDSKYLINEARRAY
972 //Connectivity->_nodal = new MEDSKYLINEARRAY(Connectivity->_count[Connectivity->_numberOfTypes]-1,size) ;
973 //int * NodalIndex = Connectivity->_nodal->getIndex() ;
974 int * NodalValue = new int[size] ;
975 int * NodalIndex = new int[Connectivity->_count[Connectivity->_numberOfTypes]] ;
978 // Fill the MEDSKYLINEARRAY by reading the MED file.
980 for ( i=0;i<Connectivity->_numberOfTypes;i++)
983 med_2_2::med_geometrie_element med_type = (med_2_2::med_geometrie_element) Connectivity->_type[i].getType() ;
984 // if ( Connectivity->_type[i].getDimension() < Connectivity->_entityDimension)
985 // if (Connectivity->_entity == MED_CELL)
986 // if ( Connectivity->_type[i].getDimension() < _ptrMesh->_spaceDimension)
989 // int NumberOfCell = Connectivity->_count[i+1]-Connectivity->_count[i] ;
990 int NumberOfNodeByCell = Connectivity->_type[i].getNumberOfNodes() ;
993 for ( j=Connectivity->_count[i]; j<Connectivity->_count[i+1];j++)
994 NodalIndex[j]=NodalIndex[j-1]+NumberOfNodeByCell ;
996 int tmp_numberOfCells = Connectivity->_count[i+1]-Connectivity->_count[i] ;
997 //CCRT int * tmp_ConnectivityArray = new int[(NumberOfNodeByCell+multi)*tmp_numberOfCells];
998 med_2_2::med_int * tmp_ConnectivityArray = new med_2_2::med_int[(NumberOfNodeByCell+multi)*tmp_numberOfCells];
1000 // int err=MEDconnLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
1001 // Connectivity->_entityDimension,tmp_ConnectivityArray,
1002 // MED_FR::MED_FULL_INTERLACE,NULL,0,Entity,med_type,MED_FR::MED_NOD);
1003 int err=MEDconnLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
1004 spaceDimension,tmp_ConnectivityArray,
1005 med_2_2::MED_FULL_INTERLACE,NULL,0,Entity,med_type,med_2_2::MED_NOD);
1007 if ( err != MED_VALID)
1009 delete[] tmp_ConnectivityArray;
1010 delete[] tmp_cells_count;
1011 delete[] tmpFaceCount;
1012 delete[] tmpEdgeCount;
1013 MESSAGE(LOC<<": MEDconnLire returns "<<err) ;
1017 int * ConnectivityArray = NodalValue + NodalIndex[Connectivity->_count[i]-1]-1 ;
1019 // version originale sans prise en compte des numéros optionnels
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 //////////////////////////////////////////////////////////////////////////////
1025 // Modification pour prise en compte de la numérotation optionnelle des noeuds ///
1026 //////////////////////////////////////////////////////////////////////////////
1028 // Rénumérote le tableau temporaire tmp_ConnectivityArray en utilisant _optionnalToCanonicNodesNumbers
1029 // Le traitement est identique à la version originelle s'il n'y a pas de numérotation optionnelle
1031 // if (_ptrMesh->_arePresentOptionnalNodesNumbers==1)
1033 // for ( j=0; j<tmp_numberOfCells; j++) for (int k=0; k<NumberOfNodeByCell; k++)
1034 // ConnectivityArray[j*NumberOfNodeByCell+k]=_ptrMesh->_optionnalToCanonicNodesNumbers[tmp_ConnectivityArray[j*(NumberOfNodeByCell+multi)+k]] ;
1038 // for ( j=0; j<tmp_numberOfCells; j++) for (int k=0; k<NumberOfNodeByCell; k++)
1039 // ConnectivityArray[j*NumberOfNodeByCell+k]=tmp_ConnectivityArray[j*(NumberOfNodeByCell+multi)+k] ;
1041 ////////////////////////////////////////////////////////////////////////////
1043 delete[] tmp_ConnectivityArray;
1047 Connectivity->_nodal = new MEDSKYLINEARRAY(Connectivity->_count[Connectivity->_numberOfTypes]-1,
1052 delete[] NodalIndex;
1053 delete[] NodalValue;
1055 } // end of bloc to read CELL
1061 if (numberOfFacesTypes!=0)
1064 // Create a CONNECTIVITY constituent to put in the top level CONNECTIVITY recursive class
1065 CONNECTIVITY * constituent = new CONNECTIVITY(numberOfFacesTypes,MED_EN::MED_FACE) ;
1066 constituent->_entityDimension = 2 ;
1067 constituent->_count[0]=1 ;
1069 // In order to create the MEDSKYLINEARRAY of the constituent object we need :
1071 // To initialize the _count array of the constituent object (containning cumulated face count by geometric type)
1072 // _count[0]=1 and _count[_numberOfTypes] give the size of NodalIndex
1074 // To calculate the total number of face nodes whatever the geometric type is.
1075 // The result is the size of the array containning all the nodes : NodalValue
1077 // To calculate the starting indexes of the different face types in NodalValue,
1078 // this is the NodalIndex array.
1081 int typeNumber = 1 ;
1083 for ( i=1; i < MED_NBR_GEOMETRIE_MAILLE; i++)
1084 { // no point1 cell type (?)
1085 if (tmpFaceCount[i]>0)
1087 constituent->_count[typeNumber] = constituent->_count[typeNumber-1] + tmpFaceCount[i];
1088 CELLMODEL t( (MED_EN::medGeometryElement) MED_MESH_DRIVER22::all_cell_type[i]) ;
1089 constituent->_type[typeNumber-1]=t ;
1091 constituent->_geometricTypes[typeNumber-1]=( MED_EN::medGeometryElement) MED_MESH_DRIVER22::all_cell_type[i] ;
1093 size+=tmpFaceCount[i]*((MED_MESH_DRIVER22::all_cell_type[i])%100) ;
1098 // Creation of the MEDSKYLINEARRAY
1099 //constituent->_nodal = new MEDSKYLINEARRAY(constituent->_count[constituent->_numberOfTypes]-1,size) ;
1100 //int * NodalIndex = constituent->_nodal->getIndex() ;
1101 int * NodalValue = new int[size] ;
1102 int * NodalIndex = new int[constituent->_count[constituent->_numberOfTypes]] ;
1105 // Fill the MEDSKYLINEARRAY by reading the MED file.
1106 for ( i=0; i<constituent->_numberOfTypes; i++)
1108 med_2_2::med_geometrie_element med_type = (med_2_2::med_geometrie_element) constituent->_type[i].getType() ;
1110 int NumberOfNodeByFace = constituent->_type[i].getNumberOfNodes() ;
1112 // initialise NodalIndex
1113 for (int j=constituent->_count[i]; j<constituent->_count[i+1];j++)
1114 NodalIndex[j]=NodalIndex[j-1]+NumberOfNodeByFace ;
1116 int tmp_numberOfFaces = constituent->_count[i+1]-constituent->_count[i] ;
1117 // Il faut ajouter 1 pour le zero a la lecture !!!
1118 // ATTENTION UNIQUEMENT POUR MED < 2.2.x
1119 //CCRT int * tmp_constituentArray = NULL;
1120 med_2_2::med_int * tmp_constituentArray = NULL;
1122 MESSAGE(LOC << "Med file version used here " << major << " " << minor << " " << release);
1124 if ((major == 2) && (minor <= 1))
1125 //CCRT tmp_constituentArray = new int[(NumberOfNodeByFace+1)*tmp_numberOfFaces] ;
1126 tmp_constituentArray = new med_2_2::med_int[(NumberOfNodeByFace+1)*tmp_numberOfFaces] ;
1127 else if ((major == 2) && (minor >= 2))
1129 //CCRT tmp_constituentArray = new int[NumberOfNodeByFace*tmp_numberOfFaces] ;
1130 tmp_constituentArray = new med_2_2::med_int[NumberOfNodeByFace*tmp_numberOfFaces] ;
1131 MESSAGE(LOC<<": WE ARE USING MED2.2 so there is no +1 for calculating the size of tmp_constituentArray !") ;
1134 int err=MEDconnLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
1135 Connectivity->_entityDimension,tmp_constituentArray,
1136 med_2_2::MED_FULL_INTERLACE,NULL,0,med_2_2::MED_MAILLE,med_type,med_2_2::MED_NOD);
1138 if ( err != MED_VALID)
1140 MESSAGE(LOC<<": MEDconnLire returns "<<err) ;
1141 delete constituent ;
1142 delete[] tmp_constituentArray;
1143 delete[] tmpFaceCount;
1144 delete[] tmpEdgeCount;
1148 int * constituentArray = NodalValue + NodalIndex[constituent->_count[i]-1]-1 ;
1150 // version originale sans prise en compte des numéros optionnels
1152 int multi = 0; // quand est-ce que multi vaut 1 ?? en MED-fichier < 2.2 ??
1153 MESSAGE(LOC << "Med file version used here " << major << " " << minor << " " << release);
1155 if ((major == 2) && (minor <= 1))
1156 for (int j=0; j<tmp_numberOfFaces; j++)
1157 for (int k=0; k<NumberOfNodeByFace; k++)
1158 constituentArray[j*NumberOfNodeByFace+k]=tmp_constituentArray[j*(NumberOfNodeByFace+1)+k] ;
1159 else if ((major == 2) && (minor >= 2))
1160 for (int j=0; j<tmp_numberOfFaces; j++)
1161 for (int k=0; k<NumberOfNodeByFace; k++)
1162 constituentArray[j*NumberOfNodeByFace+k]=tmp_constituentArray[j*(NumberOfNodeByFace+multi)+k] ;
1164 //////////////////////////////////////////////////////////////////////////////////////
1165 /// Modification pour prise en compte de la numérotation optionnelle des noeuds ///
1166 //////////////////////////////////////////////////////////////////////////////////////
1168 /// Rénumérote le tableau temporaire tmp_constituentArray en utilisant _optionnalToCanonicNodesNumbers
1169 /// Le traitement est identique à la version originelle s'il n'y a pas de numérotation optionnelle
1171 // if (_ptrMesh->_arePresentOptionnalNodesNumbers)
1173 // for (int j=0; j<tmp_numberOfFaces; j++) for (int k=0; k<NumberOfNodeByFace; k++)
1174 // constituentArray[j*NumberOfNodeByFace+k]=_ptrMesh->_optionnalToCanonicNodesNumbers[tmp_constituentArray[j*(NumberOfNodeByFace+1)+k]] ;
1178 // for (int j=0; j<tmp_numberOfFaces; j++) for (int k=0; k<NumberOfNodeByFace; k++)
1179 // constituentArray[j*NumberOfNodeByFace+k]=tmp_constituentArray[j*(NumberOfNodeByFace+1)+k] ;
1182 //////////////////////////////////////////////////////////////////////////////////////
1184 delete[] tmp_constituentArray;
1187 constituent->_nodal = new MEDSKYLINEARRAY(constituent->_count[constituent->_numberOfTypes]-1,
1191 delete[] NodalIndex ;
1192 delete[] NodalValue ;
1195 Connectivity->_constituent = constituent ;
1198 delete[] tmpFaceCount;
1203 if (numberOfEdgesTypes!=0)
1205 CONNECTIVITY * constituent = new CONNECTIVITY(numberOfEdgesTypes,MED_EDGE) ;
1206 constituent->_entityDimension = 1 ;
1207 constituent->_count[0]=1 ;
1211 // if you declare a variable <i> in two <for> initialization statement,
1212 // compiler gcc2.95.3 says nothing but there are two <i> variables in the same block
1213 //and the value you get in the common block seems to be the value of the first variable !
1216 for ( i=1; i<MED_NBR_GEOMETRIE_MAILLE; i++)
1217 { // no point1 cell type (?)
1218 if (tmpEdgeCount[i]>0)
1221 constituent->_count[typeNumber]=constituent->_count[typeNumber-1]+tmpEdgeCount[i];
1222 CELLMODEL t( (MED_EN::medGeometryElement) MED_MESH_DRIVER22::all_cell_type[i]) ;
1223 constituent->_type[typeNumber-1]=t ;
1225 constituent->_geometricTypes[typeNumber-1]=( MED_EN::medGeometryElement) MED_MESH_DRIVER22::all_cell_type[i] ;
1227 size+=tmpEdgeCount[i]*((MED_MESH_DRIVER22::all_cell_type[i])%100) ;
1232 // Creation of the MEDSKYLINEARRAY
1233 //constituent->_nodal = new MEDSKYLINEARRAY(constituent->_count[constituent->_numberOfTypes]-1,size) ;
1234 //int * NodalIndex = constituent->_nodal->getIndex() ;
1235 int * NodalValue = new int[size] ;
1236 int * NodalIndex = new int[constituent->_count[constituent->_numberOfTypes]] ;
1239 // Fill the MEDSKYLINEARRAY by reading the MED file.
1240 for ( i=0; i<constituent->_numberOfTypes; i++)
1242 med_2_2::med_geometrie_element med_type = (med_2_2::med_geometrie_element) constituent->_type[i].getType() ;
1244 int NumberOfNodeByEdge = constituent->_type[i].getNumberOfNodes() ;
1247 for (int j=constituent->_count[i]; j<constituent->_count[i+1];j++)
1248 NodalIndex[j]=NodalIndex[j-1]+NumberOfNodeByEdge ;
1250 int tmp_numberOfEdges = constituent->_count[i+1]-constituent->_count[i] ;
1251 // Il faut ajouter 1 pour le zero a la lecture !!!
1253 // ATTENTION UNIQUEMENT POUR MED < 2.2.x
1254 //CCRT int * tmp_constituentArray = NULL;
1255 med_2_2::med_int * tmp_constituentArray = NULL;
1257 MESSAGE(LOC << "Med file version used here " << major << " " << minor << " " << release);
1259 if ((major == 2) && (minor <= 1))
1260 //CCRT tmp_constituentArray = new int[(NumberOfNodeByEdge+1)*tmp_numberOfEdges] ;
1261 tmp_constituentArray = new med_2_2::med_int[(NumberOfNodeByEdge+1)*tmp_numberOfEdges] ;
1262 else if ((major == 2) && (minor >= 2))
1264 //CCRT tmp_constituentArray = new int[NumberOfNodeByEdge*tmp_numberOfEdges] ;
1265 tmp_constituentArray = new med_2_2::med_int[NumberOfNodeByEdge*tmp_numberOfEdges] ;
1266 MESSAGE(LOC<<": WE ARE USING MED2.2 so there is no +1 for calculating the size of tmp_constituentArray !") ;
1269 int err=MEDconnLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
1270 spaceDimension,tmp_constituentArray,
1271 med_2_2::MED_FULL_INTERLACE,NULL,0,med_2_2::MED_MAILLE,med_type,med_2_2::MED_NOD);
1272 if ( err != MED_VALID)
1274 MESSAGE(LOC<<": MEDconnLire returns "<<err) ;
1275 delete constituent ;
1276 delete[] tmp_constituentArray;
1277 delete[] tmpEdgeCount;
1281 int * constituentArray = NodalValue + NodalIndex[constituent->_count[i]-1]-1 ;
1283 // version originale sans prise en compte des numéros optionnels
1285 int multi = 0; // quand est-ce que multi vaut 1 ?? en MED-fichier < 2.2 ??
1286 MESSAGE(LOC << "Med file version used here " << major << " " << minor << " " << release);
1288 if ((major == 2) && (minor <= 1))
1289 for (int j=0; j<tmp_numberOfEdges; j++)
1290 for (int k=0; k<NumberOfNodeByEdge; k++)
1291 constituentArray[j*NumberOfNodeByEdge+k]=tmp_constituentArray[j*(NumberOfNodeByEdge+multi)+k] ;
1292 else if ((major == 2) && (minor >= 2))
1293 for (int j=0; j<tmp_numberOfEdges; j++)
1294 for (int k=0; k<NumberOfNodeByEdge; k++)
1295 constituentArray[j*NumberOfNodeByEdge+k]=tmp_constituentArray[j*(NumberOfNodeByEdge)+k] ;
1297 //////////////////////////////////////////////////////////////////////////////////////
1298 /// Modification pour prise en compte de la numérotation optionnelle des noeuds ///
1299 //////////////////////////////////////////////////////////////////////////////////////
1301 /// Rénumérote le tableau temporaire tmp_constituentArray en utilisant _optionnalToCanonicNodesNumbers
1302 /// Le traitement est identique à la version originelle s'il n'y a pas de numérotation optionnelle
1304 // if (_ptrMesh->_arePresentOptionnalNodesNumbers)
1306 // for (int j=0; j<tmp_numberOfEdges; j++) for (int k=0; k<NumberOfNodeByEdge; k++)
1307 // constituentArray[j*NumberOfNodeByEdge+k]=_ptrMesh->_optionnalToCanonicNodesNumbers[tmp_constituentArray[j*(NumberOfNodeByEdge+1)+k]] ;
1311 // for (int j=0; j<tmp_numberOfEdges; j++) for (int k=0; k<NumberOfNodeByEdge; k++)
1312 // constituentArray[j*NumberOfNodeByEdge+k]=tmp_constituentArray[j*(NumberOfNodeByEdge+1)+k] ;
1315 //////////////////////////////////////////////////////////////////////////////////////
1317 delete[] tmp_constituentArray;
1320 constituent->_nodal = new MEDSKYLINEARRAY(constituent->_count[constituent->_numberOfTypes]-1,
1325 delete[] NodalIndex ;
1326 delete[] NodalValue ;
1328 if (Connectivity->_entityDimension == 3)
1330 if (Connectivity->_constituent==NULL)
1331 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Edges are defined but there are no Faces !"));
1332 Connectivity->_constituent->_constituent = constituent ;
1334 Connectivity->_constituent = constituent ;
1337 delete[] tmpEdgeCount;
1340 } // end classic geometric types
1341 delete[] tmp_cells_count;
1345 // Lecture des polygones MED_CELL
1346 int NumberOfPolygons = MEDnEntMaa(_medIdt,
1347 const_cast <char *> (_ptrMesh->_name.c_str()),
1350 med_2_2::MED_POLYGONE,
1353 // Correction to permit the loading of mesh dimensionned at 2 even
1354 // if it has only MED_POLYGON elements
1356 if (NumberOfPolygons > 0)
1358 if (Connectivity->_entityDimension < 2) Connectivity->_entityDimension = 2;
1361 if (NumberOfPolygons > 0)
1363 // By consequence this exception will never occur
1364 if (Connectivity->_entityDimension == 1)
1365 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"In a 2D mesh, polygons need at least one 2D cell of a classic geometric type !"));
1366 med_int ConnectivitySize;
1367 med_err err1 = MEDpolygoneInfo(_medIdt,
1368 const_cast <char *> (_ptrMesh->_name.c_str()),
1372 if (err1 != MED_VALID)
1374 MESSAGE(LOC<<": MEDpolygoneInfo returns "<<err1);
1378 med_int* PolygonsConnectivity = new med_int[ConnectivitySize];
1379 med_int* PolygonsConnectivityIndex = new med_int[NumberOfPolygons+1];
1381 med_err err2 = MEDpolygoneConnLire(_medIdt,
1382 const_cast <char *> (_ptrMesh->_name.c_str()),
1383 PolygonsConnectivityIndex,
1385 PolygonsConnectivity,
1388 if (err2 != MED_VALID)
1390 MESSAGE(LOC<<": MEDpolygoneConnLire returns "<<err2);
1394 if (Connectivity->_entityDimension == 2) {// 2D mesh : polygons in Connectivity
1396 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
1397 int* tmp_PolygonsConnectivity = new int[ConnectivitySize];
1399 for ( i = 0 ; i < ConnectivitySize ; i++ )
1400 tmp_PolygonsConnectivity[i] = PolygonsConnectivity[i] ;
1401 int* tmp_PolygonsConnectivityIndex = new int[NumberOfPolygons+1];
1402 for ( i = 0 ; i < NumberOfPolygons+1 ; i++ )
1403 tmp_PolygonsConnectivityIndex[i] = PolygonsConnectivityIndex[i] ;
1404 Connectivity->setPolygonsConnectivity(MED_NODAL,(medEntityMesh) Entity,tmp_PolygonsConnectivity,tmp_PolygonsConnectivityIndex,ConnectivitySize,NumberOfPolygons);
1405 delete [] tmp_PolygonsConnectivity ;
1406 delete [] tmp_PolygonsConnectivityIndex ;
1408 Connectivity->setPolygonsConnectivity(MED_NODAL,(medEntityMesh) Entity,PolygonsConnectivity,PolygonsConnectivityIndex,ConnectivitySize,NumberOfPolygons);
1411 else if (Connectivity->_entityDimension == 3)
1413 if (Connectivity->_constituent == NULL) // 3D mesh : polygons in Connectivity->_constituent
1414 Connectivity->_constituent = new CONNECTIVITY(MED_FACE);
1415 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
1416 int* tmp_PolygonsConnectivity = new int[ConnectivitySize];
1418 for ( i = 0 ; i < ConnectivitySize ; i++ )
1419 tmp_PolygonsConnectivity[i] = PolygonsConnectivity[i] ;
1420 int* tmp_PolygonsConnectivityIndex = new int[NumberOfPolygons+1];
1421 for ( i = 0 ; i < NumberOfPolygons+1 ; i++ )
1422 tmp_PolygonsConnectivityIndex[i] = PolygonsConnectivityIndex[i] ;
1423 Connectivity->_constituent->setPolygonsConnectivity(MED_NODAL,MED_FACE,tmp_PolygonsConnectivity,tmp_PolygonsConnectivityIndex,ConnectivitySize,NumberOfPolygons);
1424 delete [] tmp_PolygonsConnectivity ;
1425 delete [] tmp_PolygonsConnectivityIndex ;
1427 Connectivity->_constituent->setPolygonsConnectivity(MED_NODAL,MED_FACE,PolygonsConnectivity,PolygonsConnectivityIndex,ConnectivitySize,NumberOfPolygons);
1431 delete[] PolygonsConnectivity;
1432 delete[] PolygonsConnectivityIndex;
1437 // Lecture des polyedres MED_CELL
1438 med_int NumberOfPolyhedron = MEDnEntMaa(_medIdt,
1439 const_cast <char *> (_ptrMesh->_name.c_str()),
1442 med_2_2::MED_POLYEDRE,
1445 // Correction to permit the loading of mesh dimensionned at 3 even
1446 // if it has only MED_POLYEDRE elements
1448 if (NumberOfPolyhedron > 0)
1450 Connectivity->_entityDimension = 3;
1453 if (NumberOfPolyhedron > 0)
1455 // By consequence this exception will never occur
1456 if (Connectivity->_entityDimension == 2 || Connectivity->_entityDimension == 1)
1457 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"In a 3D mesh, polyhedron need at least one 3D cell of a classic geometric type !"));
1458 med_int FacesIndexSize, NumberOfNodes, NumberOfFaces;
1459 med_err err3 = MEDpolyedreInfo(_medIdt,
1460 const_cast <char *> (_ptrMesh->_name.c_str()),
1464 NumberOfFaces = FacesIndexSize-1;
1465 if (err3 != MED_VALID)
1467 MESSAGE(LOC<<": MEDpolyhedreInfo returns "<<err3);
1471 med_int* Nodes = new med_int[NumberOfNodes];
1472 med_int* FacesIndex = new med_int[NumberOfFaces+1];
1473 med_int* PolyhedronIndex = new med_int[NumberOfPolyhedron+1];
1475 med_err err4 = MEDpolyedreConnLire(_medIdt,
1476 const_cast <char *> (_ptrMesh->_name.c_str()),
1478 NumberOfPolyhedron+1,
1483 if (err4 != MED_VALID)
1485 MESSAGE(LOC<<": MEDpolyedreConnLire returns "<<err4);
1490 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
1491 int* tmp_Nodes = new int[NumberOfNodes];
1493 for ( i = 0 ; i < NumberOfNodes ; i++ )
1494 tmp_Nodes[i] = Nodes[i] ;
1495 int* tmp_FacesIndex = new int[NumberOfFaces+1];
1496 for ( i = 0 ; i < NumberOfFaces+1 ; i++ )
1497 tmp_FacesIndex[i] = FacesIndex[i] ;
1498 int* tmp_PolyhedronIndex = new int[NumberOfPolyhedron+1];
1499 for ( i = 0 ; i < NumberOfPolyhedron+1 ; i++ )
1500 tmp_PolyhedronIndex[i] = PolyhedronIndex[i] ;
1501 Connectivity->setPolyhedronConnectivity(MED_NODAL,tmp_Nodes,tmp_PolyhedronIndex,NumberOfNodes,NumberOfPolyhedron,tmp_FacesIndex,NumberOfFaces);
1503 delete[] tmp_FacesIndex;
1504 delete[] tmp_PolyhedronIndex;
1506 Connectivity->setPolyhedronConnectivity(MED_NODAL,Nodes,PolyhedronIndex,NumberOfNodes,NumberOfPolyhedron,FacesIndex,NumberOfFaces);
1510 delete[] FacesIndex;
1511 delete[] PolyhedronIndex;
1516 // If there is no nodal connectivity, we return MED_ERROR !
1517 if (Connectivity->_numberOfTypes == 0 && NumberOfPolygons == 0 && NumberOfPolyhedron == 0)
1526 int MED_MESH_RDONLY_DRIVER22::getFAMILY()
1528 const char * LOC = "MED_MESH_RDONLY_DRIVER22::getFAMILY() : " ;
1531 if (_status==MED_OPENED)
1535 int * MEDArrayNodeFamily = NULL ;
1536 int ** MEDArrayCellFamily = NULL ;
1537 int ** MEDArrayFaceFamily = NULL ;
1538 int ** MEDArrayEdgeFamily = NULL ;
1541 MEDArrayNodeFamily = new int[_ptrMesh->getNumberOfNodes()] ;
1543 err = getNodesFamiliesNumber(MEDArrayNodeFamily) ;
1544 // error only if (_status!=MED_OPENED), other case exeception !
1547 MESSAGE(LOC << "error returned from getNodesFamiliesNumber " << err);
1549 MEDArrayCellFamily = new int* [_ptrMesh->getNumberOfTypesWithPoly(MED_CELL)] ;
1550 // ET SI IL N'Y A PAS DE CELLS ?
1552 medGeometryElement * myTypes = _ptrMesh->getTypesWithPoly(MED_CELL);
1553 for (int i=0;i<_ptrMesh->getNumberOfTypesWithPoly(MED_CELL);i++)
1554 MEDArrayCellFamily[i] = new
1555 int[_ptrMesh->getNumberOfElementsWithPoly(MED_CELL,myTypes[i])] ;
1557 err = getCellsFamiliesNumber(MEDArrayCellFamily,
1558 _ptrMesh->_connectivity,MED_CELL) ;
1561 MESSAGE(LOC << "error returned from getCellsFamiliesNumber for Cells " << err);
1563 if (_ptrMesh->_connectivity->_constituent != NULL)
1565 if (_ptrMesh->_connectivity->_constituent->_entity == MED_EN::MED_FACE)
1568 MEDArrayFaceFamily = new
1569 int* [_ptrMesh->getNumberOfTypesWithPoly(MED_FACE)] ;
1571 myTypes = _ptrMesh->getTypesWithPoly(MED_FACE);
1572 for (int i=0;i<_ptrMesh->getNumberOfTypesWithPoly(MED_FACE);i++)
1573 MEDArrayFaceFamily[i] = new
1574 int[_ptrMesh->getNumberOfElementsWithPoly(MED_FACE,myTypes[i])] ;
1577 getCellsFamiliesNumber(MEDArrayFaceFamily,
1578 _ptrMesh->_connectivity->_constituent,MED_FACE) ;
1580 MESSAGE(LOC << "error returned from getCellsFamiliesNumber for Faces " << err);
1585 MEDArrayEdgeFamily = new
1586 int* [_ptrMesh->getNumberOfTypes(MED_EDGE)] ;
1588 const medGeometryElement *myTypes2 = _ptrMesh->getTypes(MED_EDGE);
1589 for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_EDGE);i++)
1590 MEDArrayEdgeFamily[i] = new
1591 int[_ptrMesh->getNumberOfElements(MED_EDGE,myTypes2[i])] ;
1594 getCellsFamiliesNumber(MEDArrayEdgeFamily,
1595 _ptrMesh->_connectivity->_constituent,MED_FACE) ;
1597 MESSAGE(LOC << "error returned from getCellsFamiliesNumber for Edges in 2D " << err);
1600 if (_ptrMesh->_connectivity->_constituent->_constituent != NULL)
1602 MEDArrayEdgeFamily = new
1603 int* [_ptrMesh->getNumberOfTypes(MED_EDGE)] ;
1605 const medGeometryElement *myTypes2 = _ptrMesh->getTypes(MED_EDGE);
1606 for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_EDGE);i++)
1607 MEDArrayEdgeFamily[i] = new
1608 int[_ptrMesh->getNumberOfElements(MED_EDGE,myTypes2[i])] ;
1611 getCellsFamiliesNumber(MEDArrayEdgeFamily,
1612 _ptrMesh->_connectivity->_constituent->_constituent,MED_EDGE);
1615 MESSAGE(LOC << "error returned from getCellsFamiliesNumber for Edges in 3D " << err);
1620 int NumberOfFamilies = med_2_2::MEDnFam(_medIdt, const_cast <char *>
1621 (_meshName.c_str())) ;
1623 if ( NumberOfFamilies < 1 ) // at least family 0 must exist
1624 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"There is no FAMILY, FAMILY 0 must exists" ));
1626 SCRUTE(NumberOfFamilies);
1628 vector<FAMILY*> &NodeFamilyVector = _ptrMesh->_familyNode ;
1629 vector<FAMILY*> &CellFamilyVector = _ptrMesh->_familyCell ;
1630 vector<FAMILY*> &FaceFamilyVector = _ptrMesh->_familyFace ;
1631 vector<FAMILY*> &EdgeFamilyVector = _ptrMesh->_familyEdge ;
1633 int numberOfNodesFamilies = 0 ;
1634 int numberOfCellsFamilies = 0 ;
1635 int numberOfFacesFamilies = 0 ;
1636 int numberOfEdgesFamilies = 0 ;
1638 for (int i=0;i<NumberOfFamilies;i++)
1640 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
1641 med_int tmp_NumberOfAttributes = med_2_2::MEDnAttribut(_medIdt,
1643 (_meshName.c_str()),
1645 int NumberOfAttributes = tmp_NumberOfAttributes ;
1647 int NumberOfAttributes = med_2_2::MEDnAttribut(_medIdt,
1649 (_meshName.c_str()),
1653 if (NumberOfAttributes < 0)
1654 throw MEDEXCEPTION("MED_MESH_RDONLY_DRIVER22::getFAMILY() : NumberOfAttributes" );
1656 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
1657 med_int tmp_NumberOfGroups = med_2_2::MEDnGroupe(_medIdt, const_cast <char *>
1658 (_meshName.c_str()),(i+1)) ;
1659 int NumberOfGroups = tmp_NumberOfGroups ;
1661 int NumberOfGroups = med_2_2::MEDnGroupe(_medIdt, const_cast <char *>
1662 (_meshName.c_str()),(i+1)) ;
1665 if (NumberOfGroups < 0)
1666 throw MEDEXCEPTION("MED_MESH_RDONLY_DRIVER22::getFAMILY() : NumberOfGroups" );
1668 int FamilyIdentifier ;
1669 string FamilyName(MED_TAILLE_NOM,'\0');
1670 int * AttributesIdentifier = new int[NumberOfAttributes] ;
1671 int * AttributesValues = new int[NumberOfAttributes] ;
1672 string AttributesDescription(MED_TAILLE_DESC*NumberOfAttributes,' ') ;
1673 string GroupsNames(MED_TAILLE_LNOM*NumberOfGroups+1,'\0') ;
1674 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
1675 med_int tmp_FamilyIdentifier ;
1676 med_int * tmp_AttributesIdentifier = new med_int[NumberOfAttributes] ;
1677 med_int * tmp_AttributesValues = new med_int[NumberOfAttributes] ;
1678 err = med_2_2::MEDfamInfo(_medIdt,const_cast <char *>
1679 (_meshName.c_str()),
1680 (i+1),const_cast <char *>
1681 (FamilyName.c_str()), &tmp_FamilyIdentifier,
1682 tmp_AttributesIdentifier,tmp_AttributesValues,
1684 (AttributesDescription.c_str()),
1685 &tmp_NumberOfAttributes, const_cast <char *>
1686 (GroupsNames.c_str()),&tmp_NumberOfGroups);
1687 FamilyIdentifier = tmp_FamilyIdentifier ;
1689 for ( ii = 0 ; ii < NumberOfAttributes ; ii++ ) {
1690 AttributesIdentifier[ii] = tmp_AttributesIdentifier[ii] ;
1691 AttributesValues[ii] = tmp_AttributesValues[ii] ;
1693 NumberOfAttributes = tmp_NumberOfAttributes ;
1694 NumberOfGroups = tmp_NumberOfGroups ;
1695 delete [] tmp_AttributesIdentifier ;
1696 delete [] tmp_AttributesValues ;
1698 err = med_2_2::MEDfamInfo(_medIdt,const_cast <char *>
1699 (_meshName.c_str()),
1700 (i+1),const_cast <char *>
1701 (FamilyName.c_str()), &FamilyIdentifier,
1702 AttributesIdentifier,AttributesValues,
1704 (AttributesDescription.c_str()),
1705 &NumberOfAttributes, const_cast <char *>
1706 (GroupsNames.c_str()),&NumberOfGroups);
1710 SCRUTE(GroupsNames);
1715 if (err != MED_VALID)
1716 throw MEDEXCEPTION("MED_MESH_RDONLY_DRIVER22::getFAMILY() : ERROR when get FAMILY informations" );
1718 if (FamilyIdentifier != 0 )
1720 FAMILY * Family = new FAMILY(_ptrMesh,FamilyIdentifier,FamilyName,
1722 AttributesIdentifier,
1724 AttributesDescription,
1725 NumberOfGroups,GroupsNames,
1729 MEDArrayEdgeFamily) ;
1732 // if nothing found, delete Family
1734 if (Family->getNumberOfTypes() == 0)
1736 MESSAGE(LOC<<"Nothing found for family "<<FamilyName<<
1741 switch (Family->getEntity())
1743 case MED_EN::MED_NODE :
1744 NodeFamilyVector.push_back(Family) ;
1745 numberOfNodesFamilies++ ;
1747 case MED_EN::MED_CELL :
1748 CellFamilyVector.push_back(Family) ;
1749 numberOfCellsFamilies++ ;
1751 case MED_EN::MED_FACE :
1752 FaceFamilyVector.push_back(Family) ;
1753 numberOfFacesFamilies++ ;
1755 case MED_EN::MED_EDGE :
1756 EdgeFamilyVector.push_back(Family) ;
1757 numberOfEdgesFamilies++ ;
1760 // MESSAGE(LOC << (*Family));
1763 delete [] AttributesIdentifier ;
1764 delete [] AttributesValues ;
1767 if (MEDArrayNodeFamily != NULL)
1768 delete[] MEDArrayNodeFamily ;
1770 if (MEDArrayCellFamily != NULL)
1772 for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_CELL);i++)
1773 delete[] MEDArrayCellFamily[i] ;
1774 delete[] MEDArrayCellFamily ;
1777 if (MEDArrayFaceFamily != NULL)
1779 for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_FACE);i++)
1780 delete[] MEDArrayFaceFamily[i] ;
1781 delete[] MEDArrayFaceFamily ;
1784 if (MEDArrayEdgeFamily != NULL)
1786 for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_EDGE);i++)
1787 delete[] MEDArrayEdgeFamily[i] ;
1788 delete[] MEDArrayEdgeFamily ;
1798 int MED_MESH_RDONLY_DRIVER22::getNodesFamiliesNumber(int * MEDArrayNodeFamily)
1800 const char * LOC = "MED_MESH_RDONLY_DRIVER22::getNodesFamiliesNumber() : " ;
1804 if (_status==MED_OPENED)
1808 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
1809 med_int * tmp_MEDArrayNodeFamily = new med_int[_ptrMesh->getNumberOfNodes()] ;
1810 err = MEDfamLire(_medIdt, const_cast <char *>
1811 (_ptrMesh->_name.c_str()), tmp_MEDArrayNodeFamily,
1812 _ptrMesh->getNumberOfNodes(), med_2_2::MED_NOEUD,
1813 (med_2_2::med_geometrie_element) MED_NONE);
1815 for ( i = 0 ; i < _ptrMesh->getNumberOfNodes() ; i++ )
1816 MEDArrayNodeFamily[i] = tmp_MEDArrayNodeFamily[i] ;
1818 err = MEDfamLire(_medIdt, const_cast <char *>
1819 (_ptrMesh->_name.c_str()), MEDArrayNodeFamily,
1820 _ptrMesh->getNumberOfNodes(), med_2_2::MED_NOEUD,
1821 (med_2_2::med_geometrie_element) MED_NONE);
1824 if ( err != MED_VALID)
1825 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "There is no family for the |"<< _ptrMesh->getNumberOfNodes() << "| nodes in mesh |" << _ptrMesh->_name.c_str() << "|"));
1834 int MED_MESH_RDONLY_DRIVER22::getCellsFamiliesNumber(int **MEDArrayFamily,
1835 CONNECTIVITY *Connectivity,
1836 MED_EN::medEntityMesh entity)
1838 const char * LOC = "MED_MESH_RDONLY_DRIVER22::getCellsFamiliesNumber " ;
1842 if (_status==MED_OPENED)
1845 MED_EN::medGeometryElement *types=Connectivity->getGeometricTypesWithPoly(Connectivity->_entity);
1846 for (i=0;i<Connectivity->getNumberOfTypesWithPoly(Connectivity->_entity);i++)
1848 int NumberOfCell=Connectivity->getNumberOfElementsWithPoly(Connectivity->_entity,types[i]);
1849 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
1850 med_2_2::med_int * tmp_MEDArrayFamily = new med_2_2::med_int[NumberOfCell] ;
1851 err=MEDfamLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
1852 tmp_MEDArrayFamily,NumberOfCell,
1853 (med_2_2::med_entite_maillage) Connectivity->_entity,
1854 (med_2_2::med_geometrie_element)types[i]);
1855 if (err != MED_VALID)
1857 err=MEDfamLire(_medIdt,const_cast <char *>
1858 (_ptrMesh->_name.c_str()),
1859 tmp_MEDArrayFamily,NumberOfCell,
1860 med_2_2::MED_MAILLE,
1861 (med_2_2::med_geometrie_element)types[i]);
1862 if (err != MED_VALID)
1863 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Family not found for entity "<<Connectivity->_entity<<" and geometric type "<<types[i]));
1866 for ( ii = 0 ; ii < NumberOfCell ; ii++ )
1867 MEDArrayFamily[i][ii] = tmp_MEDArrayFamily[ii] ;
1868 delete [] tmp_MEDArrayFamily ;
1870 err=MEDfamLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
1871 MEDArrayFamily[i],NumberOfCell,
1872 (med_2_2::med_entite_maillage) Connectivity->_entity,
1873 (med_2_2::med_geometrie_element)types[i]);
1874 if (err != MED_VALID)
1876 err=MEDfamLire(_medIdt,const_cast <char *>
1877 (_ptrMesh->_name.c_str()),
1878 MEDArrayFamily[i],NumberOfCell,
1879 med_2_2::MED_MAILLE,
1880 (med_2_2::med_geometrie_element)types[i]);
1881 if (err != MED_VALID)
1882 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Family not found for entity "<<Connectivity->_entity<<" and geometric type "<<types[i]));
1892 /*--------------------- WRONLY PART -------------------------------*/
1894 MED_MESH_WRONLY_DRIVER22::MED_MESH_WRONLY_DRIVER22()
1898 MED_MESH_WRONLY_DRIVER22::MED_MESH_WRONLY_DRIVER22(const string & fileName,
1900 MED_MESH_DRIVER22(fileName,ptrMesh,MED_WRONLY),IMED_MESH_WRONLY_DRIVER(fileName,ptrMesh),MED_MESH_DRIVER(fileName,ptrMesh,MED_WRONLY)
1902 MESSAGE("MED_MESH_WRONLY_DRIVER22::MED_MESH_WRONLY_DRIVER22(const string & fileName, MESH * ptrMesh) has been created");
1905 MED_MESH_WRONLY_DRIVER22::MED_MESH_WRONLY_DRIVER22(const MED_MESH_WRONLY_DRIVER22 & driver):
1906 IMED_MESH_WRONLY_DRIVER(driver),MED_MESH_DRIVER22(driver),MED_MESH_DRIVER(driver)
1910 MED_MESH_WRONLY_DRIVER22::~MED_MESH_WRONLY_DRIVER22()
1912 //MESSAGE("MED_MESH_WRONLY_DRIVER22::MED_MESH_WRONLY_DRIVER22(const string & fileName, MESH * ptrMesh) has been destroyed");
1915 GENDRIVER * MED_MESH_WRONLY_DRIVER22::copy(void) const
1917 return new MED_MESH_WRONLY_DRIVER22(*this);
1920 void MED_MESH_WRONLY_DRIVER22::write(void) const
1922 const char * LOC = "void MED_MESH_WRONLY_DRIVER22::write(void) const : ";
1925 // we must first create mesh !!
1926 MESSAGE(LOC << "MeshName : |" << _meshName << "| FileName : |"<<_fileName<<"| MedIdt : | "<< _medIdt << "|");
1928 if (_status!=MED_OPENED)
1929 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "File "<<_fileName<<" is not open. Open it before write !"));
1932 if ( ( _meshName.empty() ) && ( _ptrMesh->_name.empty() ) )
1933 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)
1934 <<" neither <meshName> is set in driver nor in object MESH.")) ;
1936 // If _meshName is not set in driver, try to use _ptrmesh->_meshName
1937 if ( ( _meshName.empty() ) && ( !_ptrMesh->_name.empty() ) )
1938 _meshName=_ptrMesh->_name;
1940 if ( _meshName.size() > MED_TAILLE_NOM )
1941 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)
1942 <<" <meshName> size in object driver MESH is > MED_TAILLE_NOM ."));
1945 if (_ptrMesh->getIsAGrid())
1947 if ( writeGRID() != MED_VALID )
1948 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeGRID()" )) ;
1952 if (writeCoordinates()!=MED_VALID)
1953 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeCoordinates()" )) ;
1955 if (writeConnectivities(MED_EN::MED_CELL)!=MED_VALID)
1956 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeConnectivities(MED_CELL)" )) ;
1957 if (writeConnectivities(MED_EN::MED_FACE)!=MED_VALID)
1958 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeConnectivities(MED_FACE)" )) ;
1959 if (writeConnectivities(MED_EN::MED_EDGE)!=MED_VALID)
1960 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeConnectivities(MED_EDGE)" )) ;
1963 if (writeFamilyNumbers() !=MED_VALID)
1964 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilyNumbers()" )) ;
1967 // well we must first write zero family :
1968 if (_status==MED_OPENED) {
1970 // test if the family already exists (HDF trick waiting a MED evolution to be replaced)
1971 string dataGroupFam = "/ENS_MAA/"+_meshName+"/FAS/FAMILLE_ZERO/";
1972 MESSAGE("|"<<dataGroupFam<<"|");
1973 err =med_2_2::_MEDdatagroupOuvrir(_medIdt,const_cast <char *> (dataGroupFam.c_str()) );
1974 if ( err < MED_VALID ) {
1977 char familyName[MED_TAILLE_NOM+1];
1978 // strcpy(familyName,"FAMILLE_ZERO");
1979 err = med_2_2::MEDfamCr( _medIdt,
1980 const_cast <char *> ( _meshName.c_str() ),
1982 //CCRT (int*)NULL, (int*)NULL, (char*)NULL, 0,
1983 (med_2_2::med_int*)NULL, (med_2_2::med_int*)NULL, (char*)NULL, 0,
1988 if ( err != MED_VALID)
1989 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't create family |FAMILLE_ZERO| with identifier |0| groups names || and attributes descriptions ||")) ;
1992 med_2_2::_MEDdatagroupFermer(_medIdt);
1996 MESSAGE(LOC<<"writeFamilies(_ptrMesh->_familyNode)");
1997 if (writeFamilies(_ptrMesh->_familyNode) !=MED_VALID)
1998 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilies(_ptrMesh->_familyNode)" )) ;
2000 MESSAGE(LOC<<"writeFamilies(_ptrMesh->_familyCell)");
2001 if (writeFamilies(_ptrMesh->_familyCell) !=MED_VALID)
2002 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilies(_ptrMesh->_familyCell)" )) ;
2004 MESSAGE(LOC<<"writeFamilies(_ptrMesh->_familyFace)");
2005 if (writeFamilies(_ptrMesh->_familyFace) !=MED_VALID)
2006 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilies(_ptrMesh->_familyFace)" )) ;
2008 MESSAGE(LOC<<"writeFamilies(_ptrMesh->_familyEdge)");
2009 if (writeFamilies(_ptrMesh->_familyEdge) !=MED_VALID)
2010 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilies(_ptrMesh->_familyEdge)" )) ;
2015 //=======================================================================
2016 //function : writeGRID
2018 //=======================================================================
2020 int MED_MESH_WRONLY_DRIVER22::writeGRID() const
2022 const char * LOC = "MED_MESH_WRONLY_DRIVER22::writeGRID() : " ;
2025 if (_status!=MED_OPENED)
2027 MESSAGE (LOC<<" Not open !!!");
2030 GRID * ptrGrid = (GRID*) _ptrMesh;
2032 med_2_2::med_err err = MED_ERROR;
2033 med_2_2::med_repere rep;
2034 string tmp_name(_ptrMesh->_spaceDimension*MED_TAILLE_PNOM22,' ');
2035 string tmp_unit(_ptrMesh->_spaceDimension*MED_TAILLE_PNOM22,' ');
2037 // Test if the mesh <_meshName> already exists
2038 // If it doesn't exists create it
2039 // If it already exists verify if its space and mesh dimensions are the same
2040 // as <_ptrMesh->_spaceDimension>, <_ptrMesh->_meshDimension> respectively
2041 // rem : <_meshName> is the driver meshName not <ptrMesh->_meshName>
2043 int spaceDimension = med_2_2::MEDdimEspaceLire(_medIdt, const_cast <char *>
2044 (_meshName.c_str()) );
2046 int meshDimension = med_2_2::MEDdimLire(_medIdt, const_cast <char *>
2047 (_meshName.c_str()) );
2050 MESSAGE(LOC << "spacedim " << spaceDimension << " meshdim " << meshDimension);
2052 MESSAGE(LOC << "From the mesh spacedim " << _ptrMesh->_spaceDimension << " meshdim " << _ptrMesh->_meshDimension);
2054 if ((spaceDimension <= MED_VALID) && (meshDimension <= MED_VALID))
2056 err = MEDmaaCr(_medIdt,
2057 const_cast <char *> (_meshName.c_str()),
2058 _ptrMesh->_meshDimension,med_2_2::MED_STRUCTURE,
2059 const_cast <char *> (_ptrMesh->_description.c_str()));
2061 meshDimension = _ptrMesh->_meshDimension;
2063 if (err != MED_VALID)
2064 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Unable to create Grid"));
2066 MESSAGE(LOC<<"Grid "<<_meshName<<" created in file "<<_fileName<<" !");
2068 else if ((spaceDimension != _ptrMesh->_spaceDimension) &&
2069 (meshDimension != _ptrMesh->_meshDimension))
2070 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Grid |" << _meshName.c_str() <<
2071 "| already exists in file |" << _fileName <<
2072 "| with space dimension |" << spaceDimension <<
2073 "| and mesh dimension |" << meshDimension <<
2074 "| but the space dimension and the mesh dimension of the mesh we want to write are respectively |"
2075 << _ptrMesh->_spaceDimension <<"|" <<
2076 _ptrMesh->_meshDimension <<"|" )) ;
2078 MED_EN::med_grid_type gridType = ptrGrid->getGridType();
2080 err = med_2_2::MEDnatureGrilleEcr(_medIdt,
2081 const_cast <char *> (_meshName.c_str()),
2082 (med_2_2::med_type_grille) gridType);
2084 if (err != MED_VALID)
2085 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Unable to write the type of the Grid"));
2087 // Recompose the <_spaceDimension> strings in 1 string
2089 string valueString ;
2090 for (int i=0;i<_ptrMesh->_spaceDimension;i++) {
2092 valueString = _ptrMesh->_coordinate->_coordinateName[i] ;
2093 lengthString = (MED_TAILLE_PNOM22<valueString.size())?MED_TAILLE_PNOM22:valueString.size() ;
2094 tmp_name.replace(i*MED_TAILLE_PNOM22,i*MED_TAILLE_PNOM22+lengthString,valueString,0,lengthString);
2095 valueString = _ptrMesh->_coordinate->_coordinateUnit[i];
2096 lengthString = (MED_TAILLE_PNOM22<valueString.size())?MED_TAILLE_PNOM22:valueString.size() ;
2097 tmp_unit.replace(i*MED_TAILLE_PNOM22,i*MED_TAILLE_PNOM22+lengthString,valueString,0,lengthString);
2100 // Pourquoi le stocker sous forme de chaîne ?
2101 const string & coordinateSystem = _ptrMesh->_coordinate->_coordinateSystem;
2102 if (coordinateSystem == "CARTESIAN")
2103 rep = med_2_2::MED_CART;
2104 else if ( coordinateSystem == "CYLINDRICAL")
2105 rep = med_2_2::MED_CYL;
2106 else if ( coordinateSystem == "SPHERICAL" )
2107 rep = med_2_2::MED_SPHER;
2109 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Grid |" << _meshName.c_str() <<
2110 "| doesn't have a valid coordinate system : |"
2111 << _ptrMesh->_coordinate->_coordinateSystem
2114 med_2_2::med_int ArrayLen[] = { (med_2_2::med_int) ptrGrid->_iArrayLength,
2115 (med_2_2::med_int) ptrGrid->_jArrayLength,
2116 (med_2_2::med_int) ptrGrid->_kArrayLength };
2118 // Write node coordinates for MED_BODY_FITTED grid
2119 if (gridType == MED_EN::MED_BODY_FITTED)
2121 // Write Coordinates and families
2122 // double * coo = const_cast <double *>
2123 // (_ptrMesh->_coordinate->getCoordinates(MED_EN::MED_FULL_INTERLACE));
2125 err = MEDcoordEcr(_medIdt, const_cast <char *> (_meshName.c_str()),
2126 _ptrMesh->_spaceDimension,
2127 //const_cast <double *> ( _ptrMesh->_coordinate->_coordinate->get(MED_EN::MED_FULL_INTERLACE) ),
2128 const_cast <double *> ( _ptrMesh->_coordinate->_coordinate.get(MED_EN::MED_FULL_INTERLACE) ),
2129 med_2_2::MED_FULL_INTERLACE, _ptrMesh->_numberOfNodes,
2130 // _ptrMesh->_coordinate->_numberOfNodes
2131 rep, const_cast <char *> (tmp_name.c_str()),
2132 const_cast <char *> (tmp_unit.c_str()));
2134 if (err != MED_VALID)
2135 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write coordinates of the grid |" << _meshName.c_str() << "| in file |" << _fileName
2136 << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
2137 << " with units names |" << tmp_name
2138 << "| and units |" << tmp_unit
2141 //CCRT int* structure = new int [meshDimension];
2142 med_2_2::med_int* structure = new med_2_2::med_int [meshDimension];
2144 for (int idim = 0; idim < meshDimension; ++idim)
2145 structure[idim] = ArrayLen [idim];
2148 err = med_2_2::MEDstructureCoordEcr(_medIdt, const_cast <char *>
2149 (_meshName.c_str()), meshDimension,
2152 if (err != MED_VALID)
2153 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"error in writing the structure of the grid |" << _meshName.c_str()));
2157 else if ((gridType == MED_EN::MED_CARTESIAN) ||
2158 (gridType == MED_EN::MED_POLAR))
2160 // Write Arrays of Cartesian or Polar Grid
2162 double * Array[] = { ptrGrid->_iArray,
2166 for (int idim = 0; idim < _ptrMesh->_meshDimension; ++idim)
2168 string str_name = string (tmp_name,idim*MED_TAILLE_PNOM22,
2170 string str_unit = string (tmp_unit,idim*MED_TAILLE_PNOM22,
2173 err = med_2_2::MEDindicesCoordEcr(_medIdt, const_cast <char *>
2174 (_ptrMesh->_name.c_str()),
2175 _ptrMesh->_meshDimension,
2176 Array[idim], ArrayLen[idim],
2177 (idim+1), const_cast <char *>
2180 (str_unit.c_str()));
2182 if (err != MED_VALID)
2183 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<
2184 "Can't write grid coordinates for " <<
2185 idim << "-th dimention"));
2187 } // end Write Cartesian or Polar Grid
2193 //=======================================================================
2194 //function : writeCoordinates
2196 //=======================================================================
2198 int MED_MESH_WRONLY_DRIVER22::writeCoordinates() const {
2200 const char * LOC = "int MED_MESH_WRONLY_DRIVER22::writeCoordinates() const : ";
2203 med_2_2::med_err err = MED_ERROR;
2204 med_2_2::med_repere rep;
2205 string tmp_name(_ptrMesh->_spaceDimension*MED_TAILLE_PNOM22,' ');
2206 string tmp_unit(_ptrMesh->_spaceDimension*MED_TAILLE_PNOM22,' ');
2208 // Recompose the <_spaceDimension> strings in 1 string
2210 string valueString ;
2211 for (int i=0;i<_ptrMesh->_spaceDimension;i++) {
2212 valueString = _ptrMesh->_coordinate->_coordinateName[i] ;
2213 lengthString = (MED_TAILLE_PNOM22<valueString.size())?MED_TAILLE_PNOM22:valueString.size() ;
2214 tmp_name.replace(i*MED_TAILLE_PNOM22,i*MED_TAILLE_PNOM22+lengthString,valueString,0,lengthString);
2215 valueString = _ptrMesh->_coordinate->_coordinateUnit[i];
2216 lengthString = (MED_TAILLE_PNOM22<valueString.size())?MED_TAILLE_PNOM22:valueString.size() ;
2217 tmp_unit.replace(i*MED_TAILLE_PNOM22,i*MED_TAILLE_PNOM22+lengthString,valueString,0,lengthString);
2220 // Test if the mesh <_meshName> already exists
2221 // If it doesn't exists create it
2222 // If it already exists verify if its space and mesh dimensions are the same
2223 // as <_ptrMesh->_spaceDimension>, <_ptrMesh->_meshDimension> respectively
2224 // rem : <_meshName> is the driver meshName not <ptrMesh->_meshName>
2226 int spaceDimension = med_2_2::MEDdimEspaceLire(_medIdt, const_cast <char *>
2227 (_meshName.c_str()));
2229 int meshDimension = med_2_2::MEDdimLire(_medIdt, const_cast <char *>
2230 (_meshName.c_str()) );
2232 SCRUTE(spaceDimension);
2233 SCRUTE(meshDimension);
2234 SCRUTE(_ptrMesh->_spaceDimension);
2235 SCRUTE(_ptrMesh->_meshDimension);
2237 if ((spaceDimension != MED_VALID) && (meshDimension < MED_VALID))
2239 err = MEDmaaCr(_medIdt, const_cast <char *> (_meshName.c_str()),
2240 _ptrMesh->_meshDimension, med_2_2::MED_NON_STRUCTURE,
2241 const_cast <char *> (_ptrMesh->_description.c_str()));
2243 if (err < MED_VALID)
2244 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Unable to create Mesh : |" << _meshName << "|"));
2246 MESSAGE(LOC<<"Mesh "<<_meshName<<" created in file "<<_fileName<<" !");
2248 else if ((spaceDimension != _ptrMesh->_spaceDimension) &&
2249 (meshDimension != _ptrMesh->_meshDimension))
2250 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Mesh |" << _meshName.c_str() <<
2251 "| already exists in file |" << _fileName <<
2252 "| with space dimension |" << spaceDimension <<
2253 "| and mesh dimension |" << meshDimension <<
2254 "| but the space dimension and the mesh dimension of the mesh we want to write are respectively |"
2255 << _ptrMesh->_spaceDimension <<"|" <<
2256 _ptrMesh->_meshDimension << "|")) ;
2258 // Pourquoi le stocker sous forme de chaîne ?
2259 const string & coordinateSystem = _ptrMesh->_coordinate->_coordinateSystem;
2260 if (coordinateSystem == "CARTESIAN")
2261 rep = med_2_2::MED_CART;
2262 else if ( coordinateSystem == "CYLINDRICAL")
2263 rep = med_2_2::MED_CYL;
2264 else if ( coordinateSystem == "SPHERICAL" )
2265 rep = med_2_2::MED_SPHER;
2267 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Mesh |" << _meshName.c_str() << "| doesn't have a valid coordinate system : |"
2268 << _ptrMesh->_coordinate->_coordinateSystem
2271 // err = MEDcoordEcr(_medIdt, const_cast <char *> (_meshName.c_str()),
2272 // _ptrMesh->_spaceDimension,
2273 // //const_cast <double *> ( _ptrMesh->_coordinate->_coordinate->get(MED_EN::MED_FULL_INTERLACE) ),
2274 // const_cast <double *> ( _ptrMesh->_coordinate->_coordinate.get(MED_EN::MED_FULL_INTERLACE) ),
2275 // MED_FR::MED_FULL_INTERLACE,
2276 // _ptrMesh->_numberOfNodes, // _ptrMesh->_coordinate->_numberOfNodes
2277 // MED_FR::MED_LECTURE_ECRITURE,
2279 // const_cast <char *> (tmp_name.c_str()),
2280 // const_cast <char *> (tmp_unit.c_str())
2283 err = MEDcoordEcr(_medIdt, const_cast <char *> (_meshName.c_str()),
2284 _ptrMesh->_spaceDimension,
2285 //const_cast <double *> ( _ptrMesh->_coordinate->_coordinate->get(MED_EN::MED_FULL_INTERLACE) ),
2286 const_cast <double *> ( _ptrMesh->_coordinate->_coordinate.get(MED_EN::MED_FULL_INTERLACE) ),
2287 med_2_2::MED_FULL_INTERLACE, _ptrMesh->_numberOfNodes,
2288 // _ptrMesh->_coordinate->_numberOfNodes
2289 rep, const_cast <char *> (tmp_name.c_str()),
2290 const_cast <char *> (tmp_unit.c_str()));
2293 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write coordinates of mesh |" << _meshName.c_str() << "| in file |" << _fileName
2294 << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
2295 << " with units names |" << tmp_name
2296 << "| and units |" << tmp_unit
2300 //////////////////////////////////////////////////////////////////////////////////////
2301 /// Modification pour prise en compte de la numérotation optionnelle des noeuds ///
2302 //////////////////////////////////////////////////////////////////////////////////////
2304 /// Ecrit les numéros optionnels des noeuds
2305 /// Le traitement est identique à la version originelle s'il n'y a pas de numérotation optionnelle
2308 if (_ptrMesh->_arePresentOptionnalNodesNumbers==1) {
2310 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
2311 const int * NodesNumbers = _ptrMesh->_coordinate->getNodesNumbers() ;
2312 med_2_2::med_int * tmp_NodesNumbers = new med_int[_ptrMesh->_numberOfNodes] ;
2314 for ( ii = 0 ; ii < _ptrMesh->_numberOfNodes ; ii++ )
2315 tmp_NodesNumbers[ii] = NodesNumbers[ii] ;
2316 err = MEDnumEcr(_medIdt, const_cast <char *> (_meshName.c_str()),
2318 _ptrMesh->_numberOfNodes, med_2_2::MED_NOEUD,
2319 med_2_2::med_geometrie_element(0) );
2320 delete [] tmp_NodesNumbers ;
2322 err = MEDnumEcr(_medIdt, const_cast <char *> (_meshName.c_str()),
2323 const_cast <med_int *> (_ptrMesh->_coordinate->getNodesNumbers() ),
2324 _ptrMesh->_numberOfNodes, med_2_2::MED_NOEUD,
2325 med_2_2::med_geometrie_element(0) );
2328 if (err != MED_VALID)
2329 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write optionnal numbers of mesh |" <<
2330 _meshName.c_str() << "| in file |" <<
2331 _fileName << " |")) ;
2333 //////////////////////////////////////////////////////////////////////////////////////
2343 int MED_MESH_WRONLY_DRIVER22::writeConnectivities(medEntityMesh entity) const
2345 const char * LOC="int MED_MESH_WRONLY_DRIVER22::writeConnectivities() const : ";
2348 med_2_2::med_err err;
2350 // REM SI LA METHODE EST APPELEE DIRECTEMENT ET QUE LE MAILLAGE N'EST PAS CREE IL Y A PB !
2351 // PG : IMPOSSIBLE : LA METHODE EST PRIVEE !
2353 // A FAIRE : A tester surtout dans les methodes de MESH.
2354 // if ( _ptrMesh->_connectivity == (CONNECTIVITY *) MED_INVALID )
2355 if ( _ptrMesh->_connectivity == (CONNECTIVITY *) NULL )
2356 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The connectivity is not defined in the MESH object ")) ;
2359 // Nodal connectivity for classic geometric types
2360 if ( _ptrMesh->existConnectivity(MED_NODAL,entity) )
2363 int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ;
2364 const medGeometryElement * types = _ptrMesh->getTypes (entity) ;
2366 for (int i=0; i<numberOfTypes; i++)
2369 int numberOfElements = _ptrMesh->getNumberOfElements (entity,types[i]);
2370 const int * connectivity = _ptrMesh->getConnectivity (MED_EN::MED_FULL_INTERLACE,
2371 MED_NODAL, entity, types[i]); // ?? et SI MED_NODAL n'existe pas, recalcul auto ??
2373 // Pour l'instant la class utilise le multi.....
2375 // if (entity==MED_EN::MED_CELL)
2376 // if ( (types[i]/ 100) < _ptrMesh->_spaceDimension)
2378 int numberOfNodes = types[i]%100 ;
2379 //CCRT int * connectivityArray = new int[numberOfElements*(numberOfNodes+multi)];
2380 med_2_2::med_int * connectivityArray = new med_2_2::med_int[numberOfElements*(numberOfNodes+multi)];
2382 // version originale sans prise en compte des numéros optionnels
2384 for (int j=0 ; j<numberOfElements; j++)
2386 for (int k=0; k<numberOfNodes; k++)
2387 connectivityArray[j*(numberOfNodes+multi)+k]=connectivity[j*numberOfNodes+k] ;
2389 if (multi>0) connectivityArray[j*(numberOfNodes+multi)+numberOfNodes]=0;
2392 //////////////////////////////////////////////////////////////////////////////////////
2393 /// Modification pour prise en compte de la numérotation optionnelle des noeuds ///
2394 //////////////////////////////////////////////////////////////////////////////////////
2396 /// Dénumérote les sommets des mailles pour leur rendre leurs numéros optionnels
2397 /// Le traitement est identique à la version originelle s'il n'y a pas de numérotation optionnelle
2399 // if (_ptrMesh->_arePresentOptionnalNodesNumbers==1)
2401 // const int * nodesNumbers = _ptrMesh->_coordinate->getNodesNumbers();
2402 // for (int j=0 ; j<numberOfElements; j++)
2404 // for (int k=0; k<numberOfNodes; k++) connectivityArray[j*(numberOfNodes+multi)+k]=nodesNumbers[connectivity[j*numberOfNodes+k]-1] ;
2405 // if (multi>0) connectivityArray[j*(numberOfNodes+multi)+numberOfNodes]=0;
2410 // for (int j=0 ; j<numberOfElements; j++)
2412 // for (int k=0; k<numberOfNodes; k++) connectivityArray[j*(numberOfNodes+multi)+k]=connectivity[j*numberOfNodes+k] ;
2413 // if (multi>0) connectivityArray[j*(numberOfNodes+multi)+numberOfNodes]=0;
2417 //////////////////////////////////////////////////////////////////////////////////////
2419 // err = MEDconnEcr( _medIdt, const_cast <char *> ( _meshName.c_str()), _ptrMesh->_spaceDimension,
2420 // connectivityArray, MED_FR::MED_FULL_INTERLACE , numberOfElements,
2421 // MED_FR::MED_LECTURE_ECRITURE,
2422 // (MED_FR::med_entite_maillage ) entity,
2423 // (MED_FR::med_geometrie_element) types[i], MED_FR::MED_NOD );
2425 // err = MEDconnEcr(_medIdt, const_cast <char *> ( _meshName.c_str()),
2426 // _ptrMesh->_spaceDimension, connectivityArray,
2427 // MED_FR::MED_FULL_INTERLACE , numberOfElements,
2428 // (MED_FR::med_entite_maillage ) entity,
2429 // (MED_FR::med_geometrie_element) types[i],
2430 // med_2_2::MED_NOD);
2432 err = MEDconnEcr(_medIdt, const_cast <char *> ( _meshName.c_str()),
2433 _ptrMesh->_spaceDimension, connectivityArray,
2434 med_2_2::MED_FULL_INTERLACE , numberOfElements,
2435 // (med_2_2::med_entite_maillage ) entity, because Med Memory works only in Nodal connectivity
2436 (med_2_2::med_entite_maillage ) MED_CELL,
2437 (med_2_2::med_geometrie_element) types[i],
2440 delete[] connectivityArray ;
2442 if (err<0) // ETENDRE LES EXPLICATIONS
2443 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write connectivities of mesh |" << _meshName.c_str() << "| in file |" << _fileName
2444 << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
2452 if (_ptrMesh->existPolygonsConnectivity(MED_NODAL,entity))
2454 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
2455 med_2_2::med_int * tmp_PolygonsConnectivityIndex = new med_2_2::med_int[_ptrMesh->getNumberOfPolygons()+1] ;
2456 const int * PolygonsConnectivityIndex = _ptrMesh->getPolygonsConnectivityIndex(MED_NODAL,entity) ;
2458 for ( ii = 0 ; ii < _ptrMesh->getNumberOfPolygons()+1 ; ii++ )
2459 tmp_PolygonsConnectivityIndex[ii] = PolygonsConnectivityIndex[ii] ;
2460 med_2_2::med_int * tmp_PolygonsConnectivity = new med_2_2::med_int[_ptrMesh->getNumberOfPolygons()+1] ;
2461 const int * PolygonsConnectivity = _ptrMesh->getPolygonsConnectivity(MED_NODAL,entity) ;
2462 for ( ii = 0 ; ii < _ptrMesh->getNumberOfPolygons()+1 ; ii++ )
2463 tmp_PolygonsConnectivity[ii] = PolygonsConnectivity[ii] ;
2464 err = MEDpolygoneConnEcr(_medIdt,
2465 const_cast <char *> (_meshName.c_str()),
2466 tmp_PolygonsConnectivityIndex,
2467 _ptrMesh->getNumberOfPolygons(entity)+1,
2468 tmp_PolygonsConnectivity,
2469 // (med_2_2::med_entite_maillage) entity, because Med Memory works only in Nodal connectivity
2470 (med_2_2::med_entite_maillage) MED_CELL,
2472 delete [] tmp_PolygonsConnectivityIndex ;
2473 delete [] tmp_PolygonsConnectivity ;
2475 err = MEDpolygoneConnEcr(_medIdt,
2476 const_cast <char *> (_meshName.c_str()),
2477 const_cast <med_int*> (_ptrMesh->getPolygonsConnectivityIndex(MED_NODAL,entity)),
2478 _ptrMesh->getNumberOfPolygons(entity)+1,
2479 const_cast <med_int*> (_ptrMesh->getPolygonsConnectivity(MED_NODAL,entity)),
2480 // (med_2_2::med_entite_maillage) entity, because Med Memory works only in Nodal connectivity
2481 (med_2_2::med_entite_maillage) MED_CELL,
2486 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write polygons nodal connectivities of mesh |" << _meshName.c_str() << "| in file |" << _fileName
2487 << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
2492 // Polyhedron writing
2493 if (_ptrMesh->existPolyhedronConnectivity(MED_NODAL,entity))
2495 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
2496 med_2_2::med_int * tmp_PolyhedronIndex = new med_2_2::med_int[_ptrMesh->getNumberOfPolyhedron()+1] ;
2497 const int * PolyhedronIndex = _ptrMesh->getPolyhedronIndex(MED_NODAL) ;
2499 for ( ii = 0 ; ii < _ptrMesh->getNumberOfPolyhedron()+1 ; ii++ )
2500 tmp_PolyhedronIndex[ii] = PolyhedronIndex[ii] ;
2501 med_2_2::med_int * tmp_PolyhedronFacesIndex = new med_2_2::med_int[_ptrMesh->getNumberOfPolyhedronFaces()+1] ;
2502 const int * PolyhedronFacesIndex = _ptrMesh->getPolyhedronFacesIndex() ;
2503 for ( ii = 0 ; ii < _ptrMesh->getNumberOfPolyhedronFaces()+1 ; ii++ )
2504 tmp_PolyhedronFacesIndex[ii] = PolyhedronFacesIndex[ii] ;
2505 med_2_2::med_int * tmp_PolyhedronConnectivity = new med_2_2::med_int[_ptrMesh->getNumberOfPolyhedronFaces()+1] ;
2506 const int * PolyhedronConnectivity = _ptrMesh->getPolyhedronConnectivity(MED_NODAL) ;
2507 for ( ii = 0 ; ii < _ptrMesh->getNumberOfPolyhedronFaces()+1 ; ii++ )
2508 tmp_PolyhedronConnectivity[ii] = PolyhedronConnectivity[ii] ;
2509 err = MEDpolyedreConnEcr(_medIdt,
2510 const_cast <char *> (_meshName.c_str()),
2511 tmp_PolyhedronIndex,
2512 _ptrMesh->getNumberOfPolyhedron()+1,
2513 tmp_PolyhedronFacesIndex,
2514 _ptrMesh->getNumberOfPolyhedronFaces()+1,
2515 tmp_PolyhedronConnectivity,
2517 delete [] tmp_PolyhedronIndex ;
2518 delete [] tmp_PolyhedronFacesIndex ;
2519 delete [] tmp_PolyhedronConnectivity ;
2521 err = MEDpolyedreConnEcr(_medIdt,
2522 const_cast <char *> (_meshName.c_str()),
2523 const_cast <med_int*> (_ptrMesh->getPolyhedronIndex(MED_NODAL)),
2524 _ptrMesh->getNumberOfPolyhedron()+1,
2525 const_cast <med_int*> (_ptrMesh->getPolyhedronFacesIndex()),
2526 _ptrMesh->getNumberOfPolyhedronFaces()+1,
2527 const_cast <med_int*> (_ptrMesh->getPolyhedronConnectivity(MED_NODAL)),
2532 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write polyhedron nodal connectivities of mesh |" << _meshName.c_str() << "| in file |" << _fileName
2533 << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
2538 // Descending connectivity for classic geometric types
2539 if ( _ptrMesh->existConnectivity(MED_DESCENDING,entity) )
2542 int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ;
2543 const medGeometryElement * types = _ptrMesh->getTypes (entity) ;
2545 for (int i=0; i<numberOfTypes; i++)
2548 int numberOfElements = _ptrMesh->getNumberOfElements (entity,types[i]);
2549 const int * connectivity = _ptrMesh->getConnectivity(MED_EN::MED_FULL_INTERLACE, MED_DESCENDING, entity, types[i]);
2551 // Pour l'instant la class utilise le multi.....
2552 // err = MED_FR::MEDconnEcr( _medIdt,
2553 // const_cast <char *> ( _meshName.c_str()),
2554 // _ptrMesh->_spaceDimension,
2555 // const_cast <int *> (connectivity),
2556 // MED_FR::MED_FULL_INTERLACE,
2557 // numberOfElements,
2558 // MED_FR::MED_LECTURE_ECRITURE,
2559 // (MED_FR::med_entite_maillage ) entity,
2560 // (MED_FR::med_geometrie_element) types[i],
2561 // MED_FR::MED_DESC );
2563 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
2564 med_2_2::med_int * tmp_Connectivity = new med_2_2::med_int[numberOfElements] ;
2566 for ( ii = 0 ; ii < numberOfElements ; ii++ )
2567 tmp_Connectivity[ii] = connectivity[ii] ;
2568 err = med_2_2::MEDconnEcr(_medIdt,
2569 const_cast <char *> ( _meshName.c_str()),
2570 _ptrMesh->_spaceDimension,
2572 med_2_2::MED_FULL_INTERLACE,
2574 // (med_2_2::med_entite_maillage ) entity, because Med Memory works only in Nodal connectivity
2575 (med_2_2::med_entite_maillage) MED_CELL,
2576 (med_2_2::med_geometrie_element) types[i],
2577 med_2_2::MED_DESC );
2578 delete [] tmp_Connectivity ;
2580 err = med_2_2::MEDconnEcr(_medIdt,
2581 const_cast <char *> ( _meshName.c_str()),
2582 _ptrMesh->_spaceDimension,
2583 const_cast <int *> (connectivity),
2584 med_2_2::MED_FULL_INTERLACE,
2586 // (med_2_2::med_entite_maillage ) entity, because Med Memory works only in Nodal connectivity
2587 (med_2_2::med_entite_maillage ) MED_CELL,
2588 (med_2_2::med_geometrie_element) types[i],
2589 med_2_2::MED_DESC );
2592 if (err<0) // ETENDRE LES EXPLICATIONS
2593 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write connectivities of mesh |" << _meshName.c_str() << "| in file |" << _fileName
2594 << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
2602 if (_ptrMesh->existPolygonsConnectivity(MED_DESCENDING,entity))
2604 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
2605 med_2_2::med_int * tmp_PolygonsConnectivityIndex = new med_2_2::med_int[_ptrMesh->getNumberOfPolygons()+1] ;
2606 const int * PolygonsConnectivityIndex = _ptrMesh->getPolygonsConnectivityIndex(MED_DESCENDING,entity) ;
2608 for ( ii = 0 ; ii < _ptrMesh->getNumberOfPolygons()+1 ; ii++ )
2609 tmp_PolygonsConnectivityIndex[ii] = PolygonsConnectivityIndex[ii] ;
2610 med_2_2::med_int * tmp_PolygonsConnectivity = new med_2_2::med_int[_ptrMesh->getNumberOfPolygons()+1] ;
2611 const int * PolygonsConnectivity = _ptrMesh->getPolygonsConnectivity(MED_DESCENDING,entity) ;
2612 for ( ii = 0 ; ii < _ptrMesh->getNumberOfPolygons()+1 ; ii++ )
2613 tmp_PolygonsConnectivity[ii] = PolygonsConnectivity[ii] ;
2614 err = MEDpolygoneConnEcr(_medIdt,
2615 const_cast <char *> (_meshName.c_str()),
2616 tmp_PolygonsConnectivityIndex,
2617 _ptrMesh->getNumberOfPolygons()+1,
2618 tmp_PolygonsConnectivity,
2619 // (med_2_2::med_entite_maillage) entity, because Med Memory works only in Nodal connectivity
2620 (med_2_2::med_entite_maillage ) MED_CELL,
2622 delete [] tmp_PolygonsConnectivityIndex ;
2623 delete [] tmp_PolygonsConnectivity ;
2625 err = MEDpolygoneConnEcr(_medIdt,
2626 const_cast <char *> (_meshName.c_str()),
2627 const_cast <med_int*> (_ptrMesh->getPolygonsConnectivityIndex(MED_DESCENDING,entity)),
2628 _ptrMesh->getNumberOfPolygons()+1,
2629 const_cast <med_int*> (_ptrMesh->getPolygonsConnectivity(MED_DESCENDING,entity)),
2630 // (med_2_2::med_entite_maillage) entity, because Med Memory works only in Nodal connectivity
2631 (med_2_2::med_entite_maillage ) MED_CELL,
2636 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write polygons descending connectivities of mesh |" << _meshName.c_str() << "| in file |" << _fileName
2637 << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
2642 // Polyhedron writing
2643 if (_ptrMesh->existPolyhedronConnectivity(MED_DESCENDING,entity))
2645 med_int NumberOfFaces = _ptrMesh->getPolyhedronIndex(MED_DESCENDING)[_ptrMesh->getNumberOfPolyhedron()]-1;
2646 vector<med_int> FacesGeometricTypes(NumberOfFaces,MED_POLYGON); // by default all polyhedron faces are polygons
2648 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
2649 med_2_2::med_int * tmp_PolyhedronIndex = new med_2_2::med_int[_ptrMesh->getNumberOfPolyhedron()+1] ;
2650 const int * PolyhedronIndex = _ptrMesh->getPolyhedronIndex(MED_DESCENDING) ;
2652 for ( ii = 0 ; ii < _ptrMesh->getNumberOfPolyhedron()+1 ; ii++ )
2653 tmp_PolyhedronIndex[ii] = PolyhedronIndex[ii] ;
2654 med_2_2::med_int * tmp_PolyhedronConnectivity = new med_2_2::med_int[_ptrMesh->getNumberOfPolyhedronFaces()+1] ;
2655 const int * PolyhedronConnectivity = _ptrMesh->getPolyhedronConnectivity(MED_DESCENDING) ;
2656 for ( ii = 0 ; ii < _ptrMesh->getNumberOfPolyhedronFaces()+1 ; ii++ )
2657 tmp_PolyhedronConnectivity[ii] = PolyhedronConnectivity[ii] ;
2658 err = MEDpolyedreConnEcr(_medIdt,
2659 const_cast <char *> (_meshName.c_str()),
2660 tmp_PolyhedronIndex,
2661 _ptrMesh->getNumberOfPolyhedron()+1,
2662 &FacesGeometricTypes[0],
2664 tmp_PolyhedronConnectivity,
2666 delete [] tmp_PolyhedronIndex ;
2667 delete [] tmp_PolyhedronConnectivity ;
2669 err = MEDpolyedreConnEcr(_medIdt,
2670 const_cast <char *> (_meshName.c_str()),
2671 const_cast <med_int*> (_ptrMesh->getPolyhedronIndex(MED_DESCENDING)),
2672 _ptrMesh->getNumberOfPolyhedron()+1,
2673 &FacesGeometricTypes[0],
2675 const_cast <med_int*> (_ptrMesh->getPolyhedronConnectivity(MED_DESCENDING)),
2680 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write polyhedron descending connectivities of mesh |" << _meshName.c_str() << "| in file |" << _fileName
2681 << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
2690 int MED_MESH_WRONLY_DRIVER22::writeFamilyNumbers() const {
2692 const char * LOC="int MED_MESH_WRONLY_DRIVER22::writeFamilyNumbers() const : ";
2695 med_2_2::med_err err;
2697 // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArrayNodeFamily DOIT ETRE ENLEVER DE LA CLASSE MESH
2699 { // Node related block
2701 // We build the array from the families list objects :
2702 int NumberOfNodes = _ptrMesh->getNumberOfNodes() ;
2703 //CCRT int * MEDArrayNodeFamily = new int[NumberOfNodes] ;
2704 med_2_2::med_int * MEDArrayNodeFamily = new med_2_2::med_int[NumberOfNodes] ;
2705 // family 0 by default
2706 for (int i=0; i<NumberOfNodes; i++)
2707 MEDArrayNodeFamily[i]=0;
2708 //vector<FAMILY*> myFamilies = _ptrMesh->getFamilies(MED_NODE);
2709 vector<FAMILY*> * myFamilies = &_ptrMesh->_familyNode;
2710 int NumberOfNodesFamilies = myFamilies->size() ;
2711 //bool ToDestroy = false;
2712 if (0 == NumberOfNodesFamilies) {
2713 //ToDestroy = true ;
2714 vector<GROUP*> myGroups = _ptrMesh->getGroups(MED_NODE);
2715 int NumberOfGroups = myGroups.size() ;
2716 // build families from groups
2717 for (int i=0; i<NumberOfGroups; i++) {
2718 SUPPORT * mySupport = myGroups[i] ;
2719 FAMILY* myFamily = new FAMILY(*mySupport);
2720 myFamily->setIdentifier(i+1);
2721 myFamilies->push_back(myFamily);
2723 NumberOfNodesFamilies=myFamilies->size() ;
2725 for (int i=0 ; i<NumberOfNodesFamilies; i++) {
2727 //SCRUTE(myFamilies[i]->getName());
2728 int FamilyIdentifier = (*myFamilies)[i]->getIdentifier() ;
2729 int TotalNumber = (*myFamilies)[i]->getNumberOfElements(MED_ALL_ELEMENTS) ;
2730 if ((*myFamilies)[i]->isOnAllElements())
2731 for (int j=0; j<TotalNumber; j++)
2732 MEDArrayNodeFamily[j]=FamilyIdentifier;
2734 const int * Number = (*myFamilies)[i]->getNumber(MED_ALL_ELEMENTS) ;
2735 for (int j=0; j<TotalNumber; j++)
2736 MEDArrayNodeFamily[Number[j]-1]=FamilyIdentifier ;
2740 for(int j=0; j<NumberOfNodes; j++) {
2741 SCRUTE(MEDArrayNodeFamily[j]);
2744 // if ( !_ptrMesh->getIsAGrid() )
2746 err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
2747 MEDArrayNodeFamily, NumberOfNodes, med_2_2::MED_NOEUD,
2748 (med_2_2::med_geometrie_element) MED_NONE);
2751 // err = MEDfamGridEcr(_medIdt,
2752 // const_cast <char *> (_ptrMesh->_name.c_str()),
2753 // MEDArrayNodeFamily,
2755 // MED_FR::MED_LECTURE_ECRITURE,
2756 // MED_FR::MED_NOEUD);
2758 if ( err != MED_VALID)
2759 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write node family for the |"<< NumberOfNodes
2760 << "| nodes in mesh |"
2761 << _ptrMesh->_name.c_str() << "|" ));
2762 delete[] MEDArrayNodeFamily;
2763 //if (true == ToDestroy)
2764 // for (int i=0; i<NumberOfNodesFamilies; i++)
2765 // delete myFamilies[i];
2768 { // CELLS RELATED BLOCK
2769 medEntityMesh entity=MED_EN::MED_CELL;
2770 // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArray____Family DOIT ETRE ENLEVER DE LA CLASSE MESH
2771 if ( ( _ptrMesh->existConnectivity(MED_NODAL,entity) )|( _ptrMesh->existConnectivity(MED_DESCENDING,entity) ) ) {
2773 int numberOfTypes = _ptrMesh->getNumberOfTypesWithPoly(entity) ;
2774 medGeometryElement * types = _ptrMesh->getTypesWithPoly(entity) ;
2776 // We build the array from the families list objects :
2777 int NumberOfElements = _ptrMesh->getNumberOfElements(entity, MED_ALL_ELEMENTS);
2778 int * MEDArrayFamily = new int[NumberOfElements] ;
2779 // family 0 by default
2780 for (int i=0; i<NumberOfElements; i++)
2781 MEDArrayFamily[i]=0;
2782 //vector<FAMILY*> myFamilies = _ptrMesh->getFamilies(entity);
2783 vector<FAMILY*> * myFamilies = &_ptrMesh->_familyCell ;
2784 int NumberOfFamilies = myFamilies->size() ;
2785 //bool ToDestroy = false;
2786 if (0 == NumberOfFamilies) {
2787 //ToDestroy = true ;
2788 vector<GROUP*> myGroups = _ptrMesh->getGroups(entity);
2789 int NumberOfGroups = myGroups.size() ;
2790 // build families from groups
2791 for (int i=0; i<NumberOfGroups; i++) {
2792 SCRUTE( myGroups[i]->getName() );
2793 SUPPORT * mySupport = myGroups[i] ;
2794 FAMILY* myFamily = new FAMILY(*mySupport);
2795 myFamily->setIdentifier(-i-1);
2796 myFamilies->push_back(myFamily);
2798 NumberOfFamilies=myFamilies->size() ;
2800 for (int i=0 ; i<NumberOfFamilies; i++) {
2801 int FamilyIdentifier = (*myFamilies)[i]->getIdentifier() ;
2802 int TotalNumber = (*myFamilies)[i]->getNumberOfElements(MED_ALL_ELEMENTS) ;
2803 if ((*myFamilies)[i]->isOnAllElements())
2804 for (int ii=0; ii<TotalNumber; ii++)
2805 MEDArrayFamily[ii]=FamilyIdentifier;
2807 const int * Number = (*myFamilies)[i]->getNumber(MED_ALL_ELEMENTS) ;
2808 for (int ii=0; ii<TotalNumber; ii++)
2809 MEDArrayFamily[Number[ii]-1]=FamilyIdentifier ;
2815 for (int i=0; i<NumberOfElements; i++)
2816 SCRUTE(MEDArrayFamily[i]);
2820 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
2821 int lgth=NumberOfElements;
2822 med_2_2::med_int *temp=new med_2_2::med_int[lgth];
2823 for(int i2=0;i2<lgth;i2++)
2824 temp[i2]=(med_2_2::med_int) (MEDArrayFamily[i2]);
2826 for (int i=0; i<numberOfTypes; i++) {
2827 int typeNumberOfElements=_ptrMesh->getNumberOfElementsWithPoly(entity,types[i]);
2828 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
2829 err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
2830 (temp+offset),(typeCount[i+1]-typeCount[i]),
2831 //CCRT med_2_2::MED_REMP ,
2832 // (med_2_2::med_entite_maillage) entity, because Med Memory works only in Nodal connectivity
2833 (med_2_2::med_entite_maillage) MED_CELL,
2834 (med_2_2::med_geometrie_element) types[i]);
2836 err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
2837 (MEDArrayFamily+offset),
2838 typeNumberOfElements,
2839 // (med_2_2::med_entite_maillage) entity, because Med Memory works only in Nodal connectivity
2840 (med_2_2::med_entite_maillage) MED_CELL,
2841 (med_2_2::med_geometrie_element) types[i]);
2844 if ( err != MED_VALID)
2845 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write family for the |"<< _ptrMesh->getNumberOfElements(entity, types[i])
2846 << "| cells of geometric type |" << geoNames[types[i]] <<"|in mesh |"
2847 << _ptrMesh->_name.c_str() << "|" ));
2850 //CCRT#if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
2851 //CCRT delete [] temp;
2853 delete[] MEDArrayFamily ;
2855 //if (true == ToDestroy) {
2856 // int NumberOfFamilies = myFamilies->size();
2857 // for (int i=0; i<NumberOfFamilies; i++)
2858 // delete myFamilies[i];
2863 { // FACE RELATED BLOCK
2864 medEntityMesh entity=MED_EN::MED_FACE;
2865 // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArray____Family DOIT ETRE ENLEVER DE LA CLASSE MESH
2866 if ( ( _ptrMesh->existConnectivity(MED_NODAL,entity) )|( _ptrMesh->existConnectivity(MED_DESCENDING,entity) ) ) {
2868 int numberOfTypes = _ptrMesh->getNumberOfTypesWithPoly(entity) ;
2869 medGeometryElement * types = _ptrMesh->getTypesWithPoly(entity) ;
2870 SCRUTE(numberOfTypes);
2872 int numberOfElements = _ptrMesh->getNumberOfElementsWithPoly(entity, MED_ALL_ELEMENTS) ;
2873 int * familyArray = new int[numberOfElements] ;
2874 for (int i=0;i<numberOfElements;i++)
2877 int numberOfFamilies = _ptrMesh->getNumberOfFamilies(entity) ;
2878 //vector<FAMILY*> myFamilies = _ptrMesh->getFamilies(entity) ;
2879 vector<FAMILY*> * myFamilies = &_ptrMesh->_familyFace ;
2880 //bool ToDestroy = false;
2881 if (0 == numberOfFamilies) {
2882 //ToDestroy = true ;
2883 vector<GROUP*> myGroups = _ptrMesh->getGroups(entity);
2884 int NumberOfGroups = myGroups.size() ;
2885 // build families from groups
2886 for (int i=0; i<NumberOfGroups; i++) {
2887 SCRUTE( myGroups[i]->getName() );
2888 SUPPORT * mySupport = myGroups[i] ;
2889 FAMILY* myFamily = new FAMILY(*mySupport);
2890 myFamily->setIdentifier(-i-1000);
2891 myFamilies->push_back(myFamily);
2893 numberOfFamilies=myFamilies->size() ;
2895 for (int i=0;i<numberOfFamilies;i++) {
2896 int familyNumber = (*myFamilies)[i]->getIdentifier() ;
2897 int numberOfFamilyElements = (*myFamilies)[i]->getNumberOfElements(MED_ALL_ELEMENTS) ;
2898 if ((*myFamilies)[i]->isOnAllElements())
2899 for (int ii=0; ii<numberOfFamilyElements; ii++)
2900 familyArray[ii]=familyNumber;
2902 const int * myFamilyElements = (*myFamilies)[i]->getNumber(MED_ALL_ELEMENTS) ;
2903 for (int ii=0;ii<numberOfFamilyElements;ii++)
2904 familyArray[myFamilyElements[ii]-1]=familyNumber;
2908 for (int i=0;i<numberOfElements;i++)
2909 SCRUTE(familyArray[i]);
2912 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
2913 int lgth=numberOfElements;
2914 med_2_2::med_int *temp=new med_2_2::med_int[lgth];
2915 for(int i2=0;i2<lgth;i2++)
2916 temp[i2]=(med_2_2::med_int) (familyArray[i2]);
2918 SCRUTE(numberOfTypes);
2920 for (int i=0; i<numberOfTypes; i++) {
2921 int typeNumberOfElements = _ptrMesh->getNumberOfElementsWithPoly(entity,types[i]) ;
2922 SCRUTE(typeNumberOfElements);
2924 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
2925 err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
2926 (temp+offset), typeNumberOfElements,
2927 // (med_2_2::med_entite_maillage) entity, because Med Memory works only in Nodal connectivity
2928 (med_2_2::med_entite_maillage) MED_CELL,
2929 (med_2_2::med_geometrie_element) types[i]);
2931 MESSAGE("On est bien la !!! entity = " << entity << " type " << types[i]);
2933 err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
2934 (familyArray+offset), typeNumberOfElements,
2935 // (med_2_2::med_entite_maillage) entity, because Med Memory works only in Nodal connectivity
2936 (med_2_2::med_entite_maillage) MED_CELL,
2937 (med_2_2::med_geometrie_element) types[i]);
2939 if ( err != MED_VALID)
2940 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write family for the |"<< _ptrMesh->getNumberOfElementsWithPoly(entity, types[i])
2941 << "| faces of geometric type |" << geoNames[types[i]] <<"|in mesh |"
2942 << _ptrMesh->_name.c_str() << "|" ));
2943 offset+=typeNumberOfElements;
2945 //CCRT there was "temp" and "familyArray" for OSF, but only "familyArray" for Linux ...
2946 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
2950 delete[] familyArray ;
2952 //if (true == ToDestroy) {
2953 // int NumberOfFamilies = myFamilies->size();
2954 // for (int i=0; i<NumberOfFamilies; i++)
2955 // delete myFamilies[i];
2960 { // EDGE RELATED BLOCK
2961 //medEntityMesh entity=MED_EN::MED_FACE;
2962 medEntityMesh entity=MED_EN::MED_EDGE;
2963 // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArray____Family DOIT ETRE ENLEVER DE LA CLASSE MESH
2964 if ( ( _ptrMesh->existConnectivity(MED_NODAL,entity) )|( _ptrMesh->existConnectivity(MED_DESCENDING,entity) ) ) {
2966 int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ;
2967 const medGeometryElement * types = _ptrMesh->getTypes (entity) ;
2969 int numberOfElements = _ptrMesh->getNumberOfElements(entity, MED_ALL_ELEMENTS) ;
2970 int * familyArray = new int[numberOfElements] ;
2971 // med_2_2::med_int * familyArray = new int[numberOfElements] ;
2972 for (int i=0;i<numberOfElements;i++)
2975 int numberOfFamilies = _ptrMesh->getNumberOfFamilies(entity) ;
2976 //vector<FAMILY*> myFamilies = _ptrMesh->getFamilies(entity) ;
2977 vector<FAMILY*> * myFamilies = &_ptrMesh->_familyEdge ;
2978 //bool ToDestroy = false;
2979 if (0 == numberOfFamilies) {
2980 //ToDestroy = true ;
2981 vector<GROUP*> myGroups = _ptrMesh->getGroups(entity);
2982 int NumberOfGroups = myGroups.size() ;
2983 // build families from groups
2984 for (int i=0; i<NumberOfGroups; i++) {
2985 SCRUTE( myGroups[i]->getName() );
2986 SUPPORT * mySupport = myGroups[i] ;
2987 FAMILY* myFamily = new FAMILY(*mySupport);
2988 myFamily->setIdentifier(-i-2000);
2989 myFamilies->push_back(myFamily);
2991 numberOfFamilies=myFamilies->size() ;
2993 for (int i=0;i<numberOfFamilies;i++) {
2994 int familyNumber = (*myFamilies)[i]->getIdentifier() ;
2995 int numberOfFamilyElements = (*myFamilies)[i]->getNumberOfElements(MED_ALL_ELEMENTS) ;
2996 if ((*myFamilies)[i]->isOnAllElements())
2997 for (int ii=0; ii<numberOfFamilyElements; ii++)
2998 familyArray[ii]=familyNumber;
3000 const int * myFamilyElements = (*myFamilies)[i]->getNumber(MED_ALL_ELEMENTS) ;
3001 for (int ii=0;ii<numberOfFamilyElements;ii++)
3002 familyArray[myFamilyElements[ii]-1]=familyNumber;
3007 for (int i=0;i<numberOfElements;i++)
3008 SCRUTE(familyArray[i]);
3011 const int * typeCount = _ptrMesh->getGlobalNumberingIndex(entity) ;
3013 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
3014 int lgth=numberOfElements;
3015 med_2_2::med_int *temp=new med_2_2::med_int[lgth];
3016 for(int i2=0;i2<lgth;i2++)
3017 temp[i2]=(med_2_2::med_int) (familyArray[i2]);
3019 SCRUTE(numberOfTypes);
3021 for (int i=0; i<numberOfTypes; i++) {
3022 int typeNumberOfElements = typeCount[i+1] - typeCount[i] ;
3023 SCRUTE(typeNumberOfElements);
3024 SCRUTE(typeCount[i+1]);
3025 SCRUTE(typeCount[i]);
3026 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
3027 err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
3028 (temp+(typeCount[i]-1)), typeNumberOfElements,
3029 // (med_2_2::med_entite_maillage) entity, because Med Memory works only in Nodal connectivity
3030 (med_2_2::med_entite_maillage) MED_CELL,
3031 (med_2_2::med_geometrie_element) types[i]);
3033 err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
3034 (familyArray+(typeCount[i]-1)), typeNumberOfElements,
3035 // (med_2_2::med_entite_maillage) entity, because Med Memory works only in Nodal connectivity
3036 (med_2_2::med_entite_maillage) MED_CELL,
3037 (med_2_2::med_geometrie_element) types[i]);
3039 if ( err != MED_VALID)
3040 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write family for the |"<< _ptrMesh->getNumberOfElements(entity, types[i])
3041 << "| edges of geometric type |" << geoNames[types[i]] <<"|in mesh |"
3042 << _ptrMesh->_name.c_str() << "|" ));
3045 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
3048 delete[] familyArray ;
3049 //if (true == ToDestroy) {
3050 // int NumberOfFamilies = myFamilies->size();
3051 // for (int i=0; i<NumberOfFamilies; i++)
3052 // delete myFamilies[i];
3061 int MED_MESH_WRONLY_DRIVER22::writeFamilies(vector<FAMILY*> & families ) const
3064 const char * LOC="int MED_MESH_WRONLY_DRIVER22::writeFamilies(vector<FAMILY*> families) const : ";
3067 med_2_2::med_err err;
3069 MESSAGE(LOC<<" families.size() :"<<families.size());
3071 for (unsigned int i=0; i< families.size(); i++) {
3073 int numberOfAttributes = families[i]->getNumberOfAttributes ();
3074 string attributesDescriptions = "";
3076 // Recompose the attributes descriptions arg for MED
3077 for (int j=0; j < numberOfAttributes; j++) {
3079 string attributeDescription = families[i]->getAttributeDescription(j+1);
3081 if ( attributeDescription.size() > MED_TAILLE_DESC )
3082 throw MEDEXCEPTION( LOCALIZED(STRING(LOC) << "The size of the attribute description n° |" << j+1 << "| of the family |" << families[i]->getName()
3083 << "| with identifier |" << families[i]->getIdentifier() << "| is |"
3084 << attributeDescription.size() <<"| and is more than |" << MED_TAILLE_DESC << "|")) ;
3086 attributesDescriptions += attributeDescription;
3090 int numberOfGroups = families[i]->getNumberOfGroups();
3091 string groupsNames(numberOfGroups*MED_TAILLE_LNOM,'\0') ;
3092 // Recompose the groups names arg for MED
3093 for (int j=0; j < numberOfGroups; j++) {
3095 string groupName = families[i]->getGroupName(j+1);
3097 if ( groupName.size() > MED_TAILLE_LNOM )
3098 throw MEDEXCEPTION( LOCALIZED(STRING(LOC) << "The size of the group name n° |" << j+1 << "| of the family |" << families[i]->getName()
3099 << "| with identifier |" << families[i]->getIdentifier() << "| is |"
3100 << groupName.size() <<"| and is more than |" << MED_TAILLE_LNOM << "|")) ;
3103 int length = min(MED_TAILLE_LNOM,(int)groupName.size());
3104 groupsNames.replace(j*MED_TAILLE_LNOM,length, groupName,0,length);
3108 // test if the family already exists (HDF trick waiting a MED evolution to be replaced)
3110 string dataGroupFam;
3111 if (families[i]->getEntity() == MED_NODE)
3112 dataGroupFam = "/ENS_MAA/"+_meshName+"/FAS/NOEUD/"+families[i]->getName()+"/";
3114 dataGroupFam = "/ENS_MAA/"+_meshName+"/FAS/ELEME/"+families[i]->getName()+"/";
3116 SCRUTE("|"<<dataGroupFam<<"|");
3117 err = med_2_2::_MEDdatagroupOuvrir(_medIdt,const_cast <char *> (dataGroupFam.c_str()) ) ;
3118 if ( err < MED_VALID ) {
3120 if ( families[i]->getName().size() > MED_TAILLE_NOM )
3122 ( LOCALIZED(STRING(LOC) << "The size of the name of the family |" << i+1
3123 << "| |" << families[i]->getName()
3124 << "| with identifier |" << families[i]->getIdentifier() << "| is |"
3125 << families[i]->getName().size() <<"| and is more than |"
3126 << MED_TAILLE_NOM << "|")) ;
3128 MESSAGE(LOC<<"families[i]->getName().c_str() : "<<families[i]->getName().c_str());
3129 MESSAGE(LOC<<"_meshName.c_str() : "<<_meshName.c_str());
3130 MESSAGE(LOC<<"families[i]->getIdentifier() : "<<families[i]->getIdentifier());
3131 MESSAGE(LOC<<"numberOfAttributes : "<<numberOfAttributes);
3133 //MESSAGE(LOC<<"families[i]->getAttributesIdentifiers() : "<<families[i]->getAttributesIdentifiers()[0]);
3134 //MESSAGE(LOC<<"families[i]->getAttributesValues() : "<<families[i]->getAttributesValues()[0]);
3135 MESSAGE(LOC<<"attributesDescriptions.c_str() : "<<attributesDescriptions.c_str());
3136 MESSAGE(LOC<<"numberOfGroups : "<<numberOfGroups);
3137 MESSAGE(LOC<<"groupsNames.c_str() : "<<groupsNames.c_str());
3138 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
3139 int lgth=families[i]->getNumberOfAttributes();
3140 med_2_2::med_int * AttributesIdentifier2 = new med_2_2::med_int[lgth] ;
3141 med_2_2::med_int * AttributesValues2 = new med_2_2::med_int[lgth] ;
3142 for(med_2_2::med_int i2=0;i2<lgth;i2++)
3144 AttributesIdentifier2[i2]=(med_2_2::med_int)(families[i]->getAttributesIdentifiers()[i2]);
3145 AttributesValues2[i2]=(med_2_2::med_int)(families[i]->getAttributesValues()[i2]);
3147 err = med_2_2::MEDfamCr( _medIdt,
3148 const_cast <char *> ( _meshName.c_str() ),
3149 const_cast <char *> ( families[i]->getName().c_str() ),
3150 families[i]->getIdentifier(),
3151 AttributesIdentifier2,
3153 const_cast <char *> (attributesDescriptions.c_str()),
3155 const_cast <char *> (groupsNames.c_str()),
3157 delete [] AttributesIdentifier2;
3158 delete [] AttributesValues2;
3160 err = med_2_2::MEDfamCr( _medIdt,
3161 const_cast <char *> ( _meshName.c_str() ),
3162 const_cast <char *> ( families[i]->getName().c_str() ),
3163 families[i]->getIdentifier(),
3164 (med_2_2::med_int*)families[i]->getAttributesIdentifiers(),
3165 (med_2_2::med_int*)families[i]->getAttributesValues(),
3166 const_cast <char *> (attributesDescriptions.c_str()),
3168 const_cast <char *> (groupsNames.c_str()),
3172 if ( err != MED_VALID)
3173 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't create family |" << families[i]->getName()
3174 << "| with identifier |" << families[i]->getIdentifier() << "| groups names |"
3175 << groupsNames <<"| and attributes descriptions |" << attributesDescriptions << "|")) ;
3178 med_2_2::_MEDdatagroupFermer(_medIdt);
3189 // A FAIRE POUR LES NOEUDS ET LES ELEMENTS ret = MEDfamEcr(
3193 /*--------------------- RDWR PART -------------------------------*/
3195 MED_MESH_RDWR_DRIVER22::MED_MESH_RDWR_DRIVER22()
3199 MED_MESH_RDWR_DRIVER22::MED_MESH_RDWR_DRIVER22(const string & fileName,
3201 MED_MESH_DRIVER(fileName,ptrMesh,MED_RDWR),
3202 IMED_MESH_RDONLY_DRIVER(fileName,ptrMesh),
3203 IMED_MESH_WRONLY_DRIVER(fileName,ptrMesh),
3204 IMED_MESH_RDWR_DRIVER(fileName,ptrMesh),
3205 MED_MESH_DRIVER22(fileName,ptrMesh,MED_RDWR),
3206 MED_MESH_RDONLY_DRIVER22(fileName,ptrMesh),
3207 MED_MESH_WRONLY_DRIVER22(fileName,ptrMesh)
3209 MESSAGE("MED_MESH_RDWR_DRIVER22::MED_MESH_RDWR_DRIVER22(const string & fileName, MESH * ptrMesh) has been created");
3212 MED_MESH_RDWR_DRIVER22::MED_MESH_RDWR_DRIVER22(const MED_MESH_RDWR_DRIVER22 & driver):
3213 MED_MESH_DRIVER(driver),
3214 IMED_MESH_RDONLY_DRIVER(driver),
3215 IMED_MESH_WRONLY_DRIVER(driver),
3216 IMED_MESH_RDWR_DRIVER(driver),
3217 MED_MESH_DRIVER22(driver),
3218 MED_MESH_RDONLY_DRIVER22(driver),
3219 MED_MESH_WRONLY_DRIVER22(driver)
3223 MED_MESH_RDWR_DRIVER22::~MED_MESH_RDWR_DRIVER22() {
3224 //MESSAGE("MED_MESH_RDWR_DRIVER22::MED_MESH_RDWR_DRIVER22(const string & fileName, MESH * ptrMesh) has been destroyed");
3227 GENDRIVER * MED_MESH_RDWR_DRIVER22::copy(void) const
3229 return new MED_MESH_RDWR_DRIVER22(*this);
3232 void MED_MESH_RDWR_DRIVER22::write(void) const
3234 MED_MESH_WRONLY_DRIVER22::write();
3236 void MED_MESH_RDWR_DRIVER22::read (void)
3238 MED_MESH_RDONLY_DRIVER22::read();