From: ageay Date: Mon, 8 Apr 2013 15:54:05 +0000 (+0000) Subject: Some little imps of messages when invalid meshName and fieldNames X-Git-Tag: V6_main_FINAL~185 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=9b463a6d791f455ea7e24890d6dd832ccba01afd;p=tools%2Fmedcoupling.git Some little imps of messages when invalid meshName and fieldNames --- diff --git a/src/MEDCoupling/MEDCouplingUMesh.hxx b/src/MEDCoupling/MEDCouplingUMesh.hxx index 93f44214b..75f0db4c0 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.hxx +++ b/src/MEDCoupling/MEDCouplingUMesh.hxx @@ -55,7 +55,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT void checkCoherency1(double eps=1e-12) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void checkCoherency2(double eps=1e-12) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void setMeshDimension(int meshDim); - MEDCOUPLING_EXPORT void allocateCells(int nbOfCells); + MEDCOUPLING_EXPORT void allocateCells(int nbOfCells=0); MEDCOUPLING_EXPORT void insertNextCell(INTERP_KERNEL::NormalizedCellType type, int size, const int *nodalConnOfCell) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void finishInsertingCells(); MEDCOUPLING_EXPORT MEDCouplingUMeshCellIterator *cellIterator(); diff --git a/src/MEDCoupling_Swig/MEDCouplingCommon.i b/src/MEDCoupling_Swig/MEDCouplingCommon.i index f07d9843f..5395c22c4 100644 --- a/src/MEDCoupling_Swig/MEDCouplingCommon.i +++ b/src/MEDCoupling_Swig/MEDCouplingCommon.i @@ -1355,7 +1355,7 @@ namespace ParaMEDMEM void updateTime() const; void checkCoherency() const throw(INTERP_KERNEL::Exception); void setMeshDimension(int meshDim) throw(INTERP_KERNEL::Exception); - void allocateCells(int nbOfCells) throw(INTERP_KERNEL::Exception); + void allocateCells(int nbOfCells=0) throw(INTERP_KERNEL::Exception); void finishInsertingCells() throw(INTERP_KERNEL::Exception); MEDCouplingUMeshCellByTypeEntry *cellsByType() throw(INTERP_KERNEL::Exception); void setConnectivity(DataArrayInt *conn, DataArrayInt *connIndex, bool isComputingTypes=true) throw(INTERP_KERNEL::Exception); diff --git a/src/MEDLoader/MEDLoader.cxx b/src/MEDLoader/MEDLoader.cxx index 0550b850c..5af7ca0c0 100644 --- a/src/MEDLoader/MEDLoader.cxx +++ b/src/MEDLoader/MEDLoader.cxx @@ -304,7 +304,7 @@ std::vector MEDLoaderNS::getMeshNamesFid(med_idt fid) void MEDLoaderNS::fillGaussDataOnField(const char *fileName, const std::list& data, MEDCouplingFieldDouble *f) { - med_idt fid=MEDfileOpen(fileName,MED_ACC_RDONLY); + MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY); char locName[MED_NAME_SIZE+1]; int nloc=MEDnLocalization(fid); med_geometry_type typeGeo; @@ -341,7 +341,6 @@ void MEDLoaderNS::fillGaussDataOnField(const char *fileName, const std::list MEDLoader::GetMeshNames(const char *fileName) throw(INTERP_KERNEL::Exception) { CheckFileForRead(fileName); - med_idt fid=MEDfileOpen(fileName,MED_ACC_RDONLY); + MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY); std::vector ret=MEDLoaderNS::getMeshNamesFid(fid); - MEDfileClose(fid); return ret; } @@ -467,7 +465,7 @@ std::vector MEDLoader::GetMeshNamesOnField(const char *fileName, co CheckFileForRead(fileName); std::vector ret; // - med_idt fid=MEDfileOpen(fileName,MED_ACC_RDONLY); + MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY); med_int nbFields=MEDnField(fid); // med_field_type typcha; @@ -488,14 +486,13 @@ std::vector MEDLoader::GetMeshNamesOnField(const char *fileName, co if(curFieldName==fieldName) ret.push_back(meshName); } - MEDfileClose(fid); return ret; } std::vector MEDLoader::GetMeshFamiliesNames(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception) { CheckFileForRead(fileName); - med_idt fid=MEDfileOpen(fileName,MED_ACC_RDONLY); + MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY); med_int nfam=MEDnFamily(fid,meshName); std::vector ret(nfam); char nomfam[MED_NAME_SIZE+1]; @@ -512,7 +509,6 @@ std::vector MEDLoader::GetMeshFamiliesNames(const char *fileName, c std::string cur=MEDLoaderBase::buildStringFromFortran(nomfam,sizeof(nomfam)); ret[i]=cur; } - MEDfileClose(fid); return ret; } @@ -520,7 +516,7 @@ std::vector MEDLoader::GetMeshFamiliesNames(const char *fileName, c std::vector MEDLoader::GetMeshFamiliesNamesOnGroup(const char *fileName, const char *meshName, const char *grpName) throw(INTERP_KERNEL::Exception) { CheckFileForRead(fileName); - med_idt fid=MEDfileOpen(fileName,MED_ACC_RDONLY); + MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY); med_int nfam=MEDnFamily(fid,meshName); std::vector ret; char nomfam[MED_NAME_SIZE+1]; @@ -542,14 +538,13 @@ std::vector MEDLoader::GetMeshFamiliesNamesOnGroup(const char *file ret.push_back(cur); } } - MEDfileClose(fid); return ret; } std::vector MEDLoader::GetMeshGroupsNamesOnFamily(const char *fileName, const char *meshName, const char *famName) throw(INTERP_KERNEL::Exception) { CheckFileForRead(fileName); - med_idt fid=MEDfileOpen(fileName,MED_ACC_RDONLY); + MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY); med_int nfam=MEDnFamily(fid,meshName); std::vector ret; char nomfam[MED_NAME_SIZE+1]; @@ -573,7 +568,6 @@ std::vector MEDLoader::GetMeshGroupsNamesOnFamily(const char *fileN ret.push_back(cur2); } } - MEDfileClose(fid); if(!found) { std::ostringstream oss; @@ -587,7 +581,7 @@ std::vector MEDLoader::GetMeshGroupsNamesOnFamily(const char *fileN std::vector MEDLoader::GetMeshGroupsNames(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception) { CheckFileForRead(fileName); - med_idt fid=MEDfileOpen(fileName,MED_ACC_RDONLY); + MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY); med_int nfam=MEDnFamily(fid,meshName); std::vector ret; char nomfam[MED_NAME_SIZE+1]; @@ -608,14 +602,13 @@ std::vector MEDLoader::GetMeshGroupsNames(const char *fileName, con ret.push_back(cur); } } - MEDfileClose(fid); return ret; } std::vector MEDLoader::GetTypesOfField(const char *fileName, const char *meshName, const char *fieldName) throw(INTERP_KERNEL::Exception) { CheckFileForRead(fileName); std::vector ret; - med_idt fid=MEDfileOpen(fileName,MED_ACC_RDONLY); + MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY); med_int nbFields=MEDnField(fid); // med_field_type typcha; @@ -678,7 +671,6 @@ std::vector MEDLoader::GetTypesOfField(const char *file } delete [] maa_ass; delete [] nomcha; - MEDfileClose(fid); return ret; } @@ -686,7 +678,7 @@ std::vector MEDLoader::GetAllFieldNames(const char *fileName) throw { CheckFileForRead(fileName); std::vector ret; - med_idt fid=MEDfileOpen(fileName,MED_ACC_RDONLY); + MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY); med_int nbFields=MEDnField(fid); med_field_type typcha; for(int i=0;i MEDLoader::GetAllFieldNames(const char *fileName) throw MEDfieldInfo(fid,i+1,nomcha,maa_ass,&localmesh,&typcha,comp,unit,dt_unit,&nbPdt); ret.push_back(std::string(nomcha)); } - MEDfileClose(fid); return ret; } @@ -710,7 +701,7 @@ std::vector MEDLoader::GetAllFieldNamesOnMesh(const char *fileName, { CheckFileForRead(fileName); std::vector ret; - med_idt fid=MEDfileOpen(fileName,MED_ACC_RDONLY); + MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY); med_int nbFields=MEDnField(fid); // med_field_type typcha; @@ -734,7 +725,6 @@ std::vector MEDLoader::GetAllFieldNamesOnMesh(const char *fileName, } delete [] maa_ass; delete [] nomcha; - MEDfileClose(fid); return ret; } @@ -756,7 +746,7 @@ std::vector MEDLoader::GetCellFieldNamesOnMesh(const char *fileName { CheckFileForRead(fileName); std::vector ret; - med_idt fid=MEDfileOpen(fileName,MED_ACC_RDONLY); + MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY); med_int nbFields=MEDnField(fid); // med_field_type typcha; @@ -799,7 +789,6 @@ std::vector MEDLoader::GetCellFieldNamesOnMesh(const char *fileName } } } - MEDfileClose(fid); return ret; } @@ -807,7 +796,7 @@ std::vector MEDLoader::GetNodeFieldNamesOnMesh(const char *fileName { CheckFileForRead(fileName); std::vector ret; - med_idt fid=MEDfileOpen(fileName,MED_ACC_RDONLY); + MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY); med_int nbFields=MEDnField(fid); char pflname[MED_NAME_SIZE+1]=""; char locname[MED_NAME_SIZE+1]=""; @@ -841,16 +830,14 @@ std::vector MEDLoader::GetNodeFieldNamesOnMesh(const char *fileName } } } - MEDfileClose(fid); return ret; } -std::vector< std::pair< std::pair, double> > MEDLoader::GetAllFieldIterations(const char *fileName, const char *meshName, const char *fieldName) throw(INTERP_KERNEL::Exception) +std::vector< std::pair< std::pair, double> > MEDLoader::GetAllFieldIterations(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception) { CheckFileForRead(fileName); - std::string meshNameCpp(meshName); std::vector< std::pair< std::pair, double > > ret; - med_idt fid=MEDfileOpen(fileName,MED_ACC_RDONLY); + MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY); med_int nbFields=MEDnField(fid); // med_field_type typcha; @@ -861,6 +848,7 @@ std::vector< std::pair< std::pair, double> > MEDLoader::GetAllFieldIter INTERP_KERNEL::AutoPtr nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); med_bool localmesh; // + std::ostringstream oss; oss << "MEDLoader::GetAllFieldIterations : No field with name \"" << fieldName<< "\" in file \"" << fileName << "\" ! Possible fields are : "; for(int i=0;i, double> > MEDLoader::GetAllFieldIter MEDfieldComputingStepInfo(fid,nomcha,k+1,&numdt,&numo,&dt); ret.push_back(std::make_pair(std::make_pair(numdt,numo),dt)); } + return ret; + } + else + { + oss << "\"" << curFieldName << "\""; + if(i!=nbFields-1) oss << ", "; } } - MEDfileClose(fid); - return ret; + oss << " !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); } double MEDLoader::GetTimeAttachedOnFieldIteration(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception) { CheckFileForRead(fileName); - med_idt fid=MEDfileOpen(fileName,MED_ACC_RDONLY); + MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY); med_int nbFields=MEDnField(fid); // med_field_type typcha; @@ -921,7 +915,6 @@ double MEDLoader::GetTimeAttachedOnFieldIteration(const char *fileName, const ch } } } - MEDfileClose(fid); if(!found || !found2) { std::ostringstream oss; @@ -950,7 +943,7 @@ std::vector< std::pair > MEDLoader::GetCellFieldIterations(const char * CheckFileForRead(fileName); std::string meshNameCpp(meshName); std::vector< std::pair > ret; - med_idt fid=MEDfileOpen(fileName,MED_ACC_RDONLY); + MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY); med_int nbFields=MEDnField(fid); // med_field_type typcha; @@ -963,6 +956,8 @@ std::vector< std::pair > MEDLoader::GetCellFieldIterations(const char * INTERP_KERNEL::AutoPtr nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); med_bool localmesh; // + std::ostringstream oss; oss << "MEDLoader::GetCellFieldIterations : No cell Field field with name \"" << fieldName<< "\" in file \"" << fileName << "\" ! Possible fields are : "; + std::set s2; for(int i=0;i > MEDLoader::GetCellFieldIterations(const char * med_int nbOfVal=MEDfieldnValueWithProfile(fid,nomcha,numdt,numo,MED_CELL,typmai[j],1,MED_COMPACT_PFLMODE, pflname,&profilesize,locname,&nbi); std::string maa_ass_cpp(maa_ass); - if(meshNameCpp==maa_ass_cpp && nbOfVal>0) + if(nbOfVal>0) { - found=true; - ret.push_back(std::make_pair(numdt,numo)); + if(meshNameCpp==maa_ass_cpp) + { + found=true; + ret.push_back(std::make_pair(numdt,numo)); + } + else + s2.insert(maa_ass_cpp); } } } } + else + { + oss << "\"" << curFieldName << "\""; + if(i!=nbFields-1) oss << ", "; + } + } + if(ret.empty()) + { + if(!s2.empty()) + { + oss << ". Cell Field \"" << fieldName << "\" exists but lies on meshes with names : \""; + std::copy(s2.begin(),s2.end(),std::ostream_iterator(oss,"\", \"")); + } + oss << " !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); } - MEDfileClose(fid); return ret; } @@ -1001,7 +1015,7 @@ std::vector< std::pair > MEDLoader::GetNodeFieldIterations(const char * CheckFileForRead(fileName); std::string meshNameCpp(meshName); std::vector< std::pair > ret; - med_idt fid=MEDfileOpen(fileName,MED_ACC_RDONLY); + MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY); med_int nbFields=MEDnField(fid); // med_field_type typcha; @@ -1014,6 +1028,8 @@ std::vector< std::pair > MEDLoader::GetNodeFieldIterations(const char * INTERP_KERNEL::AutoPtr nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); med_bool localmesh; // + std::ostringstream oss; oss << "MEDLoader::GetNodeFieldIterations : No node Field field with name \"" << fieldName<< "\" in file \"" << fileName << "\" ! Possible fields are : "; + std::set s2; for(int i=0;i > MEDLoader::GetNodeFieldIterations(const char * 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(meshNameCpp==maa_ass_cpp && nbOfVal>0) + if(nbOfVal>0) { - ret.push_back(std::make_pair(numdt,numo)); + if(meshNameCpp==maa_ass_cpp) + { ret.push_back(std::make_pair(numdt,numo)); } + else + s2.insert(maa_ass_cpp); } } } + else + { + oss << "\"" << curFieldName << "\""; + if(i!=nbFields-1) oss << ", "; + } + } + if(ret.empty()) + { + if(!s2.empty()) + { + oss << ". Node Field \"" << fieldName << "\" exists but lies on meshes with names : \""; + std::copy(s2.begin(),s2.end(),std::ostream_iterator(oss,"\", \"")); + } + oss << " !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); } - MEDfileClose(fid); return ret; } @@ -1158,7 +1191,7 @@ void MEDLoaderNS::readFieldDoubleDataInMedFile(const char *fileName, const char std::vector MEDLoaderNS::getIdsFromFamilies(const char *fileName, const char *meshName, const std::vector& fams) { std::vector ret; - med_idt fid=MEDfileOpen(fileName,MED_ACC_RDONLY); + MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY); med_int nfam=MEDnFamily(fid,meshName); char nomfam[MED_NAME_SIZE+1]; med_int numfam; @@ -1175,14 +1208,13 @@ std::vector MEDLoaderNS::getIdsFromFamilies(const char *fileName, const cha if(std::find(fams.begin(),fams.end(),cur)!=fams.end()) ret.push_back(numfam); } - MEDfileClose(fid); return ret; } std::vector MEDLoaderNS::getIdsFromGroups(const char *fileName, const char *meshName, const std::vector& grps) { std::vector ret; - med_idt fid=MEDfileOpen(fileName,MED_ACC_RDONLY); + MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY); med_int nfam=MEDnFamily(fid,meshName); char nomfam[MED_NAME_SIZE+1]; med_int numfam; @@ -1206,7 +1238,6 @@ std::vector MEDLoaderNS::getIdsFromGroups(const char *fileName, const char } } } - MEDfileClose(fid); return ret; } @@ -1261,7 +1292,7 @@ void MEDLoaderNS::dispatchElems(int nbOfElemCell, int nbOfElemFace, int& nbOfEle int MEDLoaderNS::readUMeshDimFromFile(const char *fileName, const char *meshName, std::vector& possibilities) { possibilities.clear(); - med_idt fid=MEDfileOpen(fileName,MED_ACC_RDONLY); + MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY); int ret; std::set poss; char nommaa[MED_NAME_SIZE+1]; @@ -1303,7 +1334,6 @@ int MEDLoaderNS::readUMeshDimFromFile(const char *fileName, const char *meshName poss.insert(curDim); } } - MEDfileClose(fid); if(!poss.empty()) { ret=*poss.rbegin(); @@ -1850,7 +1880,7 @@ MEDCouplingUMesh *MEDLoaderNS::readUMeshFromFileLev1(const char *fileName, const if(meshDimRelToMax>0) throw INTERP_KERNEL::Exception("meshDimRelToMax must be <=0 !"); //Extraction data from MED file. - med_idt fid=MEDfileOpen(fileName,MED_ACC_RDONLY); + MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY); std::string trueMeshName; med_int mid=getIdFromMeshName(fid,meshName,trueMeshName); DataArrayDouble *coords=0; @@ -1861,7 +1891,6 @@ MEDCouplingUMesh *MEDLoaderNS::readUMeshFromFileLev1(const char *fileName, const meshDimExtract=meshDimExtract+meshDimRelToMax; MEDLoaderNS::keepSpecifiedMeshDim(conn,meshDimExtract); MEDLoaderNS::keepTypes(conn,typesToKeep); - MEDfileClose(fid); //Put data in returned data structure. MEDCouplingUMesh *ret=MEDCouplingUMesh::New(); ret->setName(trueMeshName.c_str()); @@ -2221,13 +2250,10 @@ ParaMEDMEM::MEDCouplingFieldDouble *MEDLoader::ReadFieldGaussNE(const char *file */ void MEDLoaderNS::writeUMeshesDirectly(const char *fileName, const std::vector& mesh, const std::vector& families, bool forceFromScratch, bool &isRenumbering) { - med_idt fid=MEDfileOpen(fileName,forceFromScratch?MED_ACC_CREAT:MED_ACC_RDWR); + MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,forceFromScratch?MED_ACC_CREAT:MED_ACC_RDWR); std::string meshName(mesh[0]->getName()); if(meshName=="") - { - MEDfileClose(fid); - throw INTERP_KERNEL::Exception("MEDCouplingMesh must have a not null name !"); - } + throw INTERP_KERNEL::Exception("MEDCouplingMesh must have a not null name !"); isRenumbering=false; bool isFamilies=true; std::vector conn; @@ -2300,7 +2326,6 @@ void MEDLoaderNS::writeUMeshesDirectly(const char *fileName, const std::vectorgetNumberOfNodes(),arr->getConstPointer()); - MEDfileClose(fid); } /*! @@ -2342,7 +2367,7 @@ void MEDLoaderNS::writeUMeshesPartitionDirectly(const char *fileName, const char gidsOfFamilies[fid].push_back(gid); } fid=0; - med_idt fid2=MEDfileOpen(fileName,MED_ACC_RDWR); + MEDFileUtilities::AutoFid fid2=MEDfileOpen(fileName,MED_ACC_RDWR); for(std::set::const_iterator it=familyIds.begin();it!=familyIds.end();it++,fid++) { int ngro=gidsOfFamilies[fid].size(); @@ -2354,7 +2379,6 @@ void MEDLoaderNS::writeUMeshesPartitionDirectly(const char *fileName, const char MEDLoaderBase::safeStrCpy(oss.str().c_str(),MED_NAME_SIZE,famName,MEDLoader::_TOO_LONG_STR); MEDfamilyCr(fid2,maa,famName,*it,ngro,groName); } - MEDfileClose(fid2); } /*! @@ -2367,7 +2391,7 @@ void MEDLoaderNS::appendNodeProfileField(const char *fileName, const ParaMEDMEM: med_float dt; INTERP_KERNEL::AutoPtr nommaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); MEDLoaderBase::safeStrCpy(f->getMesh()->getName(),MED_NAME_SIZE,nommaa,MEDLoader::_TOO_LONG_STR); - med_idt fid=appendFieldSimpleAtt(fileName,f,numdt,numo,dt); + MEDFileUtilities::AutoFid fid=appendFieldSimpleAtt(fileName,f,numdt,numo,dt); int nbOfNodes=f->getMesh()->getNumberOfNodes(); const double *pt=f->getArray()->getConstPointer(); INTERP_KERNEL::AutoPtr profile=new int[nbOfNodes]; @@ -2377,7 +2401,6 @@ void MEDLoaderNS::appendNodeProfileField(const char *fileName, const ParaMEDMEM: std::transform(thisMeshNodeIds,thisMeshNodeIds+nbOfNodes,(int *)profile,std::bind2nd(std::plus(),1)); MEDprofileWr(fid,profileName,nbOfNodes,profile); MEDfieldValueWithProfileWr(fid,f->getName(),numdt,numo,dt,MED_NODE,MED_NONE,MED_COMPACT_PFLMODE,profileName,MED_NO_LOCALIZATION,MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,nbOfNodes,(const unsigned char*)pt); - MEDfileClose(fid); } /*! @@ -2389,7 +2412,7 @@ void MEDLoaderNS::appendCellProfileField(const char *fileName, const ParaMEDMEM: med_int numdt,numo; med_float dt; int nbComp=f->getNumberOfComponents(); - med_idt fid=appendFieldSimpleAtt(fileName,f,numdt,numo,dt); + MEDFileUtilities::AutoFid fid=appendFieldSimpleAtt(fileName,f,numdt,numo,dt); std::list split; prepareCellFieldDoubleForWriting(f,thisMeshCellIdsPerType,split); const double *pt=f->getArray()->getConstPointer(); @@ -2409,7 +2432,6 @@ void MEDLoaderNS::appendCellProfileField(const char *fileName, const ParaMEDMEM: MED_NO_LOCALIZATION,MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,(*iter).getNbOfTuple(),(const unsigned char*)pt); pt+=(*iter).getNbOfTuple()*nbComp; } - MEDfileClose(fid); } void MEDLoaderNS::appendNodeElementProfileField(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, const int *thisMeshCellIdsPerType) @@ -2417,7 +2439,7 @@ void MEDLoaderNS::appendNodeElementProfileField(const char *fileName, const Para med_int numdt,numo; med_float dt; int nbComp=f->getNumberOfComponents(); - med_idt fid=appendFieldSimpleAtt(fileName,f,numdt,numo,dt); + MEDFileUtilities::AutoFid fid=appendFieldSimpleAtt(fileName,f,numdt,numo,dt); std::list split; prepareCellFieldDoubleForWriting(f,thisMeshCellIdsPerType,split); const double *pt=f->getArray()->getConstPointer(); @@ -2442,7 +2464,6 @@ void MEDLoaderNS::appendNodeElementProfileField(const char *fileName, const Para nbOfEntity,(const unsigned char*)pt); pt+=nbOfValues*nbComp; } - MEDfileClose(fid); } /*! @@ -2507,7 +2528,7 @@ void MEDLoaderNS::appendFieldDirectly(const char *fileName, const ParaMEDMEM::ME } //end renumbering int nbComp=f->getNumberOfComponents(); - med_idt fid=appendFieldSimpleAtt(fileName,f,numdt,numo,dt); + MEDFileUtilities::AutoFid fid=appendFieldSimpleAtt(fileName,f,numdt,numo,dt); const double *pt=f->getArray()->getConstPointer(); INTERP_KERNEL::AutoPtr nommaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); MEDLoaderBase::safeStrCpy(f->getMesh()->getName(),MED_NAME_SIZE,nommaa,MEDLoader::_TOO_LONG_STR); @@ -2624,7 +2645,6 @@ void MEDLoaderNS::appendFieldDirectly(const char *fileName, const ParaMEDMEM::ME default: throw INTERP_KERNEL::Exception("Not managed this type of FIELD !"); } - MEDfileClose(fid); if(renum) f->decrRef(); } diff --git a/src/MEDLoader/MEDLoader.hxx b/src/MEDLoader/MEDLoader.hxx index c81434af3..dcd3c0e61 100644 --- a/src/MEDLoader/MEDLoader.hxx +++ b/src/MEDLoader/MEDLoader.hxx @@ -107,7 +107,7 @@ class MEDLOADER_EXPORT MEDLoader static std::vector< std::pair > GetFieldIterations(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, const char *fieldName) throw(INTERP_KERNEL::Exception); static std::vector< std::pair > GetCellFieldIterations(const char *fileName, const char *meshName, const char *fieldName) throw(INTERP_KERNEL::Exception); static std::vector< std::pair > GetNodeFieldIterations(const char *fileName, const char *meshName, const char *fieldName) throw(INTERP_KERNEL::Exception); - static std::vector< std::pair< std::pair, double> > GetAllFieldIterations(const char *fileName, const char *meshName, const char *fieldName) throw(INTERP_KERNEL::Exception); + static std::vector< std::pair< std::pair, double> > GetAllFieldIterations(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception); static double GetTimeAttachedOnFieldIteration(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception); static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFamilies(const char *fileName, const char *meshName, int meshDimRelToMax, const std::vector& fams) throw(INTERP_KERNEL::Exception); static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromGroups(const char *fileName, const char *meshName, int meshDimRelToMax, const std::vector& grps) throw(INTERP_KERNEL::Exception);