I have visualized some arrows from a vtk file, and now I am trying to visualize the stream lines in python by using the VTK package. I can get arrows but not the streamLines. The code;
# File: wind.py
from vtk import *
reader = vtkStructuredPointsReader()
reader.SetFileName("wind.vtk")
reader.Update()
cubeOutline = vtkOutlineFilter()
cubeOutline.SetInputConnection(reader.GetOutputPort())
cubeMapper = vtkPolyDataMapper()
cubeMapper.SetInputConnection(cubeOutline.GetOutputPort())
cubeActor = vtkActor()
cubeActor.SetMapper(cubeMapper)
cubeActor.GetProperty().SetColor(1.0,1.0,1.0)
arrow = vtkArrowSource()
arrow.SetTipRadius(0.2)
arrow.SetShaftRadius(0.075)
arrowGlyph = vtkGlyph3D()
arrowGlyph.SetInputConnection(reader.GetOutputPort())
arrowGlyph.SetSource(arrow.GetOutput())
arrowGlyph.SetScaleFactor(0.05)
arrowMapper = vtkPolyDataMapper()
arrowMapper.SetInputConnection(arrowGlyph.GetOutputPort())
arrowActor = vtkActor()
arrowActor.SetMapper(arrowMapper)
points = vtkPointSource()
points.SetRadius(3.0)
points.SetNumberOfPoints(20)
streamers = vtkStreamLine()
streamers.SetInputConnection(reader.GetOutputPort())
streamers.SetSource(points.GetOutput())
streamers.SpeedScalarsOn()
streamers.SetMaximumPropagationTime(100)
streamers.SetIntegrationStepLength(0.2)
streamers.SetTerminalSpeed(0.1)
streamMapper = vtkPolyDataMapper()
streamMapper.SetInputConnection(streamers.GetOutputPort())
streamMapper.SetScalarRange(reader.GetOutput().GetScalarRange())
streamActor = vtkActor()
streamActor.SetMapper(streamMapper)
ren = vtkRenderer()
ren.SetBackground(.2, .2, .2)
renWin = vtkRenderWindow()
renWin.SetSize(800, 600)
renWin.AddRenderer( ren )
iren = vtkRenderWindowInteractor()
iren.SetRenderWindow( renWin )
ren.AddActor(cubeActor)
ren.AddActor(arrowActor)
ren.AddActor(streamActor)
renWin.Render()
iren.Initialize()
iren.Start()
I cannot see what I am missing.
I have little experience visualizing streamlines and the experience I do have is with vtkteem (vtkSeedTracts).
I assume that the points you are specifying are used as seeds for the streamlines to form from. If that is the case, shouldn’t you also specify a location for these points? I don’t know what your data is like, but I have a feeling that the streamlines aren’t visible because the seed points aren’t specified correctly.
Hope that helps!