Salome HOME
Reverted to SALOME current CMake build procedure.
[tools/medcoupling.git] / src / MEDLoader / MEDFileFieldOverView.cxx
index bd1ac3fa1f5d5a5943d55b8146c8c81bdc66294d..4f0367cb2ff9df1242bfc76e1b2be05b23207ffe 100644 (file)
@@ -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
@@ -22,6 +22,7 @@
 #include "MEDFileField.hxx"
 #include "MEDFileMesh.hxx"
 
+#include "MEDCouplingFieldDiscretization.hxx"
 #include "CellModel.hxx"
 
 using namespace ParaMEDMEM;
@@ -1664,7 +1665,7 @@ void MEDFileField1TSStructItem2::checkInRange(int nbOfEntity, int nip, const MED
   if(_pfl->getName().empty())
     {
       if(nbOfEntity!=(_start_end.second-_start_end.first)/nip)
-        throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::checkInRange : Mismatch between number of entities and size of node field !");
+        throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::checkInRange : Mismatch between number of entities and size of field !");
       return ;
     }
   else
@@ -1756,7 +1757,7 @@ MEDFileField1TSStructItem2 MEDFileField1TSStructItem2::BuildAggregationOf(const
     }
   else
     {
-      arr->setName(arrs[0]->getName());
+      arr->setName(NEWLY_CREATED_PFL_NAME);
       std::pair<int,int> p(0,oldNbTuples);
       std::string a,b;
       MEDFileField1TSStructItem2 ret(gt,p,a,b);
@@ -1920,18 +1921,23 @@ bool MEDFileField1TSStructItem::isCompatibleWithNodesDiscr(const MEDFileField1TS
   int theFirstLevFull;
   bool ret0=isFullyOnOneLev(meshSt,theFirstLevFull);
   const MEDFileField1TSStructItem2& otherNodeIt(other._items[0]);
+  int nbOfNodes(meshSt->getNumberOfNodes());
   if(otherNodeIt.getPflName().empty())
     {//on all nodes
       if(!ret0)
         return false;
-      return theFirstLevFull==0;
+      std::vector<bool> nodesFetched(nbOfNodes,false);
+      meshSt->getTheMesh()->whichAreNodesFetched(*this,globs,nodesFetched);
+      if(std::find(nodesFetched.begin(),nodesFetched.end(),false)==nodesFetched.end())
+        return theFirstLevFull==0;
+      else
+        return false;
     }
   else
     {
       const DataArrayInt *pfl=globs->getProfile(otherNodeIt.getPflName().c_str());
       MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cpyPfl(pfl->deepCpy());
       cpyPfl->sort();
-      int nbOfNodes(meshSt->getNumberOfNodes());
       if(cpyPfl->isIdentity() && cpyPfl->getNumberOfTuples()==nbOfNodes)
         {//on all nodes also !
           if(!ret0)
@@ -2037,7 +2043,6 @@ std::vector<INTERP_KERNEL::NormalizedCellType> MEDFileField1TSStructItem::getGeo
 
 MEDFileField1TSStructItem MEDFileField1TSStructItem::BuildItemFrom(const MEDFileAnyTypeField1TS *ref, const MEDFileMeshStruct *meshSt)
 {
-  TypeOfField atype;
   std::vector< MEDFileField1TSStructItem2 > anItems;
   //
   std::vector< std::vector<std::string> > pfls,locs;
@@ -2047,17 +2052,15 @@ MEDFileField1TSStructItem MEDFileField1TSStructItem::BuildItemFrom(const MEDFile
   std::size_t nbOfGeoTypes(geoTypes.size());
   if(nbOfGeoTypes==0)
     throw INTERP_KERNEL::Exception("MEDFileField1TSStruct : not null by empty ref  !");
-  bool isFirst=true;
+  if(typesF[0].empty())
+    throw INTERP_KERNEL::Exception("MEDFileField1TSStruct : internal error #1 bis !");
+  TypeOfField atype(typesF[0][0]);
   for(std::size_t i=0;i<nbOfGeoTypes;i++)
     {
       std::size_t sz=typesF[i].size();
       if(strtEnds[i].size()<1 || sz<1 || pfls[i].size()<1)
         throw INTERP_KERNEL::Exception("MEDFileField1TSStruct : internal error #1 !");
       //
-      if(isFirst)
-        atype=typesF[i][0];
-      isFirst=false;
-      //
       for(std::size_t j=0;j<sz;j++)
         {
           if(atype==typesF[i][j])
@@ -2067,7 +2070,15 @@ MEDFileField1TSStructItem MEDFileField1TSStructItem::BuildItemFrom(const MEDFile
         }
     }
   MEDFileField1TSStructItem ret(atype,anItems);
-  ret.checkWithMeshStruct(meshSt,ref);
+  try
+    {
+      ret.checkWithMeshStruct(meshSt,ref);
+    }
+  catch(INTERP_KERNEL::Exception& e)
+    {
+      std::ostringstream oss; oss << e.what() << " (" << MEDCouplingFieldDiscretization::GetTypeOfFieldRepr(ret.getType()) << ")";
+      throw INTERP_KERNEL::Exception(oss.str().c_str());
+    }
   return ret;
 }
 
@@ -2300,8 +2311,17 @@ MEDFileFastCellSupportComparator::MEDFileFastCellSupportComparator(const MEDFile
   for(int i=0;i<nbPts;i++)
     {
       MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> elt=ref->getTimeStepAtPos(i);
-      _f1ts_cmps[i]=MEDFileField1TSStruct::New(elt,_mesh_comp);
-      _f1ts_cmps[i]->checkWithMeshStruct(_mesh_comp,elt);
+      try
+        {
+          _f1ts_cmps[i]=MEDFileField1TSStruct::New(elt,_mesh_comp);
+          _f1ts_cmps[i]->checkWithMeshStruct(_mesh_comp,elt);
+        }
+      catch(INTERP_KERNEL::Exception& e)
+        {
+          std::ostringstream oss; oss << "Problem in field with name \"" << ref->getName() << "\"" << std::endl;
+          oss << "More Details : " << e.what();
+          throw INTERP_KERNEL::Exception(oss.str().c_str());
+        }
     }
 }