简体   繁体   English

VTK中的streamLines

[英]streamLines in VTK

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. 我已经可视化了来自vtk文件的一些箭头,现在我正在尝试使用VTK包来可视化python中的流线。 I can get arrows but not the streamLines. 我可以得到箭头,但不能得到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). 我几乎没有可视化简化流程的经验,而我的经验是使用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! 希望有帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM