v0.14.0
paraview_deform_macro.py
Go to the documentation of this file.
1 #### import the simple module from the paraview
2 from paraview.simple import *
3 #### disable automatic camera reset on 'Show'
4 paraview.simple._DisableFirstRenderCameraReset()
5 
6 
7 #reader = LegacyVTKReader('/Users/user/mofem/users_modules/fracture_mechanics/out_spatial0.vtk'
8 
9 # get active view
10 renderView1 = GetActiveViewOrCreate('RenderView')
11 # Properties modified on calculator1
12 calculator1 = Calculator(Input=GetActiveSource())
13 SetActiveSource(calculator1)
14 if any("SINGULAR_DISP" in str for str in calculator1.PointData.keys()):
15  calculator1.Function = 'MESH_NODE_POSITIONS+SINGULAR_DISP-coords'
16 else:
17  calculator1.Function = 'MESH_NODE_POSITIONS-coords'
18 calculator1.ResultArrayName = 'Result1'
19 
20 # show nad hide data in view
21 calculator1Display = Show(calculator1, renderView1)
22 Hide(calculator1, renderView1)
23 # SetActiveSource(calculator1)
24 # create a new 'Warp By Vector'
25 WarpByVector1 = WarpByVector(Input=calculator1)
26 WarpByVector1.Vectors = [None, 'Result1']
27 # create a new 'Calculator'
28 calculator2 = Calculator(Input=WarpByVector1)
29 
30 
31 # Properties modified on calculator2
32 if any("SINGULAR_DISP" in str for str in calculator2.PointData.keys()):
33  calculator2.Function = 'SPATIAL_POSITION-MESH_NODE_POSITIONS-SINGULAR_DISP'
34 else:
35  calculator2.Function = 'SPATIAL_POSITION-MESH_NODE_POSITIONS'
36 calculator2.ResultArrayName = 'DISPLACEMENTS'
37 SetActiveSource(calculator2)
38 # create a new 'Warp By Vector'
39 # update the view to ensure updated data information
40 calculator2Display = Show(calculator2, renderView1)
41 Hide(calculator2, renderView1)
42 WarpByVector2 = WarpByVector(Input=calculator2)
43 WarpByVector2.Vectors = [None, 'DISPLACEMENTS']
44 WarpByVector2.ScaleFactor = 1.0
45 WarpByVector2Display = Show(WarpByVector2, renderView1)
simple
import the simple module from the paraview