Salome HOME
Update copyrights
[modules/paravis.git] / src / Plugins / MEDReader / Test / testMEDReader13.py
1 #  -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2019  CEA/DEN, EDF R&D
3 #
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
8 #
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 # Lesser General Public License for more details.
13 #
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20 # Author : Anthony Geay
21
22 import os
23 import sys
24
25 from MEDLoader import *
26
27 """ This test is non regression test to check non regression of EDF 8761. ELNO Mesh filter on vector field with 4 comps cut of using GenerateVectors"""
28
29 fname="testMEDReader13.med"
30 outImgName="testMEDReader13.png"
31 #
32
33 m=MEDCouplingUMesh("mesh",2)
34 m.setCoords(DataArrayDouble([0.,0.,0.,1.,0.,0.,2.,0.,0.,1.,1.,0.],4,3))
35 m.allocateCells()
36 m.insertNextCell(NORM_TRI3,[0,1,3]) ; m.insertNextCell(NORM_TRI3,[1,2,3])
37 f=MEDCouplingFieldDouble(ON_GAUSS_NE) ; f.setName("fieldELNO") ; f.setMesh(m)
38 arr=DataArrayDouble([0.2,1.1,0.7,0.5,-0.3,0.4])
39 f.setArray(DataArrayDouble.Meld(4*[arr]))
40 f.checkConsistencyLight()
41 WriteField(fname,f,True)
42
43 ################### MED write is done -> Go to MEDReader
44
45 from paraview.simple import *
46
47 testMEDReader13_med = MEDReader( FileName=fname )
48
49 testMEDReader13_med.GenerateVectors = 1
50 testMEDReader13_med.AllArrays = ['TS0/mesh/ComSup0/fieldELNO@@][@@GSSNE']
51
52 if '-D' not in sys.argv:
53   RenderView1 = GetRenderView()
54   RenderView1.CameraPosition = [1.0, 0.5, 10000.0]
55
56   RenderView1.CameraPosition = [1.0, 0.5, 4.319751617610021]
57
58   ELNOfieldToSurface3 = ELNOfieldToSurface(Input=testMEDReader13_med)
59
60   DataRepresentation2 = Show()
61   #DataRepresentation2.ConstantRadius = 1.9999333620071411
62   DataRepresentation2.EdgeColor = [0.0, 0.0, 0.5000076295109483]
63   #DataRepresentation2.PointGaussianDefaultsInitialized = 1
64   DataRepresentation2.SelectionPointFieldDataArrayName = 'fieldELNO'
65   DataRepresentation2.SelectionCellFieldDataArrayName = 'FamilyIdCell'
66   #DataRepresentation2.SelectInputVectors = ['POINTS', 'fieldELNO_Vector']
67   DataRepresentation2.ScalarOpacityUnitDistance = 1.7746382108908556
68   DataRepresentation2.Texture = []
69   DataRepresentation2.ExtractedBlockIndex = 1
70   #DataRepresentation2.RadiusRange = [6.666666740784422e-05, 1.9999333620071411]
71   DataRepresentation2.ScaleFactor = 0.19998666953397334
72
73   #DataRepresentation2.RadiusRange = [6.66667e-05, 1.99993]
74   DataRepresentation2.ColorArrayName = ('POINT_DATA', 'fieldELNO_Vector')
75
76   a3_fieldELNO_Vector_PVLookupTable = GetLookupTableForArray( "fieldELNO_Vector", 3, RGBPoints=[0.3464101615137755, 0.23, 0.299, 0.754, 1.1258330249197703, 0.865, 0.865, 0.865, 1.9052558883257653, 0.706, 0.016, 0.15], VectorMode='Magnitude', NanColor=[0.25, 0.0, 0.0], ColorSpace='Diverging', ScalarRangeInitialized=1.0 )
77
78   a3_fieldELNO_Vector_PiecewiseFunction = CreatePiecewiseFunction( Points=[0.3464101615137755, 0.0, 0.5, 0.0, 1.9052558883257653, 1.0, 0.5, 0.0] )
79
80   RenderView1.ViewSize =[300,300]
81   Render()
82
83   # compare with baseline image
84   try:
85     baselineIndex = sys.argv.index('-B')+1
86     baselinePath = sys.argv[baselineIndex]
87   except:
88     print("Could not get baseline directory. Test failed.")
89     exit(1)
90   baseline_file = os.path.join(baselinePath, "testMEDReader13.png")
91   import vtk.test.Testing
92   from vtk.util.misc import vtkGetTempDir
93   vtk.test.Testing.VTK_TEMP_DIR = vtk.util.misc.vtkGetTempDir()
94   vtk.test.Testing.compareImage(GetActiveView().GetRenderWindow(), baseline_file,
95                                                               threshold=1)
96   vtk.test.Testing.interact()