Salome HOME
Merge remote branch 'origin/V7_dev'
[modules/paravis.git] / src / Plugins / MEDReader / Test / testMEDReader0.py
index 0ade05bb60f842d8d3467452ea6f9bb4af6eaf65..3f80e3a13aecdbdd28a96cca0a280aa3c9bbee3f 100644 (file)
@@ -1,10 +1,10 @@
 #  -*- coding: iso-8859-1 -*-
-# Copyright (C) 2007-2014  CEA/DEN, EDF R&D
+# Copyright (C) 2007-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.
+# 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
@@ -20,7 +20,6 @@
 # Author : Anthony Geay
 
 from MEDLoader import *
-
 fname="testMEDReader0.med"
 outImgName="testMEDReader0.png"
 #########
@@ -40,7 +39,7 @@ f0z.setMesh(mz)
 f0z.setArray(arr0)
 f0z.setGaussLocalizationOnType(NORM_QUAD9,[-1,-1,1,-1,1,1,-1,1,0,-1,1,0,0,1,-1,0,0,0],[-0.774597,-0.774597,0.774597,-0.774597,0.774597,0.774597,-0.774597,0.774597,0,-0.774597,0.774597,0,0,0.774597,-0.774597,0,0,0,-0.774597,-0.774597,0.774597,-0.774597,0.774597,0.774597,-0.774597,0.774597,0,-0.774597,0.774597,0,0,0.774597,-0.774597,0,0,0,-0.774597,-0.774597,0.774597,-0.774597,0.774597,0.774597,-0.774597,0.774597,0,-0.774597,0.774597,0,0,0.774597,-0.774597,0,0,0],[0.308642,0.308642,0.308642,0.308642,0.493827,0.493827,0.493827,0.493827,0.790123,0.308642,0.308642,0.308642,0.308642,0.493827,0.493827,0.493827,0.493827,0.790123,0.308642,0.308642,0.308642,0.308642,0.493827,0.493827,0.493827,0.493827,0.790123])
 f0z.setName("SolutionSIEF_ELGA")
-f0z.checkCoherency()
+f0z.checkConsistencyLight()
 ff0z=MEDFileField1TS()
 ff0z.setFieldNoProfileSBT(f0z)
 #
@@ -49,7 +48,7 @@ arr1.setInfoOnComponents(['VMIS','TRESCA'])
 f1z=MEDCouplingFieldDouble(ON_GAUSS_NE) ; f1z.setName("SolutionSIEQ_ELNO")
 f1z.setArray(arr1)
 f1z.setMesh(mz)
-f1z.checkCoherency()
+f1z.checkConsistencyLight()
 ff1z=MEDFileField1TS()
 ff1z.setFieldNoProfileSBT(f1z)
 #
@@ -57,7 +56,7 @@ arr2=DataArrayDouble([4.938269266683534e-28,-6.232001151245993e-28,1.06022905661
 arr2.setInfoOnComponents(['DRX','DRZ'])
 f2z=MEDCouplingFieldDouble(ON_NODES) ; f2z.setName("SolutionDEPL") ; f2z.setArray(arr2)
 f2z.setMesh(mz)
-f2z.checkCoherency()
+f2z.checkConsistencyLight()
 ff2z=MEDFileField1TS()
 ff2z.setFieldNoProfileSBT(f2z)
 #
@@ -87,10 +86,8 @@ arr_name_with_dis=[elt.split("/")[-1] for elt in keys]
 arr_name=[elt.split(myMedReader.GetProperty("Separator").GetData())[0] for elt in arr_name_with_dis]
 myMedReader.AllArrays=keys
 RenderView1 = GetRenderView()
-ELNOMesh1=ELNOMesh()
-ELNOMesh1.Input=myMedReader
-ExtractGroup1=ExtractGroup()
-ExtractGroup1.Input=ELNOMesh1
+ELNOMesh1=ELNOMesh(Input=myMedReader)
+ExtractGroup1=ExtractGroup(Input=ELNOMesh1)
 ExtractGroup1.UpdatePipelineInformation()
 ExtractGroup1.AllGroups=['GRP_ba2','GRP_to1','GRP_web']
 assert(isinstance(ExtractGroup1.GetProperty("MeshName")[0],str))
@@ -108,8 +105,7 @@ DataRepresentation3.ColorArrayName = 'SolutionSIEQ_ELNO'
 DataRepresentation3.LookupTable = a2_SolutionSIEQ_ELNO_PVLookupTable
 DataRepresentation3.Visibility = 1
 #
-GaussPoints1=GaussPoints()
-GaussPoints1.Input=ELNOMesh1
+GaussPoints1=GaussPoints(Input=ELNOMesh1)
 GaussPoints1.SelectSourceArray=['CELLS','ELGA@0']
 DataRepresentation4 = Show()
 DataRepresentation4.ScaleFactor = 0.008999999705702066
@@ -122,5 +118,20 @@ RenderView1.CameraPosition = [0.11797550069274401, 0.20119836056342144, 0.208854
 RenderView1.CameraClippingRange = [0.14700465306315827, 0.40712447273162633]
 RenderView1.CameraFocalPoint = [1.0170565790969026e-18, 0.0599999981932342, 0.022500000894069675]
 RenderView1.ViewSize =[300,300]
-WriteImage(outImgName)
+Render()
 
+# 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, "testMEDReader0.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()