From a4e89b15c2faff6341ab9c3d78abc6213de10fee Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Thu, 25 Feb 2016 10:07:03 +0100 Subject: [PATCH] Correction of bug seen thanks to ResOK_0000.med file in samples. --- .../IO/MEDFileFieldRepresentationTree.cxx | 2 +- .../Test/Baselines/testMEDReader20.png | Bin 0 -> 5000 bytes src/Plugins/MEDReader/Test/CMakeLists.txt | 2 +- src/Plugins/MEDReader/Test/testMEDReader20.py | 170 ++++++++++++++++++ 4 files changed, 172 insertions(+), 2 deletions(-) create mode 100644 src/Plugins/MEDReader/Test/Baselines/testMEDReader20.png create mode 100644 src/Plugins/MEDReader/Test/testMEDReader20.py diff --git a/src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.cxx b/src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.cxx index 0ad9586b..10064334 100644 --- a/src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.cxx +++ b/src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.cxx @@ -856,7 +856,7 @@ vtkDataSet *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInterpolatio vtkIntArray *vtkTab(vtkIntArray::New()); vtkTab->SetNumberOfComponents(1); vtkTab->SetName(MEDFileFieldRepresentationLeavesArrays::FAMILY_ID_NODE_NAME); - AssignDataPointerToVTK(vtkTab,famNodes,noCpyNumNodes); + AssignDataPointerToVTK(vtkTab,famNodes,noCpyFamNodes); ret->GetPointData()->AddArray(vtkTab); vtkTab->Delete(); famNodes->decrRef(); diff --git a/src/Plugins/MEDReader/Test/Baselines/testMEDReader20.png b/src/Plugins/MEDReader/Test/Baselines/testMEDReader20.png new file mode 100644 index 0000000000000000000000000000000000000000..c27a45f9f82b206bb05b0e82ed6d959705fec799 GIT binary patch literal 5000 zcmbuD2T)Vrv&Sz*et<{|MFd15RVe~eBnXH^Lhrpu2LUO9Gzm=gTL&vFhBtSqAD-@K+DtQ*Oa}3(NfAkTjxE8zf&-Wf*AH{2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23_RqpnI#mEKN|zxx6Jo zs5%wLX!fVtw|q3DNr_ne093n`>ZbG^u@vfp7o!T!VhZp0Yw6(g3NfP@4L-At^%Roj zeh-cJ@?O{dL$RR=9b7bCxBGxQ&j9PzhlZ`1wO)R|RW%#lP?*Qe^0Rv@D{Z&~AR~8o zcU9$nBK){G&0&@NitGj+FI`=aramb{y8a?g>Tq1r{a=on{^wcL84G8R);qaHeopX& O4UmVc$d<^M2L2c3M^|hB literal 0 HcmV?d00001 diff --git a/src/Plugins/MEDReader/Test/CMakeLists.txt b/src/Plugins/MEDReader/Test/CMakeLists.txt index 60763209..803fe6d0 100644 --- a/src/Plugins/MEDReader/Test/CMakeLists.txt +++ b/src/Plugins/MEDReader/Test/CMakeLists.txt @@ -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 index 00000000..a63f90ff --- /dev/null +++ b/src/Plugins/MEDReader/Test/testMEDReader20.py @@ -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() -- 2.39.2