Salome HOME
Update copyrights
[modules/paravis.git] / src / Plugins / MEDReader / Test / testMEDReader6.py
index 2154fe497f706c336561d856b2833c87511f484d..1b0d2c9dce084f5899f98922e400f4eec29a7d2a 100644 (file)
@@ -1,10 +1,10 @@
 #  -*- coding: iso-8859-1 -*-
-# Copyright (C) 2007-2014  CEA/DEN, EDF R&D
+# Copyright (C) 2007-2019  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
 #
 # Author : Anthony Geay
 
+import os
+import sys
+
 from MEDLoader import *
 
 """ This test generate a GaussPoint field on a mesh with groups.
-The aim of this test is to check that the ExtractGroup works well for GaussPoints
+The aim of this test is to check that the ExtractGroup works well for ELGAfieldToPointGaussian
 """
 
 fname="testMEDReader6.med"
@@ -47,7 +50,7 @@ fGauss.setGaussLocalizationOnType(NORM_TRI3,[0.,0.,1.,0.,0.,1.],[0.1,0.1,0.05,0.
 fGauss.setGaussLocalizationOnType(NORM_QUAD4,[-1.,-1.,1.,-1.,1.,1.,-1.,1.],[-0.9,-0.9,0.,0.,0.9,0.9],[0.2,0.3,0.5])
 fGauss.setArray(DataArrayDouble([0.9,1.3,0.22,1.3,1.62,2.21,1.62,2.72,2.95,2.54,2.25,2.16,1.58,1.05,3.13,2.91,2.82,1.41,1.58,1.95,3.59,3.53,3.59,2.82,2.91,3.13,2.25,2.54,2.95]))
 fGauss.getArray().setInfoOnComponent(0,"C0")
-fGauss.checkCoherency()
+fGauss.checkConsistencyLight()
 #
 f1ts=MEDFileField1TS()
 f1ts.setFieldNoProfileSBT(fGauss)
@@ -65,35 +68,48 @@ ExtractGroup1 = ExtractGroup(Input=myMedReader)
 ExtractGroup1.UpdatePipelineInformation()
 ExtractGroup1.AllGroups = ['GRP_grp0']
 
-GaussPoints1 = GaussPoints(Input=ExtractGroup1)
-GaussPoints1.SelectSourceArray = ['CELLS','ELGA@0']
+ELGAfieldToPointGaussian1 = ELGAfieldToPointGaussian(Input=ExtractGroup1)
+ELGAfieldToPointGaussian1.SelectSourceArray = ['CELLS','ELGA@0']
 
-Glyph1 = Glyph( Input=GaussPoints1, GlyphType="Sphere", GlyphTransform="Transform2" )
+Glyph1 = Glyph( Input=ELGAfieldToPointGaussian1, GlyphType="Sphere", GlyphTransform="Transform2" )
 Glyph1.GlyphType = "Sphere"
-Glyph1.Vectors = ['POINTS', '']
-Glyph1.SetScaleFactor = 0.29
-
-RenderView1 = GetRenderView()
-RenderView1.CameraFocalPoint = [1.5, 1.5, 0.0]
-RenderView1.CameraPosition = [1.5, 1.5, 10000.0]
-RenderView1.InteractionMode = '3D'
-RenderView1.CameraPosition = [1.5, 1.5, 8.196152422706632]
-RenderView1.CameraClippingRange = [7.825640906782493, 8.682319698595558]
-RenderView1.CameraParallelScale = 2.1213203435596424
-RenderView1.CenterOfRotation = [1.5, 1.5, 0.0]
+Glyph1.OrientationArray = ['POINTS', 'No orientation array']
+Glyph1.MaximumGlyphSize = 0.29
 
-DataRepresentation4 = Show()
-DataRepresentation4.EdgeColor = [0.0, 0.0, 0.5000076295109483]
-DataRepresentation4.SelectionPointFieldDataArrayName = 'fGauss'
-DataRepresentation4.ScaleFactor = 0.3182729169726372
+if '-D' not in sys.argv:
+    RenderView1 = GetRenderView()
+    RenderView1.CameraFocalPoint = [1.5, 1.5, 0.0]
+    RenderView1.CameraPosition = [1.5, 1.5, 10000.0]
+    RenderView1.InteractionMode = '3D'
+    RenderView1.CameraPosition = [1.5, 1.5, 8.196152422706632]
+    RenderView1.CameraParallelScale = 2.1213203435596424
+    RenderView1.CenterOfRotation = [1.5, 1.5, 0.0]
 
-a1_fGauss_PVLookupTable = GetLookupTableForArray( "fGauss", 1, RGBPoints=[0.22, 0.23, 0.299, 0.754, 2.95, 0.706, 0.016, 0.15], VectorMode='Magnitude', NanColor=[0.25, 0.0, 0.0], ColorSpace='Diverging', ScalarRangeInitialized=1.0, AllowDuplicateScalars=1 )
-a1_fGauss_PiecewiseFunction = CreatePiecewiseFunction( Points=[0.0, 0.0, 0.5, 0.0, 1.0, 1.0, 0.5, 0.0] )
-DataRepresentation4.ColorArrayName = 'fGauss'
-DataRepresentation4.LookupTable = a1_fGauss_PVLookupTable
-a1_fGauss_PVLookupTable.ScalarOpacityFunction = a1_fGauss_PiecewiseFunction
+    DataRepresentation4 = Show()
+    DataRepresentation4.EdgeColor = [0.0, 0.0, 0.5000076295109483]
+    DataRepresentation4.SelectionPointFieldDataArrayName = 'fGauss'
+    DataRepresentation4.ScaleFactor = 0.3182729169726372
 
+    a1_fGauss_PVLookupTable = GetLookupTableForArray( "fGauss", 1, RGBPoints=[0.22, 0.23, 0.299, 0.754, 2.95, 0.706, 0.016, 0.15], VectorMode='Magnitude', NanColor=[0.25, 0.0, 0.0], ColorSpace='Diverging', ScalarRangeInitialized=1.0, AllowDuplicateScalars=1 )
+    a1_fGauss_PiecewiseFunction = CreatePiecewiseFunction( Points=[0.0, 0.0, 0.5, 0.0, 1.0, 1.0, 0.5, 0.0] )
+    DataRepresentation4.ColorArrayName = 'fGauss'
+    DataRepresentation4.LookupTable = a1_fGauss_PVLookupTable
+    a1_fGauss_PVLookupTable.ScalarOpacityFunction = a1_fGauss_PiecewiseFunction
 
-RenderView1.ViewSize=[300,300]
-WriteImage(outImgName)
+    RenderView1.ViewSize=[300,300]
+    Render()
 
+    # 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, "testMEDReader6.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()