]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Enhancement of msg on invalide meshDimRelTo in field reading.
authorageay <ageay>
Tue, 5 Apr 2011 14:30:58 +0000 (14:30 +0000)
committerageay <ageay>
Tue, 5 Apr 2011 14:30:58 +0000 (14:30 +0000)
src/MEDLoader/MEDLoader.cxx

index 3c049964edb129022bab85a3b264bb609da7e4cc..5ecda40c98823419d2dd8eee3b8ca346428f1f55 100644 (file)
@@ -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<MEDLoader::MEDFieldDoublePerCellType>(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<ParaMEDMEM::MEDCouplingUMesh> 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<MEDLoader::MEDFieldDoublePerCellType>(fieldPerCellType);