Salome HOME
Merge branch 'agr/edf12447-catalyst'
authorCédric Aguerre <cedric.aguerre@edf.fr>
Mon, 14 Mar 2016 09:50:24 +0000 (10:50 +0100)
committerCédric Aguerre <cedric.aguerre@edf.fr>
Mon, 14 Mar 2016 09:50:24 +0000 (10:50 +0100)
CMakeLists.txt
src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.cxx
src/Plugins/MEDReader/Test/Baselines/testMEDReader20.png [new file with mode: 0644]
src/Plugins/MEDReader/Test/CMakeLists.txt
src/Plugins/MEDReader/Test/testMEDReader20.py [new file with mode: 0644]

index 1125184f9d9b77f1944f8725718348a524d2fa22..027dc6c7a1915016fc9aaea19efaabf7f883a28c 100644 (file)
@@ -38,7 +38,7 @@ SET(${PROJECT_NAME_UC}_MINOR_VERSION 0)
 SET(${PROJECT_NAME_UC}_PATCH_VERSION 0)
 SET(${PROJECT_NAME_UC}_VERSION
   ${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION})
-SET(${PROJECT_NAME_UC}_VERSION_DEV 0)
+SET(${PROJECT_NAME_UC}_VERSION_DEV 1)
 
 # Find KERNEL
 # ===========
index 111cc2beb0388bf12a788c033c1ba4c53962ac0f..ec2e362f17654b213cb5f725b3ce10bc6dd7091c 100644 (file)
@@ -197,6 +197,49 @@ ELGACmp::~ELGACmp()
 
 //=
 
+template<class T>
+class MEDFileVTKTraits
+{
+public:
+  typedef void VtkType;
+  typedef void MCType;
+};
+
+template<>
+class MEDFileVTKTraits<int>
+{
+public:
+  typedef vtkIntArray VtkType;
+  typedef MEDCoupling::DataArrayInt MCType;
+};
+
+template<>
+class MEDFileVTKTraits<double>
+{
+public:
+  typedef vtkDoubleArray VtkType;
+  typedef MEDCoupling::DataArrayDouble MCType;
+};
+
+template<class T>
+void AssignDataPointerToVTK(typename MEDFileVTKTraits<T>::VtkType *vtkTab, typename MEDFileVTKTraits<T>::MCType *mcTab, bool noCpyNumNodes)
+{
+  if(noCpyNumNodes)
+    vtkTab->SetArray(mcTab->getPointer(),mcTab->getNbOfElems(),1,vtkDataArrayTemplate<T>::VTK_DATA_ARRAY_FREE);
+ else
+   { vtkTab->SetArray(mcTab->getPointer(),mcTab->getNbOfElems(),0,vtkDataArrayTemplate<T>::VTK_DATA_ARRAY_FREE); mcTab->accessToMemArray().setSpecificDeallocator(0); }
+}
+
+// here copy is always assumed.
+template<class VTKT, class MCT>
+void AssignDataPointerOther(VTKT *vtkTab, MCT *mcTab, int nbElems)
+{
+  vtkTab->SetVoidArray(reinterpret_cast<unsigned char *>(mcTab->getPointer()),nbElems,0,VTKT::VTK_DATA_ARRAY_FREE);
+  mcTab->accessToMemArray().setSpecificDeallocator(0);
+}
+
+//=
+
 MEDFileFieldRepresentationLeavesArrays::MEDFileFieldRepresentationLeavesArrays():_id(-1)
 {
 }
