Salome HOME
Merge branch 'origin/akl/22533'
[modules/paravis.git] / src / Plugins / MEDReader / IO / MEDFileFieldRepresentationTree.cxx
index a6c603c2e1774ff81d99cca20db9554f0eb53460..02838b6cc69d106270ee955e51587d3086b5dd91 100644 (file)
@@ -3,7 +3,7 @@
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -1311,44 +1311,57 @@ void MEDFileFieldRepresentationTree::AppendFieldFromMeshes(const ParaMEDMEM::MED
   for(int i=0;i<ms->getNumberOfMeshes();i++)
     {
       MEDFileMesh *mm(ms->getMeshAtPos(i));
-      MEDFileUMesh *mmu(dynamic_cast<MEDFileUMesh *>(mm));
-      if(!mmu)
-        continue;
       std::vector<int> levs(mm->getNonEmptyLevels());
       ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::MEDFileField1TS> f1tsMultiLev(ParaMEDMEM::MEDFileField1TS::New());
-      for(std::vector<int>::const_iterator it=levs.begin();it!=levs.end();it++)
-        {
-          std::vector<INTERP_KERNEL::NormalizedCellType> gts(mmu->getGeoTypesAtLevel(*it));
-          for(std::vector<INTERP_KERNEL::NormalizedCellType>::const_iterator gt=gts.begin();gt!=gts.end();gt++)
-            {
-              ParaMEDMEM::MEDCouplingMesh *m(mmu->getDirectUndergroundSingleGeoTypeMesh(*gt));
-              ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::MEDCouplingFieldDouble> f(ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS));
-              f->setMesh(m);
-              ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::DataArrayDouble> arr(ParaMEDMEM::DataArrayDouble::New()); arr->alloc(f->getNumberOfTuplesExpected());
-             arr->setInfoOnComponent(0,std::string(COMPO_STR_TO_LOCATE_MESH_DA));
-              arr->iota();
-              f->setArray(arr);
-              f->setName(mm->getName());
-              f1tsMultiLev->setFieldNoProfileSBT(f);
-            }
-        }
-      if(levs.empty())
-        {
-          std::vector<int> levsExt(mm->getNonEmptyLevelsExt());
-          if(levsExt.size()==levs.size()+1)
-            {
-              ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::MEDCouplingMesh> m(mm->getGenMeshAtLevel(1));
-              ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::MEDCouplingFieldDouble> f(ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_NODES));
-              f->setMesh(m);
-              ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::DataArrayDouble> arr(ParaMEDMEM::DataArrayDouble::New()); arr->alloc(m->getNumberOfNodes());
-             arr->setInfoOnComponent(0,std::string(COMPO_STR_TO_LOCATE_MESH_DA));
-              arr->iota(); f->setArray(arr);
-              f->setName(mm->getName());
-              f1tsMultiLev->setFieldNoProfileSBT(f);
-            }
-          else
-            continue;
-        }
+      MEDFileUMesh *mmu(dynamic_cast<MEDFileUMesh *>(mm));
+      if(mmu)
+       {
+         for(std::vector<int>::const_iterator it=levs.begin();it!=levs.end();it++)
+           {
+             std::vector<INTERP_KERNEL::NormalizedCellType> gts(mmu->getGeoTypesAtLevel(*it));
+             for(std::vector<INTERP_KERNEL::NormalizedCellType>::const_iterator gt=gts.begin();gt!=gts.end();gt++)
+               {
+                 ParaMEDMEM::MEDCouplingMesh *m(mmu->getDirectUndergroundSingleGeoTypeMesh(*gt));
+                 ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::MEDCouplingFieldDouble> f(ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS));
+                 f->setMesh(m);
+                 ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::DataArrayDouble> arr(ParaMEDMEM::DataArrayDouble::New()); arr->alloc(f->getNumberOfTuplesExpected());
+                 arr->setInfoOnComponent(0,std::string(COMPO_STR_TO_LOCATE_MESH_DA));
+                 arr->iota();
+                 f->setArray(arr);
+                 f->setName(mm->getName());
+                 f1tsMultiLev->setFieldNoProfileSBT(f);
+               }
+           }
+         if(levs.empty())
+           {
+             std::vector<int> levsExt(mm->getNonEmptyLevelsExt());
+             if(levsExt.size()==levs.size()+1)
+               {
+                 ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::MEDCouplingMesh> m(mm->getGenMeshAtLevel(1));
+                 ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::MEDCouplingFieldDouble> f(ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_NODES));
+                 f->setMesh(m);
+                 ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::DataArrayDouble> arr(ParaMEDMEM::DataArrayDouble::New()); arr->alloc(m->getNumberOfNodes());
+                 arr->setInfoOnComponent(0,std::string(COMPO_STR_TO_LOCATE_MESH_DA));
+                 arr->iota(); f->setArray(arr);
+                 f->setName(mm->getName());
+                 f1tsMultiLev->setFieldNoProfileSBT(f);
+               }
+             else
+               continue;
+           }
+       }
+      else
+       {
+         ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::MEDCouplingMesh> m(mm->getGenMeshAtLevel(0));
+         ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::MEDCouplingFieldDouble> f(ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS));
+         f->setMesh(m);
+         ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::DataArrayDouble> arr(ParaMEDMEM::DataArrayDouble::New()); arr->alloc(f->getNumberOfTuplesExpected());
+         arr->setInfoOnComponent(0,std::string(COMPO_STR_TO_LOCATE_MESH_DA));
+         arr->iota();
+         f->setArray(arr);
+         f->setName(mm->getName());
+         f1tsMultiLev->setFieldNoProfileSBT(f);
+       }
       //
       ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr<ParaMEDMEM::MEDFileFieldMultiTS> fmtsMultiLev(ParaMEDMEM::MEDFileFieldMultiTS::New());
       fmtsMultiLev->pushBackTimeStep(f1tsMultiLev);