X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDLoader%2FMEDLoader.cxx;h=9c7189655f8e0f9fc5d6868455dd601c1ceceea0;hb=3f78fd9a0ef0296eee2e9df7ca43cf77dbd1dd45;hp=227396cfe47293d624b2773914e45f30a6559fbf;hpb=4e9a620291e47249b080e10dfe603d29e9ed7ef3;p=modules%2Fmed.git diff --git a/src/MEDLoader/MEDLoader.cxx b/src/MEDLoader/MEDLoader.cxx index 227396cfe..9c7189655 100644 --- a/src/MEDLoader/MEDLoader.cxx +++ b/src/MEDLoader/MEDLoader.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2014 CEA/DEN, EDF R&D +// Copyright (C) 2007-2015 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -21,6 +21,7 @@ #include "MEDLoader.hxx" #include "MEDLoaderBase.hxx" #include "MEDFileUtilities.hxx" +#include "MEDFileSafeCaller.txx" #include "MEDFileMesh.hxx" #include "MEDFileField.hxx" #include "CellModel.hxx" @@ -44,89 +45,89 @@ #include med_geometry_type typmai[MED_N_CELL_FIXED_GEO] = { MED_POINT1, - MED_SEG2, - MED_SEG3, - MED_SEG4, - MED_TRIA3, - MED_QUAD4, - MED_TRIA6, - MED_TRIA7, - MED_QUAD8, - MED_QUAD9, - MED_TETRA4, - MED_PYRA5, - MED_PENTA6, - MED_HEXA8, - MED_OCTA12, - MED_TETRA10, - MED_PYRA13, - MED_PENTA15, - MED_HEXA20, - MED_HEXA27, - MED_POLYGON, - MED_POLYGON2, - MED_POLYHEDRON }; + MED_SEG2, + MED_SEG3, + MED_SEG4, + MED_TRIA3, + MED_QUAD4, + MED_TRIA6, + MED_TRIA7, + MED_QUAD8, + MED_QUAD9, + MED_TETRA4, + MED_PYRA5, + MED_PENTA6, + MED_HEXA8, + MED_OCTA12, + MED_TETRA10, + MED_PYRA13, + MED_PENTA15, + MED_HEXA20, + MED_HEXA27, + MED_POLYGON, + MED_POLYGON2, + MED_POLYHEDRON }; med_geometry_type typmainoeud[1] = { MED_NONE }; INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO] = { INTERP_KERNEL::NORM_POINT1, - INTERP_KERNEL::NORM_SEG2, - INTERP_KERNEL::NORM_SEG3, - INTERP_KERNEL::NORM_SEG4, - INTERP_KERNEL::NORM_TRI3, - INTERP_KERNEL::NORM_QUAD4, - INTERP_KERNEL::NORM_TRI6, - INTERP_KERNEL::NORM_TRI7, - INTERP_KERNEL::NORM_QUAD8, - INTERP_KERNEL::NORM_QUAD9, - INTERP_KERNEL::NORM_TETRA4, - INTERP_KERNEL::NORM_PYRA5, - INTERP_KERNEL::NORM_PENTA6, - INTERP_KERNEL::NORM_HEXA8, - INTERP_KERNEL::NORM_HEXGP12, - INTERP_KERNEL::NORM_TETRA10, - INTERP_KERNEL::NORM_PYRA13, - INTERP_KERNEL::NORM_PENTA15, - INTERP_KERNEL::NORM_HEXA20, - INTERP_KERNEL::NORM_HEXA27, - INTERP_KERNEL::NORM_POLYGON, - INTERP_KERNEL::NORM_QPOLYG, - INTERP_KERNEL::NORM_POLYHED }; + INTERP_KERNEL::NORM_SEG2, + INTERP_KERNEL::NORM_SEG3, + INTERP_KERNEL::NORM_SEG4, + INTERP_KERNEL::NORM_TRI3, + INTERP_KERNEL::NORM_QUAD4, + INTERP_KERNEL::NORM_TRI6, + INTERP_KERNEL::NORM_TRI7, + INTERP_KERNEL::NORM_QUAD8, + INTERP_KERNEL::NORM_QUAD9, + INTERP_KERNEL::NORM_TETRA4, + INTERP_KERNEL::NORM_PYRA5, + INTERP_KERNEL::NORM_PENTA6, + INTERP_KERNEL::NORM_HEXA8, + INTERP_KERNEL::NORM_HEXGP12, + INTERP_KERNEL::NORM_TETRA10, + INTERP_KERNEL::NORM_PYRA13, + INTERP_KERNEL::NORM_PENTA15, + INTERP_KERNEL::NORM_HEXA20, + INTERP_KERNEL::NORM_HEXA27, + INTERP_KERNEL::NORM_POLYGON, + INTERP_KERNEL::NORM_QPOLYG, + INTERP_KERNEL::NORM_POLYHED }; med_geometry_type typmai3[34] = { MED_POINT1,//0 - MED_SEG2,//1 - MED_SEG3,//2 - MED_TRIA3,//3 - MED_QUAD4,//4 - MED_POLYGON,//5 - MED_TRIA6,//6 - MED_TRIA7,//7 - MED_QUAD8,//8 - MED_QUAD9,//9 - MED_SEG4,//10 - MED_NONE,//11 - MED_NONE,//12 - MED_NONE,//13 - MED_TETRA4,//14 - MED_PYRA5,//15 - MED_PENTA6,//16 - MED_NONE,//17 - MED_HEXA8,//18 - MED_NONE,//19 - MED_TETRA10,//20 - MED_NONE,//21 - MED_OCTA12,//22 - MED_PYRA13,//23 - MED_NONE,//24 - MED_PENTA15,//25 - MED_NONE,//26 - MED_HEXA27,//27 - MED_NONE,//28 - MED_NONE,//29 - MED_HEXA20,//30 - MED_POLYHEDRON,//31 - MED_POLYGON2,//32 - MED_NONE//33 + MED_SEG2,//1 + MED_SEG3,//2 + MED_TRIA3,//3 + MED_QUAD4,//4 + MED_POLYGON,//5 + MED_TRIA6,//6 + MED_TRIA7,//7 + MED_QUAD8,//8 + MED_QUAD9,//9 + MED_SEG4,//10 + MED_NONE,//11 + MED_NONE,//12 + MED_NONE,//13 + MED_TETRA4,//14 + MED_PYRA5,//15 + MED_PENTA6,//16 + MED_NONE,//17 + MED_HEXA8,//18 + MED_NONE,//19 + MED_TETRA10,//20 + MED_NONE,//21 + MED_OCTA12,//22 + MED_PYRA13,//23 + MED_NONE,//24 + MED_PENTA15,//25 + MED_NONE,//26 + MED_HEXA27,//27 + MED_NONE,//28 + MED_NONE,//29 + MED_HEXA20,//30 + MED_POLYHEDRON,//31 + MED_POLYGON2,//32 + MED_NONE//33 }; double MEDLoader::_EPS_FOR_NODE_COMP=1.e-12; @@ -144,7 +145,7 @@ namespace MEDLoaderNS int readUMeshDimFromFile(const std::string& fileName, const std::string& meshName, std::vector& possibilities); void dispatchElems(int nbOfElemCell, int nbOfElemFace, int& nbOfElem, med_entity_type& whichEntity); void writeFieldWithoutReadingAndMappingOfMeshInFile(const std::string& fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, bool writeFromScratch); - med_int getIdFromMeshName(med_idt fid, const std::string& meshName, std::string& trueMeshName) throw(INTERP_KERNEL::Exception); + med_int getIdFromMeshName(med_idt fid, const std::string& meshName, std::string& trueMeshName); std::vector getMeshNamesFid(med_idt fid); } @@ -174,10 +175,10 @@ int MEDLoaderNS::readUMeshDimFromFile(const std::string& fileName, const std::st med_sorting_type sortingType; med_int nstep; med_axis_type axisType; - int naxis=MEDmeshnAxis(fid,meshId); + int naxis(MEDmeshnAxis(fid,meshId)); INTERP_KERNEL::AutoPtr axisname=MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE); INTERP_KERNEL::AutoPtr axisunit=MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE); - MEDmeshInfo(fid,meshId,nommaa,&Sdim,&Mdim,&type_maillage,maillage_description,dt_unit,&sortingType,&nstep,&axisType,axisname,axisunit); + MEDFILESAFECALLERRD0(MEDmeshInfo,(fid,meshId,nommaa,&Sdim,&Mdim,&type_maillage,maillage_description,dt_unit,&sortingType,&nstep,&axisType,axisname,axisunit)); // limitation if(nstep!=1) { @@ -185,14 +186,14 @@ int MEDLoaderNS::readUMeshDimFromFile(const std::string& fileName, const std::st } med_int numdt,numit; med_float dt; - MEDmeshComputationStepInfo(fid,nommaa,1,&numdt,&numit,&dt); + MEDFILESAFECALLERRD0(MEDmeshComputationStepInfo,(fid,nommaa,1,&numdt,&numit,&dt)); // endlimitation for(int i=0;i meshes=getMeshNamesFid(fid); @@ -238,7 +239,7 @@ med_int MEDLoaderNS::getIdFromMeshName(med_idt fid, const std::string& meshName, } trueMeshName=meshName; return iter-meshes.begin()+1; -} + } std::vector MEDLoaderNS::getMeshNamesFid(med_idt fid) { @@ -254,11 +255,11 @@ std::vector MEDLoaderNS::getMeshNamesFid(med_idt fid) std::vector ret(n); for(int i=0;i axisname=MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE); INTERP_KERNEL::AutoPtr axisunit=MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE); int nstep; - MEDmeshInfo(fid,i+1,nommaa,&space_dim,&mesh_dim,&type_maillage,maillage_description,dtunit,&stype,&nstep,&axistype,axisname,axisunit); + MEDFILESAFECALLERRD0(MEDmeshInfo,(fid,i+1,nommaa,&space_dim,&mesh_dim,&type_maillage,maillage_description,dtunit,&stype,&nstep,&axistype,axisname,axisunit)); std::string cur=MEDLoaderBase::buildStringFromFortran(nommaa,sizeof(nommaa)); ret[i]=cur; } @@ -357,10 +358,10 @@ std::vector< std::vector< std::pair > > M med_sorting_type sortingType; med_int nstep; med_axis_type axisType; - int naxis=MEDmeshnAxis(fid,meshId); + int naxis(MEDmeshnAxis(fid,meshId)); INTERP_KERNEL::AutoPtr axisname=MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE); INTERP_KERNEL::AutoPtr axisunit=MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE); - MEDmeshInfo(fid,meshId,nommaa,&spaceDim,&meshDim,&type_maillage,maillage_description,dt_unit,&sortingType,&nstep,&axisType,axisname,axisunit); + MEDFILESAFECALLERRD0(MEDmeshInfo,(fid,meshId,nommaa,&spaceDim,&meshDim,&type_maillage,maillage_description,dt_unit,&sortingType,&nstep,&axisType,axisname,axisunit)); if(type_maillage!=MED_UNSTRUCTURED_MESH) { std::ostringstream oss; oss << "MEDLoader::GetUMeshGlobalInfo : Mesh \""<< meshName << "\" in file \"" << fileName; @@ -372,7 +373,7 @@ std::vector< std::vector< std::pair > > M throw INTERP_KERNEL::Exception("MEDLoader::GetUMeshGlobalInfo : multisteps on mesh not managed !"); med_int numdt,numit; med_float dt; - MEDmeshComputationStepInfo(fid,nommaa,1,&numdt,&numit,&dt); + MEDFILESAFECALLERRD0(MEDmeshComputationStepInfo,(fid,nommaa,1,&numdt,&numit,&dt)); // endlimitation std::vector dims; std::vector< std::pair > geoTypes; @@ -380,7 +381,7 @@ std::vector< std::vector< std::pair > > M for(int i=0;i0) { INTERP_KERNEL::NormalizedCellType typp=typmai2[i]; @@ -418,12 +419,12 @@ std::vector< std::pair > MEDLoader::GetComponentsNamesO { CheckFileForRead(fileName); MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY); - med_int nbFields=MEDnField(fid); + med_int nbFields(MEDnField(fid)); std::vector fields(nbFields); med_field_type typcha; for(int i=0;i comp=new char[ncomp*MED_SNAME_SIZE+1]; INTERP_KERNEL::AutoPtr unit=new char[ncomp*MED_SNAME_SIZE+1]; INTERP_KERNEL::AutoPtr dt_unit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE); @@ -431,7 +432,7 @@ std::vector< std::pair > MEDLoader::GetComponentsNamesO med_bool localmesh; INTERP_KERNEL::AutoPtr maa_ass=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); INTERP_KERNEL::AutoPtr nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); - MEDfieldInfo(fid,i+1,nomcha,maa_ass,&localmesh,&typcha,comp,unit,dt_unit,&nbPdt); + MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,i+1,nomcha,maa_ass,&localmesh,&typcha,comp,unit,dt_unit,&nbPdt)); std::string meshName=MEDLoaderBase::buildStringFromFortran(maa_ass,MED_NAME_SIZE); std::string curFieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE+1); if(curFieldName==fieldName) @@ -439,7 +440,7 @@ std::vector< std::pair > MEDLoader::GetComponentsNamesO std::vector< std::pair > ret(ncomp); for(int j=0;j(MEDLoaderBase::buildStringFromFortran(((char *)comp)+j*MED_SNAME_SIZE,MED_SNAME_SIZE), - MEDLoaderBase::buildStringFromFortran(((char *)unit)+j*MED_SNAME_SIZE,MED_SNAME_SIZE)); + MEDLoaderBase::buildStringFromFortran(((char *)unit)+j*MED_SNAME_SIZE,MED_SNAME_SIZE)); return ret; } fields[i]=curFieldName; @@ -465,12 +466,12 @@ std::vector MEDLoader::GetMeshNamesOnField(const std::string& fileN // for(int i=0;i comp=new char[ncomp*MED_SNAME_SIZE+1]; INTERP_KERNEL::AutoPtr unit=new char[ncomp*MED_SNAME_SIZE+1]; med_int nbPdt; INTERP_KERNEL::AutoPtr maa_ass=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); - MEDfieldInfo(fid,i+1,nomcha,maa_ass,&localmesh,&typcha,comp,unit,dt_unit,&nbPdt); + MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,i+1,nomcha,maa_ass,&localmesh,&typcha,comp,unit,dt_unit,&nbPdt)); std::string meshName=MEDLoaderBase::buildStringFromFortran(maa_ass,MED_NAME_SIZE); std::string curFieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE+1); if(curFieldName==fieldName) @@ -567,7 +568,7 @@ std::vector MEDLoader::GetMeshGroupsNamesOnFamily(const std::string return ret; } - + std::vector MEDLoader::GetMeshGroupsNames(const std::string& fileName, const std::string& meshName) { CheckFileForRead(fileName); @@ -594,74 +595,38 @@ std::vector MEDLoader::GetMeshGroupsNames(const std::string& fileNa } return ret; } + std::vector MEDLoader::GetTypesOfField(const std::string& fileName, const std::string& meshName, const std::string& fieldName) { - CheckFileForRead(fileName); std::vector ret; - MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY); - med_int nbFields=MEDnField(fid); - // - med_field_type typcha; - //med_int nbpdtnor=0,pflsize,*pflval,lnsize; - med_int numdt=0,numo=0; - med_float dt=0.0; - char pflname[MED_NAME_SIZE+1]=""; - char locname[MED_NAME_SIZE+1]=""; - char *maa_ass=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); - char *nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); - med_bool localmesh; - // - for(int i=0;i fs(MEDFileAnyTypeFieldMultiTS::New(fileName,fieldName,false)); + if(fs->getMeshName()!=meshName) { - med_int ncomp=MEDfieldnComponent(fid,i+1); - INTERP_KERNEL::AutoPtr comp=new char[ncomp*MED_SNAME_SIZE+1]; - INTERP_KERNEL::AutoPtr unit=new char[ncomp*MED_SNAME_SIZE+1]; - INTERP_KERNEL::AutoPtr dt_unit=new char[MED_LNAME_SIZE+1]; - med_int nbPdt; - MEDfieldInfo(fid,i+1,nomcha,maa_ass,&localmesh,&typcha,comp,unit,dt_unit,&nbPdt); - std::string curFieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE+1); - std::string curMeshName=MEDLoaderBase::buildStringFromFortran(maa_ass,MED_NAME_SIZE+1); - if(curMeshName==meshName) - { - if(curFieldName==fieldName) - { - int profilesize,nbi; - if(nbPdt>0) - { - bool found=false; - for(int ii=0;ii0) - { - ret.push_back(ON_NODES); - found=true; - } - } - } - bool found=false; - for(int j=0;j0) - { - MEDfieldComputingStepInfo(fid,nomcha,1,&numdt,&numo,&dt); - med_int nbOfVal=MEDfieldnValueWithProfile(fid,nomcha,numdt,numo,MED_CELL,typmai[j],1,MED_COMPACT_PFLMODE, - pflname,&profilesize,locname,&nbi); - if(nbOfVal>0) - { - found=true; - ret.push_back(ON_CELLS); - } - } - } - } - } + std::ostringstream oss; oss << "MEDLoader::GetTypesOfField : The field \"" << fieldName << "\" in file \"" << fileName << "\" is not lying on mesh \"" << meshName << "\""; + oss << " The name of the mesh in file is \"" << fs->getMeshName() << "\"!"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); } - delete [] maa_ass; - delete [] nomcha; - return ret; + int nbTS(fs->getNumberOfTS()); + if(nbTS==0) + return ret; + for(int i=0;i f1ts(fs->getTimeStepAtPos(i)); + std::vector tof(f1ts->getTypesOfFieldAvailable()); + for(std::vector::const_iterator it=tof.begin();it!=tof.end();it++) + if(std::find(ret.begin(),ret.end(),*it)==ret.end()) + ret.push_back(*it); + } + // sort ret to put before ON_NODES then ON_CELLS then the remaining. + std::vector ret2; + if(std::find(ret.begin(),ret.end(),ON_NODES)!=ret.end()) + ret2.push_back(ON_NODES); + if(std::find(ret.begin(),ret.end(),ON_CELLS)!=ret.end()) + ret2.push_back(ON_CELLS); + for(std::vector::const_iterator it=ret.begin();it!=ret.end();it++) + if(*it!=ON_NODES && *it!=ON_CELLS) + ret2.push_back(*it); + return ret2; } std::vector MEDLoader::GetAllFieldNames(const std::string& fileName) @@ -673,7 +638,7 @@ std::vector MEDLoader::GetAllFieldNames(const std::string& fileName med_field_type typcha; for(int i=0;i comp=new char[ncomp*MED_SNAME_SIZE+1]; INTERP_KERNEL::AutoPtr unit=new char[ncomp*MED_SNAME_SIZE+1]; INTERP_KERNEL::AutoPtr nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); @@ -681,7 +646,7 @@ std::vector MEDLoader::GetAllFieldNames(const std::string& fileName INTERP_KERNEL::AutoPtr dt_unit=new char[MED_LNAME_SIZE+1]; med_int nbPdt; med_bool localmesh; - MEDfieldInfo(fid,i+1,nomcha,maa_ass,&localmesh,&typcha,comp,unit,dt_unit,&nbPdt); + MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,i+1,nomcha,maa_ass,&localmesh,&typcha,comp,unit,dt_unit,&nbPdt)); ret.push_back(std::string(nomcha)); } return ret; @@ -700,13 +665,13 @@ std::vector MEDLoader::GetAllFieldNamesOnMesh(const std::string& fi // for(int i=0;i comp=new char[ncomp*MED_SNAME_SIZE+1]; INTERP_KERNEL::AutoPtr unit=new char[ncomp*MED_SNAME_SIZE+1]; INTERP_KERNEL::AutoPtr dt_unit=new char[MED_LNAME_SIZE+1]; med_int nbPdt; med_bool localmesh; - MEDfieldInfo(fid,i+1,nomcha,maa_ass,&localmesh,&typcha,comp,unit,dt_unit,&nbPdt); + MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,i+1,nomcha,maa_ass,&localmesh,&typcha,comp,unit,dt_unit,&nbPdt)); std::string curFieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE+1); std::string curMeshName=MEDLoaderBase::buildStringFromFortran(maa_ass,MED_NAME_SIZE+1); // @@ -722,14 +687,14 @@ std::vector MEDLoader::GetFieldNamesOnMesh(ParaMEDMEM::TypeOfField { CheckFileForRead(fileName); switch(type) - { + { case ON_CELLS: return GetCellFieldNamesOnMesh(fileName,meshName); case ON_NODES: return GetNodeFieldNamesOnMesh(fileName,meshName); default: throw INTERP_KERNEL::Exception("Type of field specified not managed ! manages are ON_NODES or ON_CELLS !"); - } + } } std::vector MEDLoader::GetCellFieldNamesOnMesh(const std::string& fileName, const std::string& meshName) @@ -753,10 +718,10 @@ std::vector MEDLoader::GetCellFieldNamesOnMesh(const std::string& f // for(int i=0;i comp=new char[ncomp*MED_SNAME_SIZE+1]; INTERP_KERNEL::AutoPtr unit=new char[ncomp*MED_SNAME_SIZE+1]; - MEDfieldInfo(fid,i+1,nomcha,maa_ass,&localmesh,&typcha,comp,unit,dt_unit,&nbPdt); + MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,i+1,nomcha,maa_ass,&localmesh,&typcha,comp,unit,dt_unit,&nbPdt)); std::string curFieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE+1); std::string curMeshName=MEDLoaderBase::buildStringFromFortran(maa_ass,MED_NAME_SIZE+1); int profilesize,nbi; @@ -767,9 +732,9 @@ std::vector MEDLoader::GetCellFieldNamesOnMesh(const std::string& f { if(nbPdt>0) { - MEDfieldComputingStepInfo(fid,nomcha,1,&numdt,&numo,&dt); - med_int nbOfVal=MEDfieldnValueWithProfile(fid,nomcha,numdt,numo,MED_CELL,typmai[j],1,MED_COMPACT_PFLMODE, - pflname,&profilesize,locname,&nbi); + MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,nomcha,1,&numdt,&numo,&dt)); + med_int nbOfVal(MEDfieldnValueWithProfile(fid,nomcha,numdt,numo,MED_CELL,typmai[j],1,MED_COMPACT_PFLMODE, + pflname,&profilesize,locname,&nbi)); if(nbOfVal>0) { found=true; @@ -801,19 +766,19 @@ std::vector MEDLoader::GetNodeFieldNamesOnMesh(const std::string& f // for(int i=0;i comp=new char[ncomp*MED_SNAME_SIZE+1]; INTERP_KERNEL::AutoPtr unit=new char[ncomp*MED_SNAME_SIZE+1]; med_int nbPdt; - MEDfieldInfo(fid,i+1,nomcha,maa_ass,&localmesh,&typcha,comp,unit,dt_unit,&nbPdt); + MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,i+1,nomcha,maa_ass,&localmesh,&typcha,comp,unit,dt_unit,&nbPdt)); std::string curFieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE+1); std::string curMeshName=MEDLoaderBase::buildStringFromFortran(maa_ass,MED_NAME_SIZE+1); if(nbPdt>0) { int profilesize,nbi; - MEDfieldComputingStepInfo(fid,nomcha,1,&numdt,&numo,&dt); - med_int nbOfVal=MEDfieldnValueWithProfile(fid,nomcha,numdt,numo,MED_NODE,MED_NONE,1,MED_COMPACT_PFLMODE, - pflname,&profilesize,locname,&nbi); + MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,nomcha,1,&numdt,&numo,&dt)); + med_int nbOfVal(MEDfieldnValueWithProfile(fid,nomcha,numdt,numo,MED_NODE,MED_NONE,1,MED_COMPACT_PFLMODE, + pflname,&profilesize,locname,&nbi)); if(curMeshName==meshName && nbOfVal>0) { ret.push_back(curFieldName); @@ -841,17 +806,17 @@ std::vector< std::pair< std::pair, double> > MEDLoader::GetAllFieldIter std::ostringstream oss; oss << "MEDLoader::GetAllFieldIterations : No field with name \"" << fieldName<< "\" in file \"" << fileName << "\" ! Possible fields are : "; for(int i=0;i comp=new char[ncomp*MED_SNAME_SIZE+1]; INTERP_KERNEL::AutoPtr unit=new char[ncomp*MED_SNAME_SIZE+1]; med_int nbPdt; - MEDfieldInfo(fid,i+1,nomcha,maa_ass,&localmesh,&typcha,comp,unit,dt_unit,&nbPdt); + MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,i+1,nomcha,maa_ass,&localmesh,&typcha,comp,unit,dt_unit,&nbPdt)); std::string curFieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE+1); if(curFieldName==fieldName) { for(int k=0;k::max(); for(int i=0;i comp=new char[ncomp*MED_SNAME_SIZE+1]; INTERP_KERNEL::AutoPtr unit=new char[ncomp*MED_SNAME_SIZE+1]; med_int nbPdt; - MEDfieldInfo(fid,i+1,nomcha,maa_ass,&local,&typcha,comp,unit,dt_unit,&nbPdt); + MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,i+1,nomcha,maa_ass,&local,&typcha,comp,unit,dt_unit,&nbPdt)); std::string curFieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE+1); if(curFieldName==fieldName) { found=true; for(int k=0;k > MEDLoader::GetFieldIterations(ParaMEDMEM::Type { CheckFileForRead(fileName); switch(type) - { + { case ON_CELLS: return GetCellFieldIterations(fileName,meshName,fieldName); case ON_NODES: return GetNodeFieldIterations(fileName,meshName,fieldName); default: throw INTERP_KERNEL::Exception("Type of field specified not managed ! manages are ON_NODES or ON_CELLS !"); - } + } } std::vector< std::pair > MEDLoader::GetCellFieldIterations(const std::string& fileName, const std::string& meshName, const std::string& fieldName) @@ -950,11 +915,11 @@ std::vector< std::pair > MEDLoader::GetCellFieldIterations(const std::s std::set s2; for(int i=0;i comp=new char[ncomp*MED_SNAME_SIZE+1]; INTERP_KERNEL::AutoPtr unit=new char[ncomp*MED_SNAME_SIZE+1]; med_int nbPdt; - MEDfieldInfo(fid,i+1,nomcha,maa_ass,&localmesh,&typcha,comp,unit,dt_unit,&nbPdt); + MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,i+1,nomcha,maa_ass,&localmesh,&typcha,comp,unit,dt_unit,&nbPdt)); std::string curFieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE+1); if(curFieldName==fieldName) { @@ -964,9 +929,9 @@ std::vector< std::pair > MEDLoader::GetCellFieldIterations(const std::s for(int k=0;k0) { @@ -1022,28 +987,28 @@ std::vector< std::pair > MEDLoader::GetNodeFieldIterations(const std::s std::set s2; for(int i=0;i comp=new char[ncomp*MED_SNAME_SIZE+1]; INTERP_KERNEL::AutoPtr unit=new char[ncomp*MED_SNAME_SIZE+1]; med_int nbPdt; - MEDfieldInfo(fid,i+1,nomcha,maa_ass,&localmesh,&typcha,comp,unit,dt_unit,&nbPdt); + MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,i+1,nomcha,maa_ass,&localmesh,&typcha,comp,unit,dt_unit,&nbPdt)); std::string curFieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE+1); if(curFieldName==fieldName) { for(int k=0;k0) - { - if(meshNameCpp==maa_ass_cpp) - { ret.push_back(std::make_pair(numdt,numo)); } - else - s2.insert(maa_ass_cpp); - } + MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,nomcha,k+1,&numdt,&numo,&dt)); + med_int nbOfVal(MEDfieldnValueWithProfile(fid,nomcha,numdt,numo,MED_NODE,MED_NONE,1,MED_COMPACT_PFLMODE, + pflname,&profilesize,locname,&nbi)); + std::string maa_ass_cpp(maa_ass); + if(nbOfVal>0) + { + if(meshNameCpp==maa_ass_cpp) + { ret.push_back(std::make_pair(numdt,numo)); } + else + s2.insert(maa_ass_cpp); + } } } else @@ -1124,7 +1089,7 @@ ParaMEDMEM::MEDCouplingUMesh *MEDLoader::ReadUMeshFromFile(const std::string& fi std::ostringstream oss; oss << "MEDLoader::ReadUMeshFromFile : With fileName=\""<< fileName << "\", meshName=\""<< meshName << "\" exists but it is not an unstructured mesh !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - return mmuPtr->getMeshAtLevel(meshDimRelToMax,true); + return mmuPtr->getMeshAtLevel(meshDimRelToMax,true); } ParaMEDMEM::MEDCouplingUMesh *MEDLoader::ReadUMeshFromFile(const std::string& fileName, int meshDimRelToMax) @@ -1138,7 +1103,7 @@ ParaMEDMEM::MEDCouplingUMesh *MEDLoader::ReadUMeshFromFile(const std::string& fi std::ostringstream oss; oss << "MEDLoader::ReadUMeshFromFile : With fileName=\""<< fileName << "\", meshName (the first) =\""<< mm->getName() << "\" exists but it is not an unstructured mesh !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - return mmuPtr->getMeshAtLevel(meshDimRelToMax,true); + return mmuPtr->getMeshAtLevel(meshDimRelToMax,true); } int MEDLoader::ReadUMeshDimFromFile(const std::string& fileName, const std::string& meshName) @@ -1159,7 +1124,7 @@ ParaMEDMEM::MEDCouplingUMesh *MEDLoader::ReadUMeshFromFamilies(const std::string std::ostringstream oss; oss << "MEDLoader::ReadUMeshFromFamilies : With fileName=\""<< fileName << "\", meshName (the first) =\""<< mm->getName() << "\" exists but it is not an unstructured mesh !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - return mmuPtr->getFamilies(meshDimRelToMax,fams,true); + return mmuPtr->getFamilies(meshDimRelToMax,fams,true); } ParaMEDMEM::MEDCouplingUMesh *MEDLoader::ReadUMeshFromGroups(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::vector& grps) @@ -1173,14 +1138,14 @@ ParaMEDMEM::MEDCouplingUMesh *MEDLoader::ReadUMeshFromGroups(const std::string& std::ostringstream oss; oss << "MEDLoader::ReadUMeshFromGroups : With fileName=\""<< fileName << "\", meshName (the first) =\""<< mm->getName() << "\" exists but it is not an unstructured mesh !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - return mmuPtr->getGroups(meshDimRelToMax,grps,true); + return mmuPtr->getGroups(meshDimRelToMax,grps,true); } ParaMEDMEM::MEDCouplingFieldDouble *MEDLoader::ReadField(ParaMEDMEM::TypeOfField type, const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order) { CheckFileForRead(fileName); switch(type) - { + { case ON_CELLS: return ReadFieldCell(fileName,meshName,meshDimRelToMax,fieldName,iteration,order); case ON_NODES: @@ -1191,11 +1156,11 @@ ParaMEDMEM::MEDCouplingFieldDouble *MEDLoader::ReadField(ParaMEDMEM::TypeOfField return ReadFieldGaussNE(fileName,meshName,meshDimRelToMax,fieldName,iteration,order); default: throw INTERP_KERNEL::Exception("Type of field specified not managed ! manages are ON_NODES, ON_CELLS, ON_GAUSS_PT or ON_GAUSS_NE !"); - } + } } std::vector MEDLoader::ReadFieldsOnSameMesh(ParaMEDMEM::TypeOfField type, const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, - const std::vector >& its) throw(INTERP_KERNEL::Exception) + const std::vector >& its) { if(its.empty()) return std::vector(); @@ -1232,25 +1197,25 @@ std::vector MEDLoader::ReadFieldsOnSameMes } std::vector MEDLoader::ReadFieldsCellOnSameMesh(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, - const std::vector >& its) throw(INTERP_KERNEL::Exception) + const std::vector >& its) { return ReadFieldsOnSameMesh(ON_CELLS,fileName,meshName,meshDimRelToMax,fieldName,its); } std::vector MEDLoader::ReadFieldsNodeOnSameMesh(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, - const std::vector >& its) throw(INTERP_KERNEL::Exception) + const std::vector >& its) { return ReadFieldsOnSameMesh(ON_NODES,fileName,meshName,meshDimRelToMax,fieldName,its); } std::vector MEDLoader::ReadFieldsGaussOnSameMesh(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, - const std::vector >& its) throw(INTERP_KERNEL::Exception) + const std::vector >& its) { return ReadFieldsOnSameMesh(ON_GAUSS_PT,fileName,meshName,meshDimRelToMax,fieldName,its); } std::vector MEDLoader::ReadFieldsGaussNEOnSameMesh(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, - const std::vector >& its) throw(INTERP_KERNEL::Exception) + const std::vector >& its) { return ReadFieldsOnSameMesh(ON_GAUSS_NE,fileName,meshName,meshDimRelToMax,fieldName,its); }