File size: 6,018 Bytes
6baf440 | 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 | from paraview.simple import *
# Create a new 'Render View'
renderView1 = CreateView('RenderView')
renderView1.ViewSize = [900, 1400]
# Create a new 'Render View'
renderView2 = CreateView('RenderView')
renderView2.ViewSize = [900, 1400]
SetActiveView(None)
# ----------------------------------------------------------------
# setup view layouts
# ----------------------------------------------------------------
# create new layout object 'Layout #1'
layout1 = CreateLayout(name='Layout #1')
layout1.SplitHorizontal(0, 0.500000)
layout1.AssignView(1, renderView1)
layout1.AssignView(2, renderView2)
layout1.SetSize(1800, 1400)
# ----------------------------------------------------------------
# setup the data processing pipelines
# ----------------------------------------------------------------
# create a new 'XML Rectilinear Grid Reader'
ground_truthvtr = XMLRectilinearGridReader(registrationName='materials_ground_truth.vtr', FileName=['materials/data/materials_ground_truth.vtr'])
# ground_truthvtr = XMLRectilinearGridReader(registrationName='ground_truth.vtr', FileName=['/Users/tpeterka/software/ChatVis-full-paper/examples/science-cases/materials/neg10_ground_truth.vtr'])
ground_truthvtr.CellArrayStatus = ['Intensity', 'Phase']
# create a new 'Cell Data to Point Data'
cellDatatoPointData2 = CellDatatoPointData(registrationName='CellDatatoPointData2', Input=ground_truthvtr)
cellDatatoPointData2.CellDataArraytoprocess = ['Intensity', 'Phase']
# create a new 'Iso Volume'
isoVolume2 = IsoVolume(registrationName='IsoVolume2', Input=cellDatatoPointData2)
isoVolume2.InputScalars = ['POINTS', 'Intensity']
isoVolume2.ThresholdRange = [0.2, 1.0]
# create a new 'XML Rectilinear Grid Reader'
predictionvtr = XMLRectilinearGridReader(registrationName='materials_prediction.vtr', FileName=['materials/data/materials_prediction.vtr'])
# predictionvtr = XMLRectilinearGridReader(registrationName='prediction.vtr', FileName=['/Users/tpeterka/software/ChatVis-full-paper/examples/science-cases/materials/neg10_prediction.vtr'])
predictionvtr.CellArrayStatus = ['Intensity', 'Phase']
# create a new 'Cell Data to Point Data'
cellDatatoPointData1 = CellDatatoPointData(registrationName='CellDatatoPointData1', Input=predictionvtr)
cellDatatoPointData1.CellDataArraytoprocess = ['Intensity', 'Phase']
# create a new 'Iso Volume'
isoVolume1 = IsoVolume(registrationName='IsoVolume1', Input=cellDatatoPointData1)
isoVolume1.InputScalars = ['POINTS', 'Intensity']
isoVolume1.ThresholdRange = [0.2, 1.0]
# create a new 'Clip'
clip1 = Clip(registrationName='Clip1', Input=isoVolume1)
clip1.ClipType = 'Plane'
# init the 'Plane' selected for 'ClipType'
clip1.ClipType.Origin = [32.0, 32.0, 32.0]
# create a new 'Text'
text1 = Text(registrationName='Text1')
text1.Text = 'NN Prediction'
# create a new 'Text'
text2 = Text(registrationName='Text2')
text2.Text = 'Ground Truth'
# create a new 'Clip'
clip2 = Clip(registrationName='Clip2', Input=isoVolume2)
clip2.ClipType = 'Plane'
# init the 'Plane' selected for 'ClipType'
clip2.ClipType.Origin = [32.0, 32.0, 32.0]
# ----------------------------------------------------------------
# setup the visualization in view 'renderView1'
# ----------------------------------------------------------------
# get color transfer function/color map for 'Phase'
phaseLUT = GetColorTransferFunction('Phase')
phaseLUT.ApplyPreset("Viridis (matplotlib)")
# show data from clip1
clip1Display = Show(clip1, renderView1, 'UnstructuredGridRepresentation')
clip1Display.ColorArrayName = ['POINTS', 'Phase']
clip1Display.LookupTable = phaseLUT
clip1Display.RescaleTransferFunctionToDataRange(True)
clip1Display.SetScalarBarVisibility(renderView1, True)
# show data from text1
text1Display = Show(text1, renderView1, 'TextSourceRepresentation')
text1Display.Color = [0.0, 0.0, 0.0]
text1Display.FontFamily = 'Times'
text1Display.FontSize = 60
# get color legend/bar for phaseLUT in view renderView1
phaseLUTColorBar = GetScalarBar(phaseLUT, renderView1)
phaseLUTColorBar.WindowLocation = 'Any Location'
phaseLUTColorBar.Position = [0.8175077041602465, 0.01181592039800995]
phaseLUTColorBar.Title = 'Phase'
phaseLUTColorBar.ComponentTitle = ''
phaseLUTColorBar.TitleColor = [0.0, 0.0, 0.0]
phaseLUTColorBar.TitleFontFamily = 'Times'
phaseLUTColorBar.LabelColor = [0.0, 0.0, 0.0]
phaseLUTColorBar.LabelFontFamily = 'Times'
phaseLUTColorBar.Visibility = 1
# ----------------------------------------------------------------
# setup the visualization in view 'renderView2'
# ----------------------------------------------------------------
# show data from clip2
clip2Display = Show(clip2, renderView2, 'UnstructuredGridRepresentation')
clip2Display.ColorArrayName = ['POINTS', 'Phase']
clip2Display.LookupTable = phaseLUT
clip2Display.RescaleTransferFunctionToDataRange(True)
clip2Display.SetScalarBarVisibility(renderView2, True)
# show data from text2
text2Display = Show(text2, renderView2, 'TextSourceRepresentation')
text2Display.Color = [0.0, 0.0, 0.0]
text2Display.FontFamily = 'Times'
text2Display.FontSize = 60
# get color legend/bar for phaseLUT in view renderView2
phaseLUTColorBar_1 = GetScalarBar(phaseLUT, renderView2)
phaseLUTColorBar_1.Title = 'Phase'
phaseLUTColorBar_1.ComponentTitle = ''
phaseLUTColorBar_1.TitleColor = [0.0, 0.0, 0.0]
phaseLUTColorBar_1.TitleFontFamily = 'Times'
phaseLUTColorBar_1.LabelColor = [0.0, 0.0, 0.0]
phaseLUTColorBar_1.LabelFontFamily = 'Times'
phaseLUTColorBar_1.Visibility = 1
# set camera direction
SetActiveView(renderView1)
renderView1.ResetActiveCameraToNegativeZ()
camera = GetActiveCamera()
camera.Yaw(45)
renderView1.ResetCamera(True, 0.9)
SetActiveView(renderView2)
renderView2.ResetActiveCameraToNegativeZ()
camera = GetActiveCamera()
camera.Yaw(45)
renderView2.ResetCamera(True, 0.9)
# ----------------------------------------------------------------
# save screenshot
# ----------------------------------------------------------------
SaveScreenshot("materials/results/{agent_mode}/materials.png", layout1)
|