-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparasol_y.py
165 lines (124 loc) · 5.27 KB
/
parasol_y.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# trace generated using paraview version 5.6.0
#
# To ensure correct image size when batch processing, please search
# for and uncomment the line `# renderView*.ViewSize = [*,*]`
#### import the simple module from the paraview
from paraview.simple import *
import sys
import numpy as np
#### disable automatic camera reset on 'Show'
paraview.simple._DisableFirstRenderCameraReset()
print sys.argv[1],'->',sys.argv[2]
DirectorScale=float(sys.argv[3])
FractionOfPoints=float(sys.argv[4])
# create a new 'CSV Reader'
cutycsv = CSVReader(FileName=[sys.argv[1]])
# create a new 'Table To Points'
tableToPoints1 = TableToPoints(Input=cutycsv)
tableToPoints1.XColumn = 'x'
tableToPoints1.YColumn = 'y'
tableToPoints1.ZColumn = 'z'
# Properties modified on tableToPoints1
# get active view
renderView1 = GetActiveViewOrCreate('RenderView')
# uncomment following to set a specific view size
# renderView1.ViewSize = [1058, 487]
# get the material library
materialLibrary1 = GetMaterialLibrary()
# update the view to ensure updated data information
renderView1.Update()
# create a new 'Calculator'
calculator1 = Calculator(Input=tableToPoints1)
calculator1.ResultArrayName = 'n'
calculator1.Function = 'nx*iHat+ny*jHat+nz*kHat'
NumberOfPoints= calculator1.PointData.GetArray("nx").GetNumberOfTuples()
# create a new 'Glyph'
glyph1 = Glyph(Input=calculator1,
GlyphType='Cylinder')
glyph1.OrientationArray = ['POINTS', 'n']
glyph1.ScaleArray = ['POINTS', 'No scale array']
glyph1.ScaleFactor = DirectorScale
glyph1.GlyphTransform = 'Transform2'
glyph1.GlyphMode = 'Uniform Spatial Distribution'
glyph1.MaximumNumberOfSamplePoints = int(NumberOfPoints*FractionOfPoints)
glyph1.Seed = 12121
# Properties modified on glyph1.GlyphType
glyph1.GlyphType.Radius = 0.2
# Properties modified on glyph1.GlyphTransform
glyph1.GlyphTransform.Rotate = [0.0, 0.0, 90.0]
# show data in view
glyph1Display = Show(glyph1, renderView1)
# trace defaults for the display properties.
glyph1Display.Representation = 'Surface'
glyph1Display.ColorArrayName = [None, '']
glyph1Display.OSPRayScaleArray = 'Normals'
glyph1Display.OSPRayScaleFunction = 'PiecewiseFunction'
glyph1Display.SelectOrientationVectors = 'None'
glyph1Display.ScaleFactor = 4.500537884235382
glyph1Display.SelectScaleArray = 'None'
glyph1Display.GlyphType = 'Arrow'
glyph1Display.GlyphTableIndexArray = 'None'
glyph1Display.GaussianRadius = 0.2250268942117691
glyph1Display.SetScaleArray = ['POINTS', 'Normals']
glyph1Display.ScaleTransferFunction = 'PiecewiseFunction'
glyph1Display.OpacityArray = ['POINTS', 'Normals']
glyph1Display.OpacityTransferFunction = 'PiecewiseFunction'
glyph1Display.DataAxesGrid = 'GridAxesRepresentation'
glyph1Display.SelectionCellLabelFontFile = ''
glyph1Display.SelectionPointLabelFontFile = ''
glyph1Display.PolarAxes = 'PolarAxesRepresentation'
# init the 'GridAxesRepresentation' selected for 'DataAxesGrid'
glyph1Display.DataAxesGrid.XTitleFontFile = ''
glyph1Display.DataAxesGrid.YTitleFontFile = ''
glyph1Display.DataAxesGrid.ZTitleFontFile = ''
glyph1Display.DataAxesGrid.XLabelFontFile = ''
glyph1Display.DataAxesGrid.YLabelFontFile = ''
glyph1Display.DataAxesGrid.ZLabelFontFile = ''
# init the 'PolarAxesRepresentation' selected for 'PolarAxes'
glyph1Display.PolarAxes.PolarAxisTitleFontFile = ''
glyph1Display.PolarAxes.PolarAxisLabelFontFile = ''
glyph1Display.PolarAxes.LastRadialAxisTextFontFile = ''
glyph1Display.PolarAxes.SecondaryRadialAxesTextFontFile = ''
# update the view to ensure updated data information
renderView1.Update()
# set scalar coloring
ColorBy(glyph1Display, ('POINTS', 'S'))
# rescale color and/or opacity maps used to include current data range
glyph1Display.RescaleTransferFunctionToDataRange(True, False)
# show color bar/color legend
glyph1Display.SetScalarBarVisibility(renderView1, True)
# get color transfer function/color map for 'S'
sLUT = GetColorTransferFunction('S')
sLUT.RGBPoints = [0.53286, 0.231373, 0.298039, 0.752941, 0.532921025686264, 0.865003, 0.865003, 0.865003, 0.5329820513725281, 0.705882, 0.0156863, 0.14902]
sLUT.ScalarRangeInitialized = 1.0
# get opacity transfer function/opacity map for 'S'
sPWF = GetOpacityTransferFunction('S')
sPWF.Points = [0.53286, 0.0, 0.5, 0.0, 0.5329820513725281, 1.0, 0.5, 0.0]
sPWF.ScalarRangeInitialized = 1
Xmin,Xmax,Ymin,Ymax,Zmin,Zmax =calculator1.GetDataInformation().GetBounds()
deltaX=Xmax-Xmin
deltaY=Ymax-Ymin
deltaZ=Zmax-Zmin
deltaM=max(deltaX,deltaY,deltaZ)
Xavg=(Xmax+Xmin)/2
Yavg=(Ymax+Ymin)/2
Zavg=(Zmax+Zmin)/2
AspectRatio=deltaZ/deltaX
renderView1.OrientationAxesVisibility = 1
glyph1Display.RescaleTransferFunctionToDataRange(True, True)
# current camera placement for renderView1
renderView1.ResetCamera()
renderView1.InteractionMode = '2D'
renderView1.CameraPosition = [Xavg,Yavg+deltaM/10.,Zavg]
renderView1.CameraFocalPoint = [Xavg,Yavg,Zavg]
renderView1.CameraViewUp = [0.0, 0.0, 1.0]
renderView1.CameraParallelProjection = 1
renderView1.CameraParallelScale = AspectRatio*deltaM/1.95
renderView1.Background = [.65, .65, .65]
# save screenshot
ImageRessX=4000
ImageRessY=int(ImageRessX*AspectRatio)
SaveScreenshot(sys.argv[2], renderView1, ImageResolution=[ImageRessX, ImageRessY],FontScaling='Do not scale fonts')
#### uncomment the following to render all views
# RenderAllViews()
# alternatively, if you want to write images, you can use SaveScreenshot(...).