Salome HOME
Avoid 'make test' failure on invalid DISPLAY
[modules/paravis.git] / src / Plugins / MEDReader / Test / testMEDReader5.py
index 9fbf6eb9b49d5684536f8402519262275e31f4af..613dae7f780ad810482e8df320da160720aa7e53 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
@@ -19,6 +19,9 @@
 #
 # Author : Anthony Geay
 
+import os
+import sys
+
 from MEDLoader import *
 
 """ This test is CEA specific one. It generates a .sauv file
@@ -32,7 +35,7 @@ arr=DataArrayDouble(5) ; arr.iota()
 c=MEDCouplingCMesh("mesh")
 c.setCoords(arr,arr,arr)
 m=c.buildUnstructured()
-mbis=m.deepCpy() ; mbis.translate([5,0,0]) ; mbis.tetrahedrize(PLANAR_FACE_5)
+mbis=m.deepCopy() ; mbis.translate([5,0,0]) ; mbis.tetrahedrize(PLANAR_FACE_5)
 m=MEDCouplingUMesh.MergeUMeshes([mbis,m]) ; m.setName(c.getName())
 mm=MEDFileUMesh()
 mm.setMeshAtLevel(0,m)
@@ -78,13 +81,12 @@ myMedReader=MEDReader(FileName=fname)
 myMedReader.AllArrays = ['TS0/mesh/ComSup1/fNode@@][@@P1']
 myMedReader.AllTimeSteps = ['0000']
 
-Clip1=Clip(ClipType="Plane")
-Clip1.Input=myMedReader
+Clip1=Clip(ClipType="Plane",Input=myMedReader)
 Clip1.Scalars = ['POINTS', 'FamilyIdNode']
 Clip1.ClipType.Origin = [2.0, 2.0, 2.0]
 Clip1.ClipType = "Plane"
 Clip1.ClipType.Normal = [0.04207410474474753, 0.9319448861971525, 0.3601506612529047]
-Clip1.InsideOut = 1
+Clip1.Invert = 1
 
 DataRepresentation2 = Show()
 DataRepresentation2.EdgeColor = [0.0, 0.0, 0.5000076295109483]
@@ -92,24 +94,37 @@ DataRepresentation2.ScalarOpacityUnitDistance = 1.5768745057161244
 DataRepresentation2.ExtractedBlockIndex = 1
 DataRepresentation2.ScaleFactor = 0.4
 
-RenderView1=GetRenderView()
-RenderView1.CenterOfRotation=[2.,2.,2.]
-RenderView1.CameraViewUp=[0.24562884954787187,0.6907950752417243,-0.680050463047831]
-RenderView1.CameraPosition=[-2.5085697461776486,11.6185941755061,10.14210560568201]
-RenderView1.CameraClippingRange=[5.269050059274764,23.64024625330183]
-RenderView1.CameraFocalPoint=[2.,2.,2.]
-RenderView1.CameraParallelScale=5.071791174723188
+if '-D' not in sys.argv:
+  RenderView1=GetRenderView()
+  RenderView1.CenterOfRotation=[2.,2.,2.]
+  RenderView1.CameraViewUp=[0.24562884954787187,0.6907950752417243,-0.680050463047831]
+  RenderView1.CameraPosition=[-2.5085697461776486,11.6185941755061,10.14210560568201]
+  RenderView1.CameraFocalPoint=[2.,2.,2.]
+  RenderView1.CameraParallelScale=5.071791174723188
 
-LookupTable=GetLookupTableForArray("fNode",1,RGBPoints=[0.0,0.23,0.299,0.754,55.0,0.706,0.016,0.15],VectorMode='Magnitude',NanColor=[0.25,0.0,0.0],ColorSpace='Diverging',ScalarRangeInitialized=1.0,AllowDuplicateScalars=1)
-DataRepresentation2 = Show()
-DataRepresentation2.EdgeColor = [0.0, 0.0, 0.5000076295109483]
-DataRepresentation2.ScalarOpacityUnitDistance = 1.5768745057161244
-DataRepresentation2.ExtractedBlockIndex = 1
-DataRepresentation2.ScaleFactor = 0.4
-DataRepresentation2.ColorArrayName='fNode'
-DataRepresentation2.LookupTable=LookupTable
-DataRepresentation2.ColorAttributeType='POINT_DATA'
+  LookupTable=GetLookupTableForArray("fNode",1,RGBPoints=[0.0,0.23,0.299,0.754,55.0,0.706,0.016,0.15],VectorMode='Magnitude',NanColor=[0.25,0.0,0.0],ColorSpace='Diverging',ScalarRangeInitialized=1.0,AllowDuplicateScalars=1)
+  DataRepresentation2 = Show()
+  DataRepresentation2.EdgeColor = [0.0, 0.0, 0.5000076295109483]
+  DataRepresentation2.ScalarOpacityUnitDistance = 1.5768745057161244
+  DataRepresentation2.ExtractedBlockIndex = 1
+  DataRepresentation2.ScaleFactor = 0.4
+  DataRepresentation2.ColorArrayName=('POINTS','fNode')
+  DataRepresentation2.LookupTable=LookupTable
 
+  RenderView1.ViewSize=[300,300]
+  Render()
 
-RenderView1.ViewSize=[300,300]
-WriteImage(outImgName)
+  # compare with baseline image
+  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, "testMEDReader5.png")
+  import vtk.test.Testing
+  from vtk.util.misc import vtkGetTempDir
+  vtk.test.Testing.VTK_TEMP_DIR = vtk.util.misc.vtkGetTempDir()
+  vtk.test.Testing.compareImage(GetActiveView().GetRenderWindow(), baseline_file,
+                                                              threshold=1)
+  vtk.test.Testing.interact()