Salome HOME
Copyright update 2022
[modules/paravis.git] / src / Plugins / MEDReader / plugin / Test / testMEDReader13.py
1 #  -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2022  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 medcoupling import *
26 from paraview.simple import *
27 from MEDReaderHelper import WriteInTmpDir,RetriveBaseLine
28
29 def GenerateCase():
30   """ 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"""
31
32   fname="testMEDReader13.med"
33   #
34
35   m=MEDCouplingUMesh("mesh",2)
36   m.setCoords(DataArrayDouble([0.,0.,0.,1.,0.,0.,2.,0.,0.,1.,1.,0.],4,3))
37   m.allocateCells()
38   m.insertNextCell(NORM_TRI3,[0,1,3]) ; m.insertNextCell(NORM_TRI3,[1,2,3])
39   f=MEDCouplingFieldDouble(ON_GAUSS_NE) ; f.setName("fieldELNO") ; f.setMesh(m)
40   arr=DataArrayDouble([0.2,1.1,0.7,0.5,-0.3,0.4])
41   f.setArray(DataArrayDouble.Meld(4*[arr]))
42   f.checkConsistencyLight()
43   WriteField(fname,f,True)
44   return fname
45
46 @WriteInTmpDir
47 def test(baseline_file):
48   fname = GenerateCase()
49   ################### MED write is done -> Go to MEDReader
50   testMEDReader13_med = MEDReader( FileName=fname )
51
52   testMEDReader13_med.GenerateVectors = 1
53   testMEDReader13_med.AllArrays = ['TS0/mesh/ComSup0/fieldELNO@@][@@GSSNE']
54
55   if '-D' not in sys.argv:
56     RenderView1 = GetRenderView()
57     RenderView1.CameraPosition = [1.0, 0.5, 10000.0]
58
59     RenderView1.CameraPosition = [1.0, 0.5, 4.319751617610021]
60
61     ELNOfieldToSurface3 = ELNOfieldToSurface(Input=testMEDReader13_med)
62
63     DataRepresentation2 = Show()
64     #DataRepresentation2.ConstantRadius = 1.9999333620071411
65     DataRepresentation2.EdgeColor = [0.0, 0.0, 0.5000076295109483]
66     #DataRepresentation2.PointGaussianDefaultsInitialized = 1
67     DataRepresentation2.SelectionPointFieldDataArrayName = 'fieldELNO'
68     DataRepresentation2.SelectionCellFieldDataArrayName = 'FamilyIdCell'
69     #DataRepresentation2.SelectInputVectors = ['POINTS', 'fieldELNO_Vector']
70     DataRepresentation2.ScalarOpacityUnitDistance = 1.7746382108908556
71     DataRepresentation2.Texture = []
72     DataRepresentation2.ExtractedBlockIndex = 1
73     #DataRepresentation2.RadiusRange = [6.666666740784422e-05, 1.9999333620071411]
74     DataRepresentation2.ScaleFactor = 0.19998666953397334
75
76     #DataRepresentation2.RadiusRange = [6.66667e-05, 1.99993]
77     DataRepresentation2.ColorArrayName = ('POINT_DATA', 'fieldELNO_Vector')
78
79     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 )
80
81     a3_fieldELNO_Vector_PiecewiseFunction = CreatePiecewiseFunction( Points=[0.3464101615137755, 0.0, 0.5, 0.0, 1.9052558883257653, 1.0, 0.5, 0.0] )
82
83     RenderView1.ViewSize =[300,300]
84     Render()
85
86     # compare with baseline image
87     import vtk.test.Testing
88     from vtk.util.misc import vtkGetTempDir
89     vtk.test.Testing.VTK_TEMP_DIR = vtk.util.misc.vtkGetTempDir()
90     vtk.test.Testing.compareImage(GetActiveView().GetRenderWindow(), baseline_file,
91                                                                 threshold=1)
92     vtk.test.Testing.interact()
93
94 if __name__ == "__main__":
95   outImgName="testMEDReader13.png"
96   baseline_file = RetriveBaseLine(outImgName)
97   test(baseline_file)
98   pass