|
| 1 | +#!/usr/bin/env pvbatch |
| 2 | + |
| 3 | +# state file generated using paraview version 5.9.0 |
| 4 | + |
| 5 | +from paraview.simple import * |
| 6 | +paraview.simple._DisableFirstRenderCameraReset() |
| 7 | + |
| 8 | +import argparse |
| 9 | +import os |
| 10 | +import re |
| 11 | +import paratools |
| 12 | + |
| 13 | + |
| 14 | +parser = argparse.ArgumentParser( |
| 15 | + description="Renders interface shapes from s_*.vtk files.") |
| 16 | +parser.add_argument('files', nargs='*', help="list of data files 's_*.vtk'") |
| 17 | +parser.add_argument('--force', |
| 18 | + action="store_true", |
| 19 | + help="overwrite existing files") |
| 20 | +args = parser.parse_args() |
| 21 | + |
| 22 | +renderView1 = CreateView('RenderView') |
| 23 | +renderView1.ViewSize = [1080, 1080] |
| 24 | +renderView1.OrientationAxesVisibility = 0 |
| 25 | +renderView1.UseLight = 0 |
| 26 | +renderView1.CameraPosition = [2, 2, 4] |
| 27 | +renderView1.CameraFocalPoint = [2, 2, 0] |
| 28 | +renderView1.CameraFocalDisk = 1.0 |
| 29 | +renderView1.CameraParallelProjection = 1 |
| 30 | +renderView1.CameraParallelScale = 1.5 |
| 31 | +renderView1.Background = [1] * 3 |
| 32 | + |
| 33 | +# https://github.com/OrdnanceSurvey/GeoDataViz-Toolkit/tree/master/Colours |
| 34 | +clhex_geo = [ |
| 35 | + "FF1F5B", "00CD6C", "009ADE", "AF58BA", "FFC61E", "F28522", "A0B1BA", |
| 36 | + "A6761D", "E9002D", "FFAA00", "00B000" |
| 37 | +] |
| 38 | + |
| 39 | + |
| 40 | +def rgb(h): |
| 41 | + return list(int(h[i:i + 2], 16) / 255. for i in (0, 2, 4)) |
| 42 | + |
| 43 | + |
| 44 | +steps = paratools.ReplaceFilename(args.files, '{}', keep_dir=False) |
| 45 | +source_s = LegacyVTKReader( |
| 46 | + FileNames=paratools.ReplaceFilename(args.files, 's_{}.vtk')) |
| 47 | +source_vf = XDMFReader( |
| 48 | + FileNames=paratools.ReplaceFilename(args.files, 'vf_{}.xmf')) |
| 49 | +source_vf.CellArrayStatus = ['vf'] |
| 50 | +sources_ft, timearrays = paratools.ApplyForceTime([source_s, source_vf]) |
| 51 | +source_s, source_vf = sources_ft |
| 52 | + |
| 53 | +vfDisplay = Show(source_vf, renderView1) |
| 54 | +vfLUT = GetColorTransferFunction('vf') |
| 55 | +vfLUT.AutomaticRescaleRangeMode = 'Never' |
| 56 | +vfLUT.RGBPoints = [0.0] + [1] * 3 + [1.0] + rgb(clhex_geo[2]) |
| 57 | +vfLUT.ColorSpace = 'RGB' |
| 58 | +vfLUT.NanColor = [1.0, 0.0, 0.0] |
| 59 | +vfLUT.Discretize = 0 |
| 60 | +vfLUT.ScalarRangeInitialized = 1.0 |
| 61 | +vfPWF = GetOpacityTransferFunction('vf') |
| 62 | +vfPWF.ScalarRangeInitialized = 1 |
| 63 | +vfDisplay.Representation = 'Surface' |
| 64 | +vfDisplay.ColorArrayName = ['CELLS', 'vf'] |
| 65 | +vfDisplay.LookupTable = vfLUT |
| 66 | + |
| 67 | +surfDisplay = Show(source_s, renderView1) |
| 68 | +surfDisplay.Representation = 'Wireframe' |
| 69 | +surfDisplay.AmbientColor = [0.0, 0.0, 0.0] |
| 70 | +surfDisplay.ColorArrayName = ['POINTS', ''] |
| 71 | +surfDisplay.DiffuseColor = [0.0, 0.0, 0.0] |
| 72 | +surfDisplay.LineWidth = 8 |
| 73 | + |
| 74 | +paratools.SetTimeStep(1, sources_ft, timearrays) |
| 75 | + |
| 76 | +paratools.SaveAnimation(steps, |
| 77 | + renderView1, |
| 78 | + sources_ft, |
| 79 | + timearrays, |
| 80 | + force=args.force) |
0 commit comments