1#!/usr/bin/env python 2import vtk 3from vtk.util.misc import vtkGetDataRoot 4VTK_DATA_ROOT = vtkGetDataRoot() 5 6# create pipeline 7# 8pl3d = vtk.vtkMultiBlockPLOT3DReader() 9pl3d.SetXYZFileName("" + str(VTK_DATA_ROOT) + "/Data/combxyz.bin") 10pl3d.SetQFileName("" + str(VTK_DATA_ROOT) + "/Data/combq.bin") 11pl3d.SetScalarFunctionNumber(100) 12pl3d.SetVectorFunctionNumber(202) 13pl3d.Update() 14output = pl3d.GetOutput().GetBlock(0) 15# create three line probes 16line = vtk.vtkLineSource() 17line.SetResolution(30) 18transL1 = vtk.vtkTransform() 19transL1.Translate(3.7,0.0,28.37) 20transL1.Scale(5,5,5) 21transL1.RotateY(90) 22tf = vtk.vtkTransformPolyDataFilter() 23tf.SetInputConnection(line.GetOutputPort()) 24tf.SetTransform(transL1) 25probe = vtk.vtkProbeFilter() 26probe.SetInputConnection(tf.GetOutputPort()) 27probe.SetSourceData(output) 28probe.Update() 29transL2 = vtk.vtkTransform() 30transL2.Translate(9.2,0.0,31.20) 31transL2.Scale(5,5,5) 32transL2.RotateY(90) 33tf2 = vtk.vtkTransformPolyDataFilter() 34tf2.SetInputConnection(line.GetOutputPort()) 35tf2.SetTransform(transL2) 36probe2 = vtk.vtkProbeFilter() 37probe2.SetInputConnection(tf2.GetOutputPort()) 38probe2.SetSourceData(output) 39probe2.Update() 40transL3 = vtk.vtkTransform() 41transL3.Translate(13.27,0.0,33.40) 42transL3.Scale(4.5,4.5,4.5) 43transL3.RotateY(90) 44tf3 = vtk.vtkTransformPolyDataFilter() 45tf3.SetInputConnection(line.GetOutputPort()) 46tf3.SetTransform(transL3) 47probe3 = vtk.vtkProbeFilter() 48probe3.SetInputConnection(tf3.GetOutputPort()) 49probe3.SetSourceData(output) 50probe3.Update() 51appendF = vtk.vtkAppendPolyData() 52appendF.AddInputData(probe.GetPolyDataOutput()) 53appendF.AddInputData(probe2.GetPolyDataOutput()) 54appendF.AddInputData(probe3.GetPolyDataOutput()) 55tuber = vtk.vtkTubeFilter() 56tuber.SetInputConnection(appendF.GetOutputPort()) 57tuber.SetRadius(0.1) 58lineMapper = vtk.vtkPolyDataMapper() 59lineMapper.SetInputConnection(tuber.GetOutputPort()) 60lineActor = vtk.vtkActor() 61lineActor.SetMapper(lineMapper) 62probe.Update() 63probe3.Update() 64# probe the line and plot it 65xyplot = vtk.vtkXYPlotActor() 66xyplot.AddDataSetInput(probe.GetOutput()) 67xyplot.AddDataSetInputConnection(probe2.GetOutputPort()) 68xyplot.AddDataSetInput(probe3.GetOutput()) 69xyplot.GetPositionCoordinate().SetValue(0.0,0.67,0) 70xyplot.GetPosition2Coordinate().SetValue(1.0,0.33,0) 71#relative to Position 72xyplot.SetXValuesToArcLength() 73xyplot.SetNumberOfXLabels(6) 74xyplot.SetTitle("Pressure vs. Arc Length (Zoomed View)") 75xyplot.SetXTitle("") 76xyplot.SetYTitle("P") 77xyplot.SetXRange(.1,.35) 78xyplot.SetYRange(.2,.4) 79xyplot.GetProperty().SetColor(0,0,0) 80xyplot.GetProperty().SetLineWidth(2) 81# Set text prop color (same color for backward compat with test) 82# Assign same object to all text props 83tprop = xyplot.GetTitleTextProperty() 84tprop.SetColor(xyplot.GetProperty().GetColor()) 85xyplot.SetAxisTitleTextProperty(tprop) 86xyplot.SetAxisLabelTextProperty(tprop) 87xyplot.SetLabelFormat("%-#6.2f") 88xyplot2 = vtk.vtkXYPlotActor() 89xyplot2.AddDataSetInput(probe.GetOutput()) 90xyplot2.AddDataSetInputConnection(probe2.GetOutputPort()) 91xyplot2.AddDataSetInputConnection(probe3.GetOutputPort()) 92xyplot2.GetPositionCoordinate().SetValue(0.00,0.33,0) 93xyplot2.GetPosition2Coordinate().SetValue(1.0,0.33,0) 94#relative to Position 95xyplot2.SetXValuesToNormalizedArcLength() 96xyplot2.SetNumberOfXLabels(6) 97xyplot2.SetTitle("Pressure vs. Normalized Arc Length") 98xyplot2.SetXTitle("") 99xyplot2.SetYTitle("P") 100xyplot2.PlotPointsOn() 101xyplot2.PlotLinesOff() 102xyplot2.GetProperty().SetColor(1,0,0) 103xyplot2.GetProperty().SetPointSize(2) 104# Set text prop color (same color for backward compat with test) 105# Assign same object to all text props 106tprop = xyplot2.GetTitleTextProperty() 107tprop.SetColor(xyplot2.GetProperty().GetColor()) 108xyplot2.SetAxisTitleTextProperty(tprop) 109xyplot2.SetAxisLabelTextProperty(tprop) 110xyplot2.SetLabelFormat(xyplot.GetLabelFormat()) 111xyplot3 = vtk.vtkXYPlotActor() 112xyplot3.AddDataSetInputConnection(probe.GetOutputPort()) 113xyplot3.AddDataSetInputConnection(probe2.GetOutputPort()) 114xyplot3.AddDataSetInputConnection(probe3.GetOutputPort()) 115xyplot3.GetPositionCoordinate().SetValue(0.0,0.0,0) 116xyplot3.GetPosition2Coordinate().SetValue(1.0,0.33,0) 117#relative to Position 118xyplot3.SetXValuesToIndex() 119xyplot3.SetNumberOfXLabels(6) 120xyplot3.SetTitle("Pressure vs. Point Id") 121xyplot3.SetXTitle("Probe Length") 122xyplot3.SetYTitle("P") 123xyplot3.PlotPointsOn() 124xyplot3.GetProperty().SetColor(0,0,1) 125xyplot3.GetProperty().SetPointSize(3) 126# Set text prop color (same color for backward compat with test) 127# Assign same object to all text props 128tprop = xyplot3.GetTitleTextProperty() 129tprop.SetColor(xyplot3.GetProperty().GetColor()) 130xyplot3.SetAxisTitleTextProperty(tprop) 131xyplot3.SetAxisLabelTextProperty(tprop) 132xyplot3.SetLabelFormat(xyplot.GetLabelFormat()) 133# draw an outline 134outline = vtk.vtkStructuredGridOutlineFilter() 135outline.SetInputData(output) 136outlineMapper = vtk.vtkPolyDataMapper() 137outlineMapper.SetInputConnection(outline.GetOutputPort()) 138outlineActor = vtk.vtkActor() 139outlineActor.SetMapper(outlineMapper) 140outlineActor.GetProperty().SetColor(0,0,0) 141# Create graphics stuff 142# 143ren1 = vtk.vtkRenderer() 144ren2 = vtk.vtkRenderer() 145renWin = vtk.vtkRenderWindow() 146renWin.SetMultiSamples(0) 147renWin.AddRenderer(ren1) 148renWin.AddRenderer(ren2) 149iren = vtk.vtkRenderWindowInteractor() 150iren.SetRenderWindow(renWin) 151ren1.SetBackground(0.6784,0.8471,0.9020) 152ren1.SetViewport(0,0,.5,1) 153ren1.AddActor(outlineActor) 154ren1.AddActor(lineActor) 155ren2.SetBackground(1,1,1) 156ren2.SetViewport(0.5,0.0,1.0,1.0) 157ren2.AddActor2D(xyplot) 158ren2.AddActor2D(xyplot2) 159ren2.AddActor2D(xyplot3) 160renWin.SetSize(790,400) 161cam1 = ren1.GetActiveCamera() 162cam1.SetClippingRange(3.95297,100) 163cam1.SetFocalPoint(8.88908,0.595038,29.3342) 164cam1.SetPosition(-12.3332,31.7479,41.2387) 165cam1.SetViewUp(0.060772,-0.319905,0.945498) 166iren.Initialize() 167# render the image 168# 169# prevent the tk window from showing up then start the event loop 170# --- end of script -- 171