1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2016 CEA/DEN, EDF R&D
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.
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.
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
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 # Author : Anthony Geay
22 from MEDLoader import *
24 """ 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"""
26 fname="testMEDReader13.med"
27 outImgName="testMEDReader13.png"
30 m=MEDCouplingUMesh("mesh",2)
31 m.setCoords(DataArrayDouble([0.,0.,0.,1.,0.,0.,2.,0.,0.,1.,1.,0.],4,3))
33 m.insertNextCell(NORM_TRI3,[0,1,3]) ; m.insertNextCell(NORM_TRI3,[1,2,3])
34 f=MEDCouplingFieldDouble(ON_GAUSS_NE) ; f.setName("fieldELNO") ; f.setMesh(m)
35 arr=DataArrayDouble([0.2,1.1,0.7,0.5,-0.3,0.4])
36 f.setArray(DataArrayDouble.Meld(4*[arr]))
37 f.checkConsistencyLight()
38 WriteField(fname,f,True)
40 ################### MED write is done -> Go to MEDReader
42 from paraview.simple import *
44 testMEDReader13_med = MEDReader( FileName=fname )
46 testMEDReader13_med.GenerateVectors = 1
47 testMEDReader13_med.AllArrays = ['TS0/mesh/ComSup0/fieldELNO@@][@@GSSNE']
49 RenderView1 = GetRenderView()
50 RenderView1.CameraPosition = [1.0, 0.5, 10000.0]
52 RenderView1.CameraPosition = [1.0, 0.5, 4.319751617610021]
54 ELNOfieldToSurface3 = ELNOfieldToSurface(Input=testMEDReader13_med)
56 DataRepresentation2 = Show()
57 #DataRepresentation2.ConstantRadius = 1.9999333620071411
58 DataRepresentation2.EdgeColor = [0.0, 0.0, 0.5000076295109483]
59 #DataRepresentation2.PointSpriteDefaultsInitialized = 1
60 DataRepresentation2.SelectionPointFieldDataArrayName = 'fieldELNO'
61 DataRepresentation2.SelectionCellFieldDataArrayName = 'FamilyIdCell'
62 #DataRepresentation2.SelectInputVectors = ['POINTS', 'fieldELNO_Vector']
63 DataRepresentation2.ScalarOpacityUnitDistance = 1.7746382108908556
64 DataRepresentation2.Texture = []
65 DataRepresentation2.ExtractedBlockIndex = 1
66 #DataRepresentation2.RadiusRange = [6.666666740784422e-05, 1.9999333620071411]
67 DataRepresentation2.ScaleFactor = 0.19998666953397334
69 #DataRepresentation2.RadiusRange = [6.66667e-05, 1.99993]
70 DataRepresentation2.ColorArrayName = ('POINT_DATA', 'fieldELNO_Vector')
72 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 )
74 a3_fieldELNO_Vector_PiecewiseFunction = CreatePiecewiseFunction( Points=[0.3464101615137755, 0.0, 0.5, 0.0, 1.9052558883257653, 1.0, 0.5, 0.0] )
76 RenderView1.ViewSize =[300,300]
79 # compare with baseline image
83 baselineIndex = sys.argv.index('-B')+1
84 baselinePath = sys.argv[baselineIndex]
86 print "Could not get baseline directory. Test failed."
88 baseline_file = os.path.join(baselinePath, "testMEDReader13.png")
89 import vtk.test.Testing
90 vtk.test.Testing.VTK_TEMP_DIR = vtk.util.misc.vtkGetTempDir()
91 vtk.test.Testing.compareImage(GetActiveView().GetRenderWindow(), baseline_file,
93 vtk.test.Testing.interact()