-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefect_renderizer.py
executable file
·465 lines (359 loc) · 15.7 KB
/
defect_renderizer.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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
#!/home/souzarf/Programas/ParaView/5.4.1/bin/pvbatch
#### import the simple module from the paraview
from paraview.simple import *
import sys
dropletSize=int(sys.argv[-2])
InputFile="./"+str(sys.argv[-1])
OutputFile= InputFile[0:-3]+'png'
SS=0.3
#### disable automatic camera reset on 'Show'
paraview.simple._DisableFirstRenderCameraReset()
# create a new 'CSV Reader'
director_field_42csv = CSVReader(FileName=[InputFile])
# Create a new 'SpreadSheet View'
spreadSheetView1 = CreateView('SpreadSheetView')
spreadSheetView1.ColumnToSort = ''
spreadSheetView1.BlockSize = 1024L
# show data in view
director_field_42csvDisplay = Show(director_field_42csv, spreadSheetView1)
director_field_42csvDisplay.FieldAssociation = 'Row Data'
renderView1 = FindViewOrCreate('RenderView1', viewtype='RenderView')
tableToStructuredGrid1 = TableToStructuredGrid(Input=director_field_42csv)
tableToStructuredGrid1.XColumn = 'x'
tableToStructuredGrid1.YColumn = 'y'
tableToStructuredGrid1.ZColumn = 'z'
tableToStructuredGrid1.WholeExtent = [0, dropletSize, 0, dropletSize, 0, dropletSize]
# reset view to fit data
renderView1.Update()
Hide(tableToStructuredGrid1, renderView1)
# create a new 'Contour'
contour1 = Contour(Input=tableToStructuredGrid1)
contour1.ContourBy = ['POINTS', 'S']
contour1.Isosurfaces = [SS]
contour1.PointMergeMethod = 'Uniform Binning'
# show data in view
contour1Display = Show(contour1, renderView1)
# trace defaults for the display properties.
contour1Display.Representation = 'Surface'
contour1Display.AmbientColor = [0.0, 0.0, 0.0]
contour1Display.ColorArrayName = [None, '']
contour1Display.OSPRayScaleArray = 'Normals'
contour1Display.OSPRayScaleFunction = 'PiecewiseFunction'
contour1Display.SelectOrientationVectors = 'None'
contour1Display.ScaleFactor = 8.897135416666668
contour1Display.SelectScaleArray = 'None'
contour1Display.GlyphType = 'Arrow'
contour1Display.GlyphTableIndexArray = 'None'
contour1Display.DataAxesGrid = 'GridAxesRepresentation'
contour1Display.PolarAxes = 'PolarAxesRepresentation'
contour1Display.GaussianRadius = 4.448567708333334
contour1Display.SetScaleArray = ['POINTS', 'P']
contour1Display.ScaleTransferFunction = 'PiecewiseFunction'
contour1Display.OpacityArray = ['POINTS', 'P']
contour1Display.OpacityTransferFunction = 'PiecewiseFunction'
# init the 'GridAxesRepresentation' selected for 'DataAxesGrid'
contour1Display.DataAxesGrid.XTitleColor = [0.0, 0.0, 0.0]
contour1Display.DataAxesGrid.YTitleColor = [0.0, 0.0, 0.0]
contour1Display.DataAxesGrid.ZTitleColor = [0.0, 0.0, 0.0]
contour1Display.DataAxesGrid.GridColor = [0.0, 0.0, 0.0]
contour1Display.DataAxesGrid.XLabelColor = [0.0, 0.0, 0.0]
contour1Display.DataAxesGrid.YLabelColor = [0.0, 0.0, 0.0]
contour1Display.DataAxesGrid.ZLabelColor = [0.0, 0.0, 0.0]
# init the 'PolarAxesRepresentation' selected for 'PolarAxes'
contour1Display.PolarAxes.PolarAxisTitleColor = [0.0, 0.0, 0.0]
contour1Display.PolarAxes.PolarAxisLabelColor = [0.0, 0.0, 0.0]
contour1Display.PolarAxes.LastRadialAxisTextColor = [0.0, 0.0, 0.0]
contour1Display.PolarAxes.SecondaryRadialAxesTextColor = [0.0, 0.0, 0.0]
# update the view to ensure updated data information
renderView1.Update()
contour1Display = Show(contour1, renderView1)
# change solid color
contour1Display.DiffuseColor = [1.0, 1.0, 0.0]
# set active source
SetActiveSource(tableToStructuredGrid1)
# get color transfer function/color map for 'S'
sLUT = GetColorTransferFunction('S')
sLUT.LockDataRange = 0
sLUT.InterpretValuesAsCategories = 0
sLUT.ShowCategoricalColorsinDataRangeOnly = 0
sLUT.RescaleOnVisibilityChange = 0
sLUT.EnableOpacityMapping = 0
sLUT.RGBPoints = [0.533, 0.231373, 0.298039, 0.752941, 0.5330610313415527, 0.865003, 0.865003, 0.865003, 0.5331220626831055, 0.705882, 0.0156863, 0.14902]
sLUT.UseLogScale = 0
sLUT.ColorSpace = 'Diverging'
sLUT.UseBelowRangeColor = 0
sLUT.BelowRangeColor = [0.0, 0.0, 0.0]
sLUT.UseAboveRangeColor = 0
sLUT.AboveRangeColor = [1.0, 1.0, 1.0]
sLUT.NanColor = [1.0, 1.0, 0.0]
sLUT.Discretize = 1
sLUT.NumberOfTableValues = 256
sLUT.ScalarRangeInitialized = 1.0
sLUT.HSVWrap = 0
sLUT.VectorComponent = 0
sLUT.VectorMode = 'Magnitude'
sLUT.AllowDuplicateScalars = 1
sLUT.Annotations = []
sLUT.ActiveAnnotatedValues = []
sLUT.IndexedColors = []
# get color transfer function/color map for 'GlyphScale'
glyphScaleLUT = GetColorTransferFunction('GlyphScale')
glyphScaleLUT.RGBPoints = [0.14000000059604645, 0.231373, 0.298039, 0.752941, 0.31199999898672104, 0.865003, 0.865003, 0.865003, 0.48399999737739563, 0.705882, 0.0156863, 0.14902]
glyphScaleLUT.ScalarRangeInitialized = 1.0
sPWF = GetOpacityTransferFunction('S')
sPWF.Points = [0.14, 0.0, 0.5, 0.0, 0.484, 1.0, 0.5, 0.0]
sPWF.ScalarRangeInitialized = 1
# Rescale transfer function
sPWF.RescaleTransferFunction(0.0, 0.6)
# get color legend/bar for sLUT in view renderView1
sLUTColorBar = GetScalarBar(sLUT, renderView1)
sLUTColorBar.Title = 'S'
sLUTColorBar.ComponentTitle = ''
sLUTColorBar.TitleColor = [0.0, 0.0, 0.0]
sLUTColorBar.LabelColor = [0.0, 0.0, 0.0]
# change scalar bar placement
sLUTColorBar.WindowLocation = 'AnyLocation'
sLUTColorBar.Position = [0.75, 0.015037593984962405]
# create a new 'Slice'
slice1 = Slice(Input=tableToStructuredGrid1)
slice1.SliceType = 'Plane'
slice1.SliceOffsetValues = [0.0]
slice1.SliceType.Origin = [50.0, 50.0, 50.0]
# create a new 'Threshold'
threshold1 = Threshold(Input=slice1)
threshold1.Scalars = ['POINTS', 'S']
threshold1.ThresholdRange = [0.0, 0.9]
# create a new 'Calculator'
calculator1 = Calculator(Input=threshold1)
calculator1.ResultArrayName = 'n'
calculator1.Function = 'nx*iHat+ny*jHat+nz*kHat'
# create a new 'Glyph'
glyph1 = Glyph(Input=calculator1,
GlyphType='Cylinder')
glyph1.Scalars = ['POINTS', 'S']
glyph1.Vectors = ['POINTS', 'n']
glyph1.ScaleFactor = 1.0
glyph1.GlyphMode = 'All Points'
glyph1.GlyphTransform = 'Transform2'
glyph1.GlyphTransform.Rotate = [0.0, 0.0, 90.0]
glyph1.GlyphType.Height = 0.9
glyph1.GlyphType.Radius = 0.25
# show data in view
glyph1Display = Show(glyph1, renderView1)
# trace defaults for the display properties.
glyph1Display.Representation = 'Surface'
glyph1Display.AmbientColor = [0.0, 0.0, 0.0]
glyph1Display.ColorArrayName = ['POINTS', 'GlyphScale']
glyph1Display.LookupTable = glyphScaleLUT
glyph1Display.OSPRayScaleArray = 'GlyphScale'
glyph1Display.OSPRayScaleFunction = 'PiecewiseFunction'
glyph1Display.SelectOrientationVectors = 'GlyphVector'
glyph1Display.ScaleFactor = 1.
glyph1Display.SelectScaleArray = 'S'
glyph1Display.GlyphType = 'Arrow'
glyph1Display.GlyphTableIndexArray = 'S'
glyph1Display.DataAxesGrid = 'GridAxesRepresentation'
glyph1Display.PolarAxes = 'PolarAxesRepresentation'
glyph1Display.GaussianRadius = 5.049871079623699
glyph1Display.SetScaleArray = ['POINTS', 'GlyphScale']
glyph1Display.ScaleTransferFunction = 'PiecewiseFunction'
glyph1Display.OpacityArray = ['POINTS', 'GlyphScale']
glyph1Display.OpacityTransferFunction = 'PiecewiseFunction'
# init the 'GridAxesRepresentation' selected for 'DataAxesGrid'
glyph1Display.DataAxesGrid.XTitleColor = [0.0, 0.0, 0.0]
glyph1Display.DataAxesGrid.YTitleColor = [0.0, 0.0, 0.0]
glyph1Display.DataAxesGrid.ZTitleColor = [0.0, 0.0, 0.0]
glyph1Display.DataAxesGrid.GridColor = [0.0, 0.0, 0.0]
glyph1Display.DataAxesGrid.XLabelColor = [0.0, 0.0, 0.0]
glyph1Display.DataAxesGrid.YLabelColor = [0.0, 0.0, 0.0]
glyph1Display.DataAxesGrid.ZLabelColor = [0.0, 0.0, 0.0]
# init the 'PolarAxesRepresentation' selected for 'PolarAxes'
glyph1Display.PolarAxes.PolarAxisTitleColor = [0.0, 0.0, 0.0]
glyph1Display.PolarAxes.PolarAxisLabelColor = [0.0, 0.0, 0.0]
glyph1Display.PolarAxes.LastRadialAxisTextColor = [0.0, 0.0, 0.0]
glyph1Display.PolarAxes.SecondaryRadialAxesTextColor = [0.0, 0.0, 0.0]
# show color bar/color legend
ColorBy(glyph1Display, ('POINTS', 'S'))
# current camera placement for renderView1
renderView1.CameraPosition = [dropletSize, dropletSize/2, dropletSize/2]
renderView1.CameraFocalPoint = [ dropletSize/2, dropletSize/2, dropletSize/2]
renderView1.CameraViewUp = [0.0, 0.0, 1.0]
renderView1.CameraParallelScale = dropletSize/(1.97)
renderView1.CameraParallelProjection = 1
sLUT.RescaleTransferFunction(0.0, 0.6)
# save screenshot
SaveScreenshot('/home/souzarf/x_plane.png', renderView1, ImageResolution=[3076, 3076],FontScaling='Scale fonts proportionally',
SeparatorWidth=0,
SeparatorColor=[0.0, 0.0, 0.0],
OverrideColorPalette='',
StereoMode='No change',
TransparentBackground=0,
ImageQuality=100)
Hide(glyph1, renderView1)
SetActiveSource(tableToStructuredGrid1)
# create a new 'Slice'
slice2 = Slice(Input=tableToStructuredGrid1)
slice2.SliceType = 'Plane'
slice2.SliceOffsetValues = [0.0]
slice2.SliceType.Origin = [50.0, 50.0, 50.0]
slice2.SliceType.Normal = [0.0, 1.0, 0.0]
# create a new 'Threshold'
threshold2 = Threshold(Input=slice2)
threshold2.Scalars = ['POINTS', 'S']
threshold2.ThresholdRange = [0.0, 0.9]
# create a new 'Calculator'
calculator2 = Calculator(Input=threshold2)
calculator2.ResultArrayName = 'n'
calculator2.Function = 'nx*iHat+ny*jHat+nz*kHat'
# create a new 'Glyph'
glyph2 = Glyph(Input=calculator2,
GlyphType='Cylinder')
glyph2.Scalars = ['POINTS', 'S']
glyph2.Vectors = ['POINTS', 'n']
glyph2.ScaleFactor = 1.0
glyph2.GlyphMode = 'All Points'
glyph2.GlyphTransform = 'Transform2'
glyph2.GlyphType.Height = 0.9
glyph2.GlyphType.Radius = 0.25
glyph2.GlyphTransform.Rotate = [0.0, 0.0, 90.0]
# get color transfer function/color map for 'GlyphScale'
glyphScaleLUT = GetColorTransferFunction('GlyphScale')
glyphScaleLUT.RGBPoints = [0.14000000059604645, 0.231373, 0.298039, 0.752941, 0.31199999898672104, 0.865003, 0.865003, 0.865003, 0.48399999737739563, 0.705882, 0.0156863, 0.14902]
glyphScaleLUT.ScalarRangeInitialized = 1.0
# show data in view
glyph2Display = Show(glyph2, renderView1)
# trace defaults for the display properties.
glyph2Display.Representation = 'Surface'
glyph2Display.AmbientColor = [0.0, 0.0, 0.0]
glyph2Display.ColorArrayName = ['POINTS', 'GlyphScale']
glyph2Display.LookupTable = glyphScaleLUT
glyph2Display.OSPRayScaleArray = 'GlyphScale'
glyph2Display.OSPRayScaleFunction = 'PiecewiseFunction'
glyph2Display.SelectOrientationVectors = 'GlyphVector'
glyph2Display.ScaleFactor = 10.099742159247398
glyph2Display.SelectScaleArray = 'GlyphScale'
glyph2Display.GlyphType = 'Arrow'
glyph2Display.GlyphTableIndexArray = 'GlyphScale'
glyph2Display.DataAxesGrid = 'GridAxesRepresentation'
glyph2Display.PolarAxes = 'PolarAxesRepresentation'
glyph2Display.GaussianRadius = 5.049871079623699
glyph2Display.SetScaleArray = ['POINTS', 'GlyphScale']
glyph2Display.ScaleTransferFunction = 'PiecewiseFunction'
glyph2Display.OpacityArray = ['POINTS', 'GlyphScale']
glyph2Display.OpacityTransferFunction = 'PiecewiseFunction'
# init the 'GridAxesRepresentation' selected for 'DataAxesGrid'
glyph1Display.DataAxesGrid.XTitleColor = [0.0, 0.0, 0.0]
glyph1Display.DataAxesGrid.YTitleColor = [0.0, 0.0, 0.0]
glyph1Display.DataAxesGrid.ZTitleColor = [0.0, 0.0, 0.0]
glyph1Display.DataAxesGrid.GridColor = [0.0, 0.0, 0.0]
glyph1Display.DataAxesGrid.XLabelColor = [0.0, 0.0, 0.0]
glyph1Display.DataAxesGrid.YLabelColor = [0.0, 0.0, 0.0]
glyph1Display.DataAxesGrid.ZLabelColor = [0.0, 0.0, 0.0]
# init the 'PolarAxesRepresentation' selected for 'PolarAxes'
glyph1Display.PolarAxes.PolarAxisTitleColor = [0.0, 0.0, 0.0]
glyph1Display.PolarAxes.PolarAxisLabelColor = [0.0, 0.0, 0.0]
glyph1Display.PolarAxes.LastRadialAxisTextColor = [0.0, 0.0, 0.0]
glyph1Display.PolarAxes.SecondaryRadialAxesTextColor = [0.0, 0.0, 0.0]
# update the view to ensure updated data information
renderView1.Update()
# set scalar coloring
ColorBy(glyph2Display, ('POINTS', 'S'))
SetActiveSource(glyph2)
# Hide the scalar bar for this color map if no visible data is colored by it.
HideScalarBarIfNotNeeded(glyphScaleLUT, renderView1)
glyph2Display.SetScalarBarVisibility(renderView1, True)
# current camera placement for renderView1
renderView1.CameraPosition = [dropletSize/2, dropletSize, dropletSize/2]
renderView1.CameraFocalPoint = [ dropletSize/2, dropletSize/2, dropletSize/2]
renderView1.CameraViewUp = [1.0, 0.0, 0.0]
renderView1.CameraParallelProjection = 1
sLUT.RescaleTransferFunction(0.0, 0.6)
# save screenshot
SaveScreenshot('/home/souzarf/y_plane.png', renderView1, ImageResolution=[3076, 3076],FontScaling='Scale fonts proportionally',
SeparatorWidth=0,
SeparatorColor=[0.0, 0.0, 0.0],
OverrideColorPalette='',
StereoMode='No change',
TransparentBackground=0,
ImageQuality=100)
Hide(glyph2, renderView1)
# set active source
SetActiveSource(tableToStructuredGrid1)
# create a new 'Slice'
slice3 = Slice(Input=tableToStructuredGrid1)
slice3.SliceType = 'Plane'
slice3.SliceOffsetValues = [0.0]
slice3.SliceType.Origin = [50.0, 50.0, 50.0]
slice3.SliceType.Normal = [0.0, 0.0, 1.0]
# create a new 'Threshold'
threshold3 = Threshold(Input=slice3)
threshold3.Scalars = ['POINTS', 'S']
threshold3.ThresholdRange = [0.0, 0.9]
# update the view to ensure updated data information
renderView1.Update()
# create a new 'Calculator'
calculator3 = Calculator(Input=threshold3)
calculator3.ResultArrayName = 'n'
calculator3.Function = 'nx*iHat+ny*jHat+nz*kHat'
# create a new 'Glyph'
glyph3 = Glyph(Input=calculator3,
GlyphType='Cylinder')
glyph3.Scalars = ['POINTS', 'S']
glyph3.Vectors = ['POINTS', 'n']
glyph3.ScaleFactor = 1.0
glyph3.GlyphMode = 'All Points'
glyph3.GlyphTransform = 'Transform2'
glyph3.GlyphTransform.Rotate = [0.0, 0.0, 90.0]
glyph3.GlyphType.Height = 0.9
glyph3.GlyphType.Radius = 0.25
# show data in view
glyph3Display = Show(glyph3, renderView1)
# trace defaults for the display properties.
glyph3Display.Representation = 'Surface'
glyph3Display.AmbientColor = [0.0, 0.0, 0.0]
glyph3Display.ColorArrayName = ['POINTS', 'S']
glyph3Display.LookupTable = sLUT
glyph3Display.OSPRayScaleArray = 'GlyphScale'
glyph3Display.OSPRayScaleFunction = 'PiecewiseFunction'
glyph3Display.SelectOrientationVectors = 'GlyphVector'
glyph3Display.ScaleFactor = 1.
glyph3Display.SelectScaleArray = 'GlyphScale'
glyph3Display.GlyphTableIndexArray = 'GlyphScale'
glyph3Display.DataAxesGrid = 'GridAxesRepresentation'
glyph3Display.PolarAxes = 'PolarAxesRepresentation'
glyph3Display.GaussianRadius = 5.050078421831131
glyph3Display.SetScaleArray = ['POINTS', 'GlyphScale']
glyph3Display.ScaleTransferFunction = 'PiecewiseFunction'
glyph3Display.OpacityArray = ['POINTS', 'GlyphScale']
glyph3Display.OpacityTransferFunction = 'PiecewiseFunction'
# init the 'GridAxesRepresentation' selected for 'DataAxesGrid'
glyph3Display.DataAxesGrid.XTitleColor = [0.0, 0.0, 0.0]
glyph3Display.DataAxesGrid.YTitleColor = [0.0, 0.0, 0.0]
glyph3Display.DataAxesGrid.ZTitleColor = [0.0, 0.0, 0.0]
glyph3Display.DataAxesGrid.GridColor = [0.0, 0.0, 0.0]
glyph3Display.DataAxesGrid.XLabelColor = [0.0, 0.0, 0.0]
glyph3Display.DataAxesGrid.YLabelColor = [0.0, 0.0, 0.0]
glyph3Display.DataAxesGrid.ZLabelColor = [0.0, 0.0, 0.0]
# init the 'PolarAxesRepresentation' selected for 'PolarAxes'
glyph3Display.PolarAxes.PolarAxisTitleColor = [0.0, 0.0, 0.0]
glyph3Display.PolarAxes.PolarAxisLabelColor = [0.0, 0.0, 0.0]
glyph3Display.PolarAxes.LastRadialAxisTextColor = [0.0, 0.0, 0.0]
glyph3Display.PolarAxes.SecondaryRadialAxesTextColor = [0.0, 0.0, 0.0]
ColorBy(glyph3Display, ('POINTS', 'S'))
# current camera placement for renderView1
renderView1.CameraPosition = [dropletSize/2,dropletSize/2 ,dropletSize]
renderView1.CameraFocalPoint = [dropletSize/2,dropletSize/2,dropletSize/2]
renderView1.CameraViewUp = [0.0, 1.0, 0.0]
renderView1.CameraParallelScale = dropletSize/(1.97)
renderView1.CameraParallelProjection = 1
sLUT.RescaleTransferFunction(0.0, 0.6)
# save screenshot
sLUT.RescaleTransferFunction(0.0, 0.6)
# save screenshot
SaveScreenshot('/home/souzarf/z_plane.png', renderView1, ImageResolution=[3076, 3076],FontScaling='Scale fonts proportionally',
SeparatorWidth=0,
SeparatorColor=[0.0, 0.0, 0.0],
OverrideColorPalette='',
StereoMode='No change',
TransparentBackground=0,
ImageQuality=100)