1 # Copyright (C) 2017-2021 CEA/DEN, EDF R&D
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.
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.
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
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 # Author : Anthony Geay (EDF R&D)
21 #### import the simple module from the paraview
22 from paraview.simple import *
24 TMPFileName="test3.med"
26 #### disable automatic camera reset on 'Show'
27 paraview.simple._DisableFirstRenderCameraReset()
29 # create a new 'Mandelbrot'
30 mandelbrot1 = Mandelbrot()
32 # Properties modified on mandelbrot1
33 mandelbrot1.WholeExtent = [0, 50, 0, 50, 0, 50]
36 renderView1 = GetActiveViewOrCreate('RenderView')
37 # uncomment following to set a specific view size
38 # renderView1.ViewSize = [1017, 317]
41 mandelbrot1Display = Show(mandelbrot1, renderView1)
43 # trace defaults for the display properties.
44 mandelbrot1Display.Representation = 'Outline'
45 mandelbrot1Display.ColorArrayName = ['POINTS', '']
46 mandelbrot1Display.OSPRayScaleArray = 'Iterations'
47 mandelbrot1Display.OSPRayScaleFunction = 'PiecewiseFunction'
48 mandelbrot1Display.SelectOrientationVectors = 'Iterations'
49 mandelbrot1Display.ScaleFactor = 0.25
50 mandelbrot1Display.SelectScaleArray = 'Iterations'
51 mandelbrot1Display.GlyphType = 'Arrow'
52 mandelbrot1Display.GlyphTableIndexArray = 'Iterations'
53 mandelbrot1Display.DataAxesGrid = 'GridAxesRepresentation'
54 mandelbrot1Display.PolarAxes = 'PolarAxesRepresentation'
55 mandelbrot1Display.ScalarOpacityUnitDistance = 0.08124038404635964
56 mandelbrot1Display.Slice = 25
57 mandelbrot1Display.GaussianRadius = 0.125
58 mandelbrot1Display.SetScaleArray = ['POINTS', 'Iterations']
59 mandelbrot1Display.ScaleTransferFunction = 'PiecewiseFunction'
60 mandelbrot1Display.OpacityArray = ['POINTS', 'Iterations']
61 mandelbrot1Display.OpacityTransferFunction = 'PiecewiseFunction'
62 mandelbrot1Display.InputVectors = [None, '']
63 mandelbrot1Display.SelectInputVectors = [None, '']
64 mandelbrot1Display.WriteLog = ''
66 # init the 'PiecewiseFunction' selected for 'ScaleTransferFunction'
67 mandelbrot1Display.ScaleTransferFunction.Points = [1.0, 0.0, 0.5, 0.0, 100.0, 1.0, 0.5, 0.0]
69 # init the 'PiecewiseFunction' selected for 'OpacityTransferFunction'
70 mandelbrot1Display.OpacityTransferFunction.Points = [1.0, 0.0, 0.5, 0.0, 100.0, 1.0, 0.5, 0.0]
72 # reset view to fit data
73 renderView1.ResetCamera()
75 # update the view to ensure updated data information
78 # create a new 'Developed Surface'
79 developedSurface1 = DevelopedSurface(Input=mandelbrot1)
80 developedSurface1.SliceType = 'Cylinder'
82 # init the 'Cylinder' selected for 'SliceType'
83 developedSurface1.SliceType.Center = [-0.5, 0.0, 1.0]
84 developedSurface1.SliceType.Radius = 0.5 #1.25
85 developedSurface1.SliceType.Axis = [-0.5065630563269753, -0.6288876685363318, -0.5898255422814533]
88 developedSurface1Display = Show(developedSurface1, renderView1)
90 # get color transfer function/color map for 'Iterations'
91 iterationsLUT = GetColorTransferFunction('Iterations')
93 # trace defaults for the display properties.
94 developedSurface1Display.Representation = 'Surface'
95 developedSurface1Display.ColorArrayName = ['POINTS', 'Iterations']
96 developedSurface1Display.LookupTable = iterationsLUT
97 developedSurface1Display.OSPRayScaleArray = 'Iterations'
98 developedSurface1Display.OSPRayScaleFunction = 'PiecewiseFunction'
99 developedSurface1Display.SelectOrientationVectors = 'Iterations'
100 developedSurface1Display.ScaleFactor = 0.7853981633974483
101 developedSurface1Display.SelectScaleArray = 'Iterations'
102 developedSurface1Display.GlyphType = 'Arrow'
103 developedSurface1Display.GlyphTableIndexArray = 'Iterations'
104 developedSurface1Display.DataAxesGrid = 'GridAxesRepresentation'
105 developedSurface1Display.PolarAxes = 'PolarAxesRepresentation'
106 developedSurface1Display.GaussianRadius = 0.39269908169872414
107 developedSurface1Display.SetScaleArray = ['POINTS', 'Iterations']
108 developedSurface1Display.ScaleTransferFunction = 'PiecewiseFunction'
109 developedSurface1Display.OpacityArray = ['POINTS', 'Iterations']
110 developedSurface1Display.OpacityTransferFunction = 'PiecewiseFunction'
111 developedSurface1Display.InputVectors = [None, '']
112 developedSurface1Display.SelectInputVectors = [None, '']
113 developedSurface1Display.WriteLog = ''
115 # init the 'PiecewiseFunction' selected for 'ScaleTransferFunction'
116 developedSurface1Display.ScaleTransferFunction.Points = [1.0, 0.0, 0.5, 0.0, 100.0, 1.0, 0.5, 0.0]
118 # init the 'PiecewiseFunction' selected for 'OpacityTransferFunction'
119 developedSurface1Display.OpacityTransferFunction.Points = [1.0, 0.0, 0.5, 0.0, 100.0, 1.0, 0.5, 0.0]
122 Hide(mandelbrot1, renderView1)
124 # show color bar/color legend
125 developedSurface1Display.SetScalarBarVisibility(renderView1, True)
127 # update the view to ensure updated data information
130 # toggle 3D widget visibility (only when running from the GUI)
131 Hide3DWidgets(proxy=developedSurface1.SliceType)
133 #### saving camera placements for all active views
135 # current camera placement for renderView1
136 renderView1.CameraPosition = [4.090024784500779, -0.15919161102314858, 7.485304552729019]
137 renderView1.CameraFocalPoint = [4.090024784500779, -0.15919161102314858, 1.0]
138 renderView1.CameraParallelScale = 2.03100960115899
140 #### uncomment the following to render all views
142 # alternatively, if you want to write images, you can use SaveScreenshot(...).
145 vtp=servermanager.Fetch(developedSurface1)
146 arr=vtp.GetPointData().GetArray(0)
147 assert(arr.GetName()=="Iterations")
149 assert(a>=1 and a<=2)
151 SaveData(TMPFileName, proxy=developedSurface1)
152 from MEDLoader import *
154 mm=MEDFileMesh.New(TMPFileName)
156 area=m0.getMeasureField(True).getArray().accumulate()[0]
159 fs=MEDFileFields(TMPFileName)
160 f=fs["Iterations"][0].field(mm)
161 nodeIds=f.getArray().convertToDblArr().findIdsInRange(99.,101.)
162 cellIds=m0.getCellIdsLyingOnNodes(nodeIds,True)
163 zeResu1=m0[cellIds].getMeasureField(True).getArray().accumulate()[0]
165 assert(abs(zeResu1-1.3564)<1e-2)