Salome HOME
Merge V9_dev branch into master
[modules/paravis.git] / src / Plugins / MEDReader / Test / testMEDReader2.py
index 86074114dd6be181f6bee1c01c7d1836c6eab476..b2fe089775929631a9e63ca1ad3967ae585f2dca 100644 (file)
@@ -1,10 +1,10 @@
 #  -*- coding: iso-8859-1 -*-
-# Copyright (C) 2007-2014  CEA/DEN, EDF R&D
+# Copyright (C) 2007-2017  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.
+# 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
@@ -46,7 +46,7 @@ mm.write(fname,2)
 pfl=DataArrayInt([7,8,9,10,13,14,15,16,19,20,21,22,25,26,27,28]) ; pfl.setName("pfl")
 f=MEDCouplingFieldDouble(ON_CELLS) ; f.setName("ACellField")
 arr=DataArrayDouble(16) ; arr.iota()
-arr2=arr.deepCpy() ; arr2.reverse()
+arr2=arr.deepCopy() ; arr2.reverse()
 arr=DataArrayDouble.Meld(arr,arr2) ; arr.setInfoOnComponents(["aa","bbb"])
 f.setArray(arr)
 f1ts=MEDFileField1TS()
@@ -57,16 +57,13 @@ f1ts.write(fname,0)
 
 from paraview.simple import *
 
-
-
 testMEDReader1=MEDReader(FileName=fname)
 testMEDReader1.AllArrays=['TS0/mesh/ComSup0/ACellField@@][@@P0']
 testMEDReader2=MEDReader(FileName=fname)
 testMEDReader2.AllArrays=['TS0/mesh/ComSup1/mesh@@][@@P0']
 GroupDatasets1=GroupDatasets(Input=[testMEDReader1,testMEDReader2])
 
-Clip1 = Clip(ClipType="Plane")
-Clip1.Input=GroupDatasets1
+Clip1 = Clip(ClipType="Plane",Input=GroupDatasets1)
 Clip1.Scalars=['FamilyIdCell']
 Clip1.ClipType.Origin=[3.0, 3.0, 3.0]
 Clip1.InsideOut=1
@@ -82,9 +79,8 @@ DataRepresentation4.ScaleFactor = 0.6000000000000001
 DataRepresentation4.Visibility = 1
 DataRepresentation4.Representation = 'Wireframe'
 
-ExtractBlock1 = ExtractBlock()
+ExtractBlock1 = ExtractBlock(Input=Clip1)
 ExtractBlock1.BlockIndices=[1, 2]
-ExtractBlock1.Input=Clip1
 
 DataRepresentation5 = Show()
 DataRepresentation5.EdgeColor = [0.0, 0.0, 0.5000076295109483]
@@ -94,18 +90,32 @@ a2_ACellField_PVLookupTable=GetLookupTableForArray( "ACellField", 2, RGBPoints=[
 a2_ACellField_PiecewiseFunction=CreatePiecewiseFunction( Points=[0.0, 0.0, 0.5, 0.0, 1.0, 1.0, 0.5, 0.0] )
 a2_ACellField_PVLookupTable.ScalarOpacityFunction = a2_ACellField_PiecewiseFunction
 DataRepresentation5.ScalarOpacityFunction = a2_ACellField_PiecewiseFunction
-DataRepresentation5.ColorArrayName = 'ACellField'
 DataRepresentation5.LookupTable = a2_ACellField_PVLookupTable
-DataRepresentation5.ColorAttributeType = 'CELL_DATA'
+DataRepresentation5.ColorArrayName = ("CELLS", "ACellField")
 
 RenderView1 = GetRenderView()
 RenderView1.CenterOfRotation = [3.0, 3.0, 3.0]
 RenderView1.CameraViewUp = [-0.03886073885859842, 0.48373409998193495, 0.8743518533691291]
 RenderView1.CameraPosition = [7.351939549758929, -5.688193007926853, 8.000155023042788]
-RenderView1.CameraClippingRange = [0.026023957813772633, 26.023957813772633]
 RenderView1.CameraFocalPoint = [2.9999999999999996, 2.9999999999999987, 2.9999999999999982]
 
 RenderView1.ViewSize =[300,300]
-WriteImage(outImgName)
-
-
+Render()
+
+#WriteImage(outImgName)
+
+# 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, "testMEDReader2.png")
+import vtk.test.Testing
+vtk.test.Testing.VTK_TEMP_DIR = vtk.util.misc.vtkGetTempDir()
+vtk.test.Testing.compareImage(GetActiveView().GetRenderWindow(), baseline_file,
+                                                            threshold=1)
+vtk.test.Testing.interact()