From 0b251bcdb898e6a65846670dc9d74e7f404d7990 Mon Sep 17 00:00:00 2001 From: ageay Date: Tue, 5 Apr 2011 14:30:58 +0000 Subject: [PATCH] Enhancement of msg on invalide meshDimRelTo in field reading. --- src/MEDLoader/MEDLoader.cxx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/MEDLoader/MEDLoader.cxx b/src/MEDLoader/MEDLoader.cxx index 3c049964e..5ecda40c9 100644 --- a/src/MEDLoader/MEDLoader.cxx +++ b/src/MEDLoader/MEDLoader.cxx @@ -25,6 +25,7 @@ #include "MEDCouplingMemArray.hxx" #include "MEDCouplingFieldDouble.hxx" #include "MEDCouplingGaussLocalization.hxx" +#include "MEDCouplingAutoRefCountObjectPtr.hxx" #include "InterpKernelAutoPtr.hxx" @@ -1790,6 +1791,16 @@ ParaMEDMEM::MEDCouplingFieldDouble *MEDLoaderNS::readFieldDoubleLev2(const char { if(typeOfOutField==ON_CELLS || typeOfOutField==ON_GAUSS_PT || typeOfOutField==ON_GAUSS_NE) MEDLoaderNS::keepSpecifiedMeshDim(fieldPerCellType,meshDim); + if(fieldPerCellType.empty()) + { + std::ostringstream oss; oss << "Error on reading file \"" << fileName << "\" meshName=\"" << mesh->getName(); + oss << std::endl << "FieldName=\"" << fieldName << "\" (iteration=" << iteration << ",order=" << order << ")" << std::endl; + if(typeOfOutField==ON_CELLS || typeOfOutField==ON_GAUSS_PT || typeOfOutField==ON_GAUSS_NE) + oss << "Request for cell field, maybe by changing meshDimRelToMax ?"; + else + oss << "Request for a node field, maybe it is a cell field instead ?"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } //for profiles ParaMEDMEM::MEDCouplingUMesh *newMesh=0; std::string mName(mesh->getName()); @@ -1907,11 +1918,10 @@ ParaMEDMEM::MEDCouplingFieldDouble *MEDLoaderNS::readFieldDoubleLev1(const char oss << "Request for a node field, maybe it is a cell field instead ?"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - ParaMEDMEM::MEDCouplingUMesh *mesh=readUMeshFromFileLev1(fileName,meshName,meshDimRelToMax,familiesToKeep,typesToKeep,meshDim,cellRenum); + MEDCouplingAutoRefCountObjectPtr mesh=readUMeshFromFileLev1(fileName,meshName,meshDimRelToMax,familiesToKeep,typesToKeep,meshDim,cellRenum); ParaMEDMEM::MEDCouplingFieldDouble *ret=readFieldDoubleLev2(fileName,typeOfOutField,meshDim,cellRenum,mesh,infos,fieldName,iteration,order,time,fieldPerCellType); if(cellRenum) mesh->renumberCells(cellRenum,true); - mesh->decrRef(); //clean-up delete [] cellRenum; releaseMEDFileCoreFrmt(fieldPerCellType); -- 2.39.2