Salome HOME
Copyright update 2022
[modules/paravis.git] / src / Plugins / DevelopedSurface / plugin / Test / test_dev_surface.py
1 # Copyright (C) 2017-2022  CEA/DEN, EDF R&D
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19 # Author : Anthony Geay (EDF R&D)
20
21 #### import the simple module from the paraview
22 from paraview.simple import *
23 #### disable automatic camera reset on 'Show'
24 paraview.simple._DisableFirstRenderCameraReset()
25
26 # create a new 'MED Reader'
27 multiTSmed = MEDReader(FileName='multiTS.med')
28 multiTSmed.AllArrays = ['TS0/Mesh/ComSup0/Pressure@@][@@P0']
29 multiTSmed.AllTimeSteps = ['0000', '0001', '0002', '0003', '0004', '0005', '0006', '0007', '0008', '0009']
30
31 # get animation scene
32 animationScene1 = GetAnimationScene()
33
34 # update animation scene based on data timesteps
35 animationScene1.UpdateAnimationUsingDataTimeSteps()
36
37 # get active view
38 renderView1 = GetActiveViewOrCreate('RenderView')
39 # uncomment following to set a specific view size
40 # renderView1.ViewSize = [1499, 582]
41
42 # show data in view
43 multiTSmedDisplay = Show(multiTSmed, renderView1)
44
45 # trace defaults for the display properties.
46 multiTSmedDisplay.Representation = 'Surface'
47 multiTSmedDisplay.ColorArrayName = [None, '']
48 multiTSmedDisplay.OSPRayScaleArray = 'FamilyIdNode'
49 multiTSmedDisplay.OSPRayScaleFunction = 'PiecewiseFunction'
50 multiTSmedDisplay.SelectOrientationVectors = 'FamilyIdNode'
51 multiTSmedDisplay.ScaleFactor = 0.07399989366531372
52 multiTSmedDisplay.SelectScaleArray = 'FamilyIdNode'
53 multiTSmedDisplay.GlyphType = 'Arrow'
54 multiTSmedDisplay.GlyphTableIndexArray = 'FamilyIdNode'
55 multiTSmedDisplay.DataAxesGrid = 'GridAxesRepresentation'
56 multiTSmedDisplay.PolarAxes = 'PolarAxesRepresentation'
57 multiTSmedDisplay.ScalarOpacityUnitDistance = 0.017316274962626298
58 multiTSmedDisplay.GaussianRadius = 0.03699994683265686
59 multiTSmedDisplay.SetScaleArray = ['POINTS', 'FamilyIdNode']
60 multiTSmedDisplay.ScaleTransferFunction = 'PiecewiseFunction'
61 multiTSmedDisplay.OpacityArray = ['POINTS', 'FamilyIdNode']
62 multiTSmedDisplay.OpacityTransferFunction = 'PiecewiseFunction'
63 multiTSmedDisplay.InputVectors = [None, '']
64 multiTSmedDisplay.SelectInputVectors = [None, '']
65 multiTSmedDisplay.WriteLog = ''
66
67 # init the 'PiecewiseFunction' selected for 'ScaleTransferFunction'
68 multiTSmedDisplay.ScaleTransferFunction.Points = [0.0, 0.0, 0.5, 0.0, 1.1757813367477812e-38, 1.0, 0.5, 0.0]
69
70 # init the 'PiecewiseFunction' selected for 'OpacityTransferFunction'
71 multiTSmedDisplay.OpacityTransferFunction.Points = [0.0, 0.0, 0.5, 0.0, 1.1757813367477812e-38, 1.0, 0.5, 0.0]
72
73 # reset view to fit data
74 renderView1.ResetCamera()
75
76 # update the view to ensure updated data information
77 renderView1.Update()
78
79 # create a new 'Developed Surface'
80 developedSurface1 = DevelopedSurface(Input=multiTSmed)
81 developedSurface1.SliceType = 'Cylinder'
82
83 # init the 'Cylinder' selected for 'SliceType'
84 developedSurface1.SliceType.Center = [0.0, 0.0, 0.05000000074505806]
85 developedSurface1.SliceType.Radius = 0.3699994683265686
86
87 # Properties modified on developedSurface1.SliceType
88 developedSurface1.SliceType.Center = [0.0, 0.0, 0.05]
89 developedSurface1.SliceType.Axis = [0.0, 0.0, 1.0]
90 developedSurface1.SliceType.Radius = 0.07
91
92 # Properties modified on developedSurface1.SliceType
93 developedSurface1.SliceType.Center = [0.0, 0.0, 0.05]
94 developedSurface1.SliceType.Axis = [0.0, 0.0, 1.0]
95 developedSurface1.SliceType.Radius = 0.07
96
97 # show data in view
98 developedSurface1Display = Show(developedSurface1, renderView1)
99
100 # trace defaults for the display properties.
101 developedSurface1Display.Representation = 'Surface'
102 developedSurface1Display.ColorArrayName = [None, '']
103 developedSurface1Display.OSPRayScaleArray = 'FamilyIdNode'
104 developedSurface1Display.OSPRayScaleFunction = 'PiecewiseFunction'
105 developedSurface1Display.SelectOrientationVectors = 'FamilyIdNode'
106 developedSurface1Display.ScaleFactor = 0.043982297150257116
107 developedSurface1Display.SelectScaleArray = 'FamilyIdNode'
108 developedSurface1Display.GlyphType = 'Arrow'
109 developedSurface1Display.GlyphTableIndexArray = 'FamilyIdNode'
110 developedSurface1Display.DataAxesGrid = 'GridAxesRepresentation'
111 developedSurface1Display.PolarAxes = 'PolarAxesRepresentation'
112 developedSurface1Display.GaussianRadius = 0.021991148575128558
113 developedSurface1Display.SetScaleArray = ['POINTS', 'FamilyIdNode']
114 developedSurface1Display.ScaleTransferFunction = 'PiecewiseFunction'
115 developedSurface1Display.OpacityArray = ['POINTS', 'FamilyIdNode']
116 developedSurface1Display.OpacityTransferFunction = 'PiecewiseFunction'
117 developedSurface1Display.InputVectors = [None, '']
118 developedSurface1Display.SelectInputVectors = [None, '']
119 developedSurface1Display.WriteLog = ''
120
121 # init the 'PiecewiseFunction' selected for 'ScaleTransferFunction'
122 developedSurface1Display.ScaleTransferFunction.Points = [0.0, 0.0, 0.5, 0.0, 1.1757813367477812e-38, 1.0, 0.5, 0.0]
123
124 # init the 'PiecewiseFunction' selected for 'OpacityTransferFunction'
125 developedSurface1Display.OpacityTransferFunction.Points = [0.0, 0.0, 0.5, 0.0, 1.1757813367477812e-38, 1.0, 0.5, 0.0]
126
127 # hide data in view
128 Hide(multiTSmed, renderView1)
129
130 # update the view to ensure updated data information
131 renderView1.Update()
132
133 #change interaction mode for render view
134 renderView1.InteractionMode = '2D'
135
136 # toggle 3D widget visibility (only when running from the GUI)
137 Hide3DWidgets(proxy=developedSurface1.SliceType)
138
139 # set scalar coloring
140 ColorBy(developedSurface1Display, ('CELLS', 'Pressure'))
141
142 # rescale color and/or opacity maps used to include current data range
143 developedSurface1Display.RescaleTransferFunctionToDataRange(True, False)
144
145 # show color bar/color legend
146 developedSurface1Display.SetScalarBarVisibility(renderView1, True)
147
148 # get color transfer function/color map for 'Pressure'
149 pressureLUT = GetColorTransferFunction('Pressure')
150
151 #### saving camera placements for all active views
152
153 # current camera placement for renderView1
154 renderView1.InteractionMode = '2D'
155 renderView1.CameraPosition = [0.18935662797765695, 0.01726656182167085, 2.08092363470839]
156 renderView1.CameraFocalPoint = [0.18935662797765695, 0.01726656182167085, 0.05000000074505806]
157 renderView1.CameraParallelScale = 0.16748564967020724
158
159 #### uncomment the following to render all views
160 # RenderAllViews()
161 # alternatively, if you want to write images, you can use SaveScreenshot(...).
162 Render()