1 from MEDLoader import *
3 """ This is a non regression bug revealed during training session. The bug is linked to the native Threshold VTK filter. Corrected with PV version >= 4.4. (KW10658)
4 There is still a problem when both image comparison and Fetch are enable together."""
6 fname="testMEDReader19.med"
7 imgName="testMEDReader19.png"
10 coo=DataArrayDouble([(-0.3,-0.3),(0.2,-0.3),(0.7,-0.3),(-0.3,0.2),(0.2,0.2),(0.7,0.2),(-0.3,0.7),(0.2,0.7),(0.7,0.7)])
11 conn0=[[NORM_TRI3,1,4,2],[NORM_TRI3,4,5,2],[NORM_QUAD4,0,3,4,1],[NORM_QUAD4,6,7,4,3],[NORM_QUAD4,7,8,5,4]]
12 conn1=[[NORM_SEG2,4,5],[NORM_SEG2,5,2],[NORM_SEG2,1,0],[NORM_SEG2,6,7]]
13 m0=MEDCouplingUMesh() ; m0.setCoords(coo) ; m0.setMeshDimension(2) ; m0.allocateCells(0)
15 m0.insertNextCell(c[0],c[1:])
17 m1=MEDCouplingUMesh() ; m1.setCoords(coo) ; m1.setMeshDimension(1) ; m1.allocateCells(0)
19 m1.insertNextCell(c[0],c[1:])
24 #### import the simple module from the paraview
25 from paraview.simple import *
26 #### disable automatic camera reset on 'Show'
27 paraview.simple._DisableFirstRenderCameraReset()
29 # create a new 'MED Reader'
30 testMEDReader19med = MEDReader(FileName=fname)
31 testMEDReader19med.AllArrays = ['TS0/mesh/ComSup0/mesh@@][@@P0']
32 testMEDReader19med.AllTimeSteps = ['0000']
33 # Properties modified on testMEDReader19med
34 testMEDReader19med.AllArrays = ['TS0/mesh/ComSup0/mesh@@][@@P0']
37 renderView1 = GetActiveViewOrCreate('RenderView')
39 # reset view to fit data
40 renderView1.ResetCamera()
42 #changing interaction mode based on data extents
43 renderView1.InteractionMode = '2D'
44 renderView1.CameraPosition = [0.2, 0.2, 10000.0]
45 renderView1.CameraFocalPoint = [0.2, 0.2, 0.0]
46 testMEDReader19med.UpdatePipeline()
47 # create a new 'Extract Cell Type'
48 extractCellType1 = ExtractCellType(Input=testMEDReader19med)
49 extractCellType1.AllGeoTypes = []
51 # Properties modified on extractCellType1
52 extractCellType1.AllGeoTypes = ['TRI3']
55 extractCellType1Display = Show(extractCellType1, renderView1)
56 # trace defaults for the display properties.
57 extractCellType1Display.ColorArrayName = [None, '']
58 extractCellType1Display.ScalarOpacityUnitDistance = 0.5
59 extractCellType1Display.OpacityArray = [None, '']
60 extractCellType1Display.RadiusArray = [None, '']
61 extractCellType1Display.RadiusRange = [0.2, 0.7]
62 extractCellType1Display.ConstantRadius = 0.7
63 extractCellType1Display.PointSpriteDefaultsInitialized = 1
64 extractCellType1Display.SelectInputVectors = [None, '']
65 extractCellType1Display.WriteLog = ''
68 renderView1.InteractionMode = '2D'
69 renderView1.CameraPosition = [0.2, 0.2, 10000.0]
70 renderView1.CameraFocalPoint = [0.2, 0.2, 0.0]
71 renderView1.CameraParallelScale = 0.7071067811865476
73 res=servermanager.Fetch(extractCellType1,0)
74 assert(res.GetBlock(0).GetNumberOfCells()==2) # problem was here in PV4.3.1
76 """# compare with baseline image # Waiting KW return to uncomment this part because SIGSEGV in PV5.
80 baselineIndex = sys.argv.index('-B')+1
81 baselinePath = sys.argv[baselineIndex]
83 print "Could not get baseline directory. Test failed."
85 baseline_file = os.path.join(baselinePath, imgName)
86 import vtk.test.Testing
87 vtk.test.Testing.VTK_TEMP_DIR = vtk.util.misc.vtkGetTempDir()
88 vtk.test.Testing.compareImage(GetActiveView().GetRenderWindow(), baseline_file, threshold=25)
89 vtk.test.Testing.interact()