@@ -275,7 +318,6 @@ bool MEDFileFieldRepresentationLeavesArrays::setStatus(bool status) const
 
 void MEDFileFieldRepresentationLeavesArrays::appendFields(const MEDTimeReq *tr, const MEDCoupling::MEDFileFieldGlobsReal *globs, const MEDCoupling::MEDMeshMultiLev *mml, const MEDCoupling::MEDFileMeshStruct *mst, vtkDataSet *ds) const
 {
-  const int VTK_DATA_ARRAY_FREE=vtkDataArrayTemplate<double>::VTK_DATA_ARRAY_FREE;
   const int VTK_DATA_ARRAY_DELETE=vtkDataArrayTemplate<double>::VTK_DATA_ARRAY_DELETE;
   tr->setNumberOfTS((operator->())->getNumberOfTS());
   tr->initIterator();
@@ -333,14 +375,7 @@ void MEDFileFieldRepresentationLeavesArrays::appendFields(const MEDTimeReq *tr,
           vtkd->SetNumberOfComponents(vd->getNumberOfComponents());
           for(int i=0;i<vd->getNumberOfComponents();i++)
             vtkd->SetComponentName(i,vd->getInfoOnComponent(i).c_str());
-          if(postProcessedArr!=crudeArr)
-            {
-              vtkd->SetArray(vd->getPointer(),vd->getNbOfElems(),0,VTK_DATA_ARRAY_FREE); vd->accessToMemArray().setSpecificDeallocator(0);
-            }
-          else
-            {
-              vtkd->SetArray(vd->getPointer(),vd->getNbOfElems(),1,VTK_DATA_ARRAY_FREE);
-            }
+          AssignDataPointerToVTK<double>(vtkd,vd,postProcessedArr==crudeArr);
           std::string name(tr->buildName(f1ts->getName()));
           vtkd->SetName(name.c_str());
           att->AddArray(vtkd);
@@ -413,14 +448,7 @@ void MEDFileFieldRepresentationLeavesArrays::appendFields(const MEDTimeReq *tr,
           vtkd->SetNumberOfComponents(vi->getNumberOfComponents());
           for(int i=0;i<vi->getNumberOfComponents();i++)
             vtkd->SetComponentName(i,vi->getVarOnComponent(i).c_str());
-          if(postProcessedArr!=crudeArr)
-            {
-              vtkd->SetArray(vi->getPointer(),vi->getNbOfElems(),0,VTK_DATA_ARRAY_FREE); vi->accessToMemArray().setSpecificDeallocator(0);
-            }
-          else
-            {
-              vtkd->SetArray(vi->getPointer(),vi->getNbOfElems(),1,VTK_DATA_ARRAY_FREE);
-            }
+          AssignDataPointerToVTK<int>(vtkd,vi,postProcessedArr==crudeArr);
           std::string name(tr->buildName(f1ts->getName()));
           vtkd->SetName(name.c_str());
           att->AddArray(vtkd);
@@ -634,7 +662,6 @@ void MEDFileFieldRepresentationLeaves::appendFields(const MEDTimeReq *tr, const
 
 vtkUnstructuredGrid *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInterpolationUnstructured(MEDUMeshMultiLev *mm) const
 {
-  const int VTK_DATA_ARRAY_FREE=vtkDataArrayTemplate<double>::VTK_DATA_ARRAY_FREE;
   DataArrayDouble *coordsMC(0);
   DataArrayByte *typesMC(0);
   DataArrayInt *cellLocationsMC(0),*cellsMC(0),*faceLocationsMC(0),*facesMC(0);
@@ -646,20 +673,20 @@ vtkUnstructuredGrid *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInt
   int nbOfCells(typesSafe->getNbOfElems());
   vtkUnstructuredGrid *ret(vtkUnstructuredGrid::New());
   vtkUnsignedCharArray *cellTypes(vtkUnsignedCharArray::New());
-  cellTypes->SetArray(reinterpret_cast<unsigned char *>(typesSafe->getPointer()),nbOfCells,0,VTK_DATA_ARRAY_FREE); typesSafe->accessToMemArray().setSpecificDeallocator(0);
+  AssignDataPointerOther<vtkUnsignedCharArray,DataArrayByte>(cellTypes,typesSafe,nbOfCells);
   vtkIdTypeArray *cellLocations(vtkIdTypeArray::New());
-  cellLocations->SetVoidArray(cellLocationsSafe->getPointer(),nbOfCells,0,VTK_DATA_ARRAY_FREE); cellLocationsSafe->accessToMemArray().setSpecificDeallocator(0);
+  AssignDataPointerOther<vtkIdTypeArray,DataArrayInt>(cellLocations,cellLocationsSafe,nbOfCells);
   vtkCellArray *cells(vtkCellArray::New());
   vtkIdTypeArray *cells2(vtkIdTypeArray::New());
-  cells2->SetVoidArray(cellsSafe->getPointer(),cellsSafe->getNbOfElems(),0,VTK_DATA_ARRAY_FREE); cellsSafe->accessToMemArray().setSpecificDeallocator(0);
+  AssignDataPointerOther<vtkIdTypeArray,DataArrayInt>(cells2,cellsSafe,cellsSafe->getNbOfElems());
   cells->SetCells(nbOfCells,cells2);
   cells2->Delete();
   if(faceLocationsMC!=0 && facesMC!=0)
     {
       vtkIdTypeArray *faces(vtkIdTypeArray::New());
-      faces->SetVoidArray(facesSafe->getPointer(),facesSafe->getNbOfElems(),0,VTK_DATA_ARRAY_FREE); facesSafe->accessToMemArray().setSpecificDeallocator(0);
+      AssignDataPointerOther<vtkIdTypeArray,DataArrayInt>(faces,facesSafe,facesSafe->getNbOfElems());
       vtkIdTypeArray *faceLocations(vtkIdTypeArray::New());
-      faceLocations->SetVoidArray(faceLocationsSafe->getPointer(),faceLocationsSafe->getNbOfElems(),0,VTK_DATA_ARRAY_FREE); faceLocationsSafe->accessToMemArray().setSpecificDeallocator(0);
+      AssignDataPointerOther<vtkIdTypeArray,DataArrayInt>(faceLocations,faceLocationsSafe,faceLocationsSafe->getNbOfElems());
       ret->SetCells(cellTypes,cellLocations,cells,faceLocations,faces);
       faceLocations->Delete();
       faces->Delete();
@@ -672,13 +699,7 @@ vtkUnstructuredGrid *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInt
   vtkPoints *pts(vtkPoints::New());
   vtkDoubleArray *pts2(vtkDoubleArray::New());
   pts2->SetNumberOfComponents(3);
-  if(!statusOfCoords)
-    {
-      pts2->SetArray(coordsSafe->getPointer(),coordsSafe->getNbOfElems(),0,VTK_DATA_ARRAY_FREE);
-      coordsSafe->accessToMemArray().setSpecificDeallocator(0);
-    }
-  else
-    pts2->SetArray(coordsSafe->getPointer(),coordsSafe->getNbOfElems(),1,VTK_DATA_ARRAY_FREE);
+  AssignDataPointerToVTK<double>(pts2,coordsSafe,statusOfCoords);
   pts->SetData(pts2);
   pts2->Delete();
   ret->SetPoints(pts);
@@ -689,7 +710,6 @@ vtkUnstructuredGrid *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInt
 
 vtkRectilinearGrid *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInterpolationCartesian(MEDCoupling::MEDCMeshMultiLev *mm) const
 {
-  const int VTK_DATA_ARRAY_FREE=vtkDataArrayTemplate<double>::VTK_DATA_ARRAY_FREE;
   bool isInternal;
   std::vector< DataArrayDouble * > arrs(mm->buildVTUArrays(isInternal));
   vtkDoubleArray *vtkTmp(0);
@@ -706,10 +726,7 @@ vtkRectilinearGrid *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInte
   ret->SetDimensions(sizePerAxe[0],sizePerAxe[1],sizePerAxe[2]);
   vtkTmp=vtkDoubleArray::New();
   vtkTmp->SetNumberOfComponents(1);
-  if(isInternal)
-    vtkTmp->SetArray(arrs[0]->getPointer(),arrs[0]->getNbOfElems(),1,VTK_DATA_ARRAY_FREE);
-  else
-    { vtkTmp->SetArray(arrs[0]->getPointer(),arrs[0]->getNbOfElems(),0,VTK_DATA_ARRAY_FREE); arrs[0]->accessToMemArray().setSpecificDeallocator(0); }
+  AssignDataPointerToVTK<double>(vtkTmp,arrs[0],isInternal);
   ret->SetXCoordinates(vtkTmp);
   vtkTmp->Delete();
   arrs[0]->decrRef();
@@ -717,10 +734,7 @@ vtkRectilinearGrid *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInte
     {
       vtkTmp=vtkDoubleArray::New();
       vtkTmp->SetNumberOfComponents(1);
-      if(isInternal)
-        vtkTmp->SetArray(arrs[1]->getPointer(),arrs[1]->getNbOfElems(),1,VTK_DATA_ARRAY_FREE);
-      else
-        { vtkTmp->SetArray(arrs[1]->getPointer(),arrs[1]->getNbOfElems(),0,VTK_DATA_ARRAY_FREE); arrs[1]->accessToMemArray().setSpecificDeallocator(0); }
+      AssignDataPointerToVTK<double>(vtkTmp,arrs[1],isInternal);
       ret->SetYCoordinates(vtkTmp);
       vtkTmp->Delete();
       arrs[1]->decrRef();
@@ -729,10 +743,7 @@ vtkRectilinearGrid *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInte
     {
       vtkTmp=vtkDoubleArray::New();
       vtkTmp->SetNumberOfComponents(1);
-      if(isInternal)
-        vtkTmp->SetArray(arrs[2]->getPointer(),arrs[2]->getNbOfElems(),1,VTK_DATA_ARRAY_FREE);
-      else
-        { vtkTmp->SetArray(arrs[2]->getPointer(),arrs[2]->getNbOfElems(),0,VTK_DATA_ARRAY_FREE); arrs[2]->accessToMemArray().setSpecificDeallocator(0); }
+      AssignDataPointerToVTK<double>(vtkTmp,arrs[2],isInternal);
       ret->SetZCoordinates(vtkTmp);
       vtkTmp->Delete();
       arrs[2]->decrRef();
@@ -742,7 +753,6 @@ vtkRectilinearGrid *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInte
 
 vtkStructuredGrid *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInterpolationCurveLinear(MEDCoupling::MEDCurveLinearMeshMultiLev *mm) const
 {
-  const int VTK_DATA_ARRAY_FREE=vtkDataArrayTemplate<double>::VTK_DATA_ARRAY_FREE;
   int meshStr[3]={1,1,1};
   DataArrayDouble *coords(0);
   std::vector<int> nodeStrct;
@@ -761,17 +771,11 @@ vtkStructuredGrid *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInter
   vtkDoubleArray *da(vtkDoubleArray::New());
   da->SetNumberOfComponents(3);
   if(coords->getNumberOfComponents()==3)
-    {
-      if(isInternal)
-        da->SetArray(coords->getPointer(),coords->getNbOfElems(),1,VTK_DATA_ARRAY_FREE);//VTK has not the ownership of double * because MEDLoader main struct has it !
-      else
-        { da->SetArray(coords->getPointer(),coords->getNbOfElems(),0,VTK_DATA_ARRAY_FREE); coords->accessToMemArray().setSpecificDeallocator(0); }
-    }
+    AssignDataPointerToVTK<double>(da,coords,isInternal);//if isIntenal==True VTK has not the ownership of double * because MEDLoader main struct has it !
   else
     {
       MCAuto<DataArrayDouble> coords2(coords->changeNbOfComponents(3,0.));
-      da->SetArray(coords2->getPointer(),coords2->getNbOfElems(),0,VTK_DATA_ARRAY_FREE);//let VTK deal with double *
-      coords2->accessToMemArray().setSpecificDeallocator(0);
+      AssignDataPointerToVTK<double>(da,coords2,false);//let VTK deal with double *
     }
   coords->decrRef();
   vtkPoints *points=vtkPoints::New();
@@ -784,7 +788,6 @@ vtkStructuredGrid *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInter
  
 vtkDataSet *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInterpolation(const MEDTimeReq *tr, const MEDFileFieldGlobsReal *globs, const MEDCoupling::MEDFileMeshes *meshes) const
 {
-  const int VTK_DATA_ARRAY_FREE=vtkDataArrayTemplate<double>::VTK_DATA_ARRAY_FREE;
   vtkDataSet *ret(0);
   //_fsp->isDataSetSupportEqualToThePreviousOne(i,globs);
   MCAuto<MEDMeshMultiLev> mml(_fsp->buildFromScratchDataSetSupport(0,globs));//0=timestep Id. Make the hypothesis that support does not change 
@@ -829,10 +832,7 @@ vtkDataSet *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInterpolatio
       vtkIntArray *vtkTab(vtkIntArray::New());
       vtkTab->SetNumberOfComponents(1);
       vtkTab->SetName(MEDFileFieldRepresentationLeavesArrays::FAMILY_ID_CELL_NAME);
-      if(noCpyFamCells)
-        vtkTab->SetArray(famCells->getPointer(),famCells->getNbOfElems(),1,VTK_DATA_ARRAY_FREE);
-      else
-        { vtkTab->SetArray(famCells->getPointer(),famCells->getNbOfElems(),0,VTK_DATA_ARRAY_FREE); famCells->accessToMemArray().setSpecificDeallocator(0); }
+      AssignDataPointerToVTK<int>(vtkTab,famCells,noCpyFamCells);
       ret->GetCellData()->AddArray(vtkTab);
       vtkTab->Delete();
       famCells->decrRef();
@@ -843,10 +843,7 @@ vtkDataSet *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInterpolatio
       vtkIntArray *vtkTab(vtkIntArray::New());
       vtkTab->SetNumberOfComponents(1);
       vtkTab->SetName(MEDFileFieldRepresentationLeavesArrays::NUM_ID_CELL_NAME);
-      if(noCpyNumCells)
-        vtkTab->SetArray(numCells->getPointer(),numCells->getNbOfElems(),1,VTK_DATA_ARRAY_FREE);
-      else
-        { vtkTab->SetArray(numCells->getPointer(),numCells->getNbOfElems(),0,VTK_DATA_ARRAY_FREE); numCells->accessToMemArray().setSpecificDeallocator(0); }
+      AssignDataPointerToVTK<int>(vtkTab,numCells,noCpyNumCells);
       ret->GetCellData()->AddArray(vtkTab);
       vtkTab->Delete();
       numCells->decrRef();
@@ -860,10 +857,7 @@ vtkDataSet *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInterpolatio
       vtkIntArray *vtkTab(vtkIntArray::New());
       vtkTab->SetNumberOfComponents(1);
       vtkTab->SetName(MEDFileFieldRepresentationLeavesArrays::FAMILY_ID_NODE_NAME);
-      if(noCpyFamNodes)
-        vtkTab->SetArray(famNodes->getPointer(),famNodes->getNbOfElems(),1,VTK_DATA_ARRAY_FREE);
-      else
-        { vtkTab->SetArray(famNodes->getPointer(),famNodes->getNbOfElems(),0,VTK_DATA_ARRAY_FREE); famNodes->accessToMemArray().setSpecificDeallocator(0); }
+      AssignDataPointerToVTK<int>(vtkTab,famNodes,noCpyFamNodes);
       ret->GetPointData()->AddArray(vtkTab);
       vtkTab->Delete();
       famNodes->decrRef();
@@ -874,10 +868,7 @@ vtkDataSet *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInterpolatio
       vtkIntArray *vtkTab(vtkIntArray::New());
       vtkTab->SetNumberOfComponents(1);
       vtkTab->SetName(MEDFileFieldRepresentationLeavesArrays::NUM_ID_NODE_NAME);
-      if(noCpyNumNodes)
-        vtkTab->SetArray(numNodes->getPointer(),numNodes->getNbOfElems(),1,VTK_DATA_ARRAY_FREE);
-      else
-        { vtkTab->SetArray(numNodes->getPointer(),numNodes->getNbOfElems(),0,VTK_DATA_ARRAY_FREE); numNodes->accessToMemArray().setSpecificDeallocator(0); }
+      AssignDataPointerToVTK<int>(vtkTab,numNodes,noCpyNumNodes);
       ret->GetPointData()->AddArray(vtkTab);
       vtkTab->Delete();
       numNodes->decrRef();
@@ -889,8 +880,9 @@ vtkDataSet *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInterpolatio
       vtkIntArray *vtkTab(vtkIntArray::New());
       vtkTab->SetNumberOfComponents(1);
       vtkTab->SetName(MEDFileFieldRepresentationLeavesArrays::GLOBAL_NODE_ID_NAME);
-      vtkTab->SetArray(gni->getPointer(),gni->getNbOfElems(),0,VTK_DATA_ARRAY_FREE);
-      gni->accessToMemArray().setSpecificDeallocator(0);
+      AssignDataPointerToVTK<int>(vtkTab,gni,false);
+      ret->GetPointData()->AddArray(vtkTab);
+      vtkTab->Delete();
       gni->decrRef();
     }
   return ret;
diff --git a/src/Plugins/MEDReader/Test/Baselines/testMEDReader20.png b/src/Plugins/MEDReader/Test/Baselines/testMEDReader20.png
new file mode 100644 (file)
index 0000000..c27a45f
Binary files /dev/null and b/src/Plugins/MEDReader/Test/Baselines/testMEDReader20.png differ
index 60763209c324ea44a5bb08c2c32274630b545bc9..803fe6d0d316ecd90434138ca25a50ac5620dcaf 100644 (file)
@@ -17,7 +17,7 @@
 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
 
-SET(TEST_NUMBERS 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19)
+SET(TEST_NUMBERS 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20)
 
 SET(TEST_INSTALL_DIRECTORY ${SALOME_INSTALL_SCRIPT_SCRIPTS}/test/MEDReader)
 SET(BASELINES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Baselines")
diff --git a/src/Plugins/MEDReader/Test/testMEDReader20.py b/src/Plugins/MEDReader/Test/testMEDReader20.py
new file mode 100644 (file)
index 0000000..a63f90f
--- /dev/null
@@ -0,0 +1,170 @@
+#  -*- coding: iso-8859-1 -*-
+# Copyright (C) 2016  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
+# License as published by the Free Software Foundation; either
+# 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
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+# Author : Anthony Geay (EDF R&D)
+
+# non regression test that emulates https://ageay@git.salome-platform.org/gitpub/samples/datafiles.git Med/ResOK_0000.med
+# This test point error during commit efd9331a9455785d0f04b75 in PARAVIS
+
+from MEDLoader import *
+fname="testMEDReader20.med"
+png="testMEDReader20.png"
+nb=10
+arrX=DataArrayDouble(nb+1) ; arrX.iota()
+arrY=DataArrayDouble([0.,1.])
+m=MEDCouplingCMesh() ; m.setCoords(arrX,arrY) ; m=m.buildUnstructured(); m.setName("mesh") ; m.simplexize(0)
+mm=MEDFileUMesh() ; mm[0]=m
+m1=m.computeSkin() ; mm[-1]=m1
+#
+f0=DataArrayInt(m1.getNumberOfCells()) ; f0.iota() ; mm.setFamilyFieldArr(-1,f0)
+f1=DataArrayInt(m1.getNumberOfNodes()) ; f1.iota() ; mm.setFamilyFieldArr(1,f1) # <- very important the bug can be shown here
+#
+nbCells=m1.getNumberOfCells() ; nbNodes=m.getNumberOfNodes()
+mm.write(fname,2)
+for i in range(5):
+    f=MEDCouplingFieldDouble(ON_CELLS) ; f.setMesh(m)
+    f.setName("Field")
+    arr=DataArrayInt(2*nb) ; arr.iota(i) ; arr%=nb ; arr=arr.convertToDblArr()
+    f.setArray(arr) ; f.setTime(float(i),i,0)
+    WriteFieldUsingAlreadyWrittenMesh(fname,f)
+    #
+    f=MEDCouplingFieldDouble(ON_CELLS) ; f.setMesh(m1)
+    f.setName("Field")
+    arr=DataArrayInt(nbCells) ; arr.iota(i) ; arr%=nbCells ; arr=arr.convertToDblArr()
+    f.setArray(arr) ; f.setTime(float(i),i,0)
+    WriteFieldUsingAlreadyWrittenMesh(fname,f)
+    #
+    f=MEDCouplingFieldDouble(ON_NODES) ; f.setMesh(m)
+    f.setName("FieldNode")
+    arr=DataArrayDouble(nbNodes) ; arr[:]=float(i)
+    f.setArray(arr) ; f.setTime(float(i),i,0)
+    WriteFieldUsingAlreadyWrittenMesh(fname,f)
+    pass
+#####################
+from paraview.simple import *
+#### disable automatic camera reset on 'Show'
+paraview.simple._DisableFirstRenderCameraReset()
+
+# create a new 'MED Reader'
+testMEDReader20med = MEDReader(FileName=fname)
+testMEDReader20med.AllArrays = ['TS0/mesh/ComSup0/Field@@][@@P0']
+testMEDReader20med.AllTimeSteps = ['0000', '0001', '0002', '0003', '0004']
+
+# get animation scene
+animationScene1 = GetAnimationScene()
+
+# update animation scene based on data timesteps
+animationScene1.UpdateAnimationUsingDataTimeSteps()
+
+# get active view
+renderView1 = GetActiveViewOrCreate('RenderView')
+# uncomment following to set a specific view size
+# renderView1.ViewSize = [610, 477]
+
+# show data in view
+testMEDReader20medDisplay = Show(testMEDReader20med, renderView1)
+# trace defaults for the display properties.
+testMEDReader20medDisplay.ColorArrayName = [None, '']
+testMEDReader20medDisplay.GlyphType = 'Arrow'
+testMEDReader20medDisplay.ScalarOpacityUnitDistance = 4.664739046219201
+testMEDReader20medDisplay.SelectUncertaintyArray = [None, '']
+testMEDReader20medDisplay.UncertaintyTransferFunction = 'PiecewiseFunction'
+testMEDReader20medDisplay.OpacityArray = [None, '']
+testMEDReader20medDisplay.RadiusArray = [None, '']
+testMEDReader20medDisplay.RadiusRange = [0.0, 10.0]
+testMEDReader20medDisplay.ConstantRadius = 10.0
+testMEDReader20medDisplay.PointSpriteDefaultsInitialized = 1
+testMEDReader20medDisplay.SelectInputVectors = [None, '']
+testMEDReader20medDisplay.WriteLog = ''
+
+# reset view to fit data
+renderView1.ResetCamera()
+
+#changing interaction mode based on data extents
+renderView1.InteractionMode = '2D'
+renderView1.CameraPosition = [5.0, 0.5, 10000.0]
+renderView1.CameraFocalPoint = [5.0, 0.5, 0.0]
+
+# set scalar coloring
+ColorBy(testMEDReader20medDisplay, ('FIELD', 'vtkBlockColors'))
+
+# show color bar/color legend
+testMEDReader20medDisplay.SetScalarBarVisibility(renderView1, True)
+
+# get color transfer function/color map for 'vtkBlockColors'
+vtkBlockColorsLUT = GetColorTransferFunction('vtkBlockColors')
+
+# get opacity transfer function/opacity map for 'vtkBlockColors'
+vtkBlockColorsPWF = GetOpacityTransferFunction('vtkBlockColors')
+
+# set scalar coloring
+ColorBy(testMEDReader20medDisplay, ('CELLS', 'Field'))
+
+# rescale color and/or opacity maps used to include current data range
+testMEDReader20medDisplay.RescaleTransferFunctionToDataRange(True)
+
+# show color bar/color legend
+testMEDReader20medDisplay.SetScalarBarVisibility(renderView1, True)
+
+# get color transfer function/color map for 'Field'
+fieldLUT = GetColorTransferFunction('Field')
+
+# get opacity transfer function/opacity map for 'Field'
+fieldPWF = GetOpacityTransferFunction('Field')
+
+animationScene1.GoToNext() # <- very important to see the bug play with time steps...
+animationScene1.GoToNext()
+animationScene1.GoToNext()
+animationScene1.GoToNext()
+animationScene1.GoToPrevious()
+animationScene1.GoToPrevious()
+
+# current camera placement for renderView1
+renderView1.InteractionMode = '2D'
+renderView1.CameraPosition = [5.0, 0.5, 10000.0]
+renderView1.CameraFocalPoint = [5.0, 0.5, 0.0]
+renderView1.CameraParallelScale = 5.024937810560445
+
+#
+
+renderView1.ViewSize =[300,300]
+Render()
+#WriteImage(png)
+
+#### saving camera placements for all active views
+
+# current camera placement for renderView1
+renderView1.InteractionMode = '2D'
+renderView1.CameraPosition = [5.0, 0.5, 10000.0]
+renderView1.CameraFocalPoint = [5.0, 0.5, 0.0]
+renderView1.CameraParallelScale = 5.024937810560445
+# compare with baseline image
+import os
+import sys
+try:
+  baselineIndex = sys.argv.index('-B')+1
+  baselinePath = sys.argv[baselineIndex]
+except:
+  print "Could not get baseline directory. Test failed."
+  exit(1)
+baseline_file = os.path.join(baselinePath,png)
+import vtk.test.Testing
+vtk.test.Testing.VTK_TEMP_DIR = vtk.util.misc.vtkGetTempDir()
+vtk.test.Testing.compareImage(GetActiveView().GetRenderWindow(), baseline_file, threshold=25)
+vtk.test.Testing.interact()