q: streamers

gvwilson at nevex.com gvwilson at nevex.com
Tue Aug 31 12:08:18 EDT 1999


Hi.  I'm new to VTK, and am trying to put streamers (like those shown in
the "Kitchen" example on pg. 174 or Kitchen.cxx) into the "comb" data set
(used in the velocity profile example on page 168 or velProf.tcl).  I'm
including what I have so far (which runs, but doesn't work), and I'd be
grateful to anyone who could answer the following questions:

1. In lines 33-36, I'm trying to extract the XYZ coordinates of the points
halfway up the left-hand face of the data volume.  If the volume were
cubic, the coordinates would be [0, 0, zMax/2] and [0, yMax, zMax/2].  I
can get the dimensions of the data set, but I need to translate my
coordinates into scalar point indices --- how do I do this?

2. Line 51 sets the input of the vtkStreamLine object to be the output of
the vtkPLOT3DReader object.  I thought this should work, since I've
specified that the only thing I want out of the data set is the velocity
information (function number 200, line 19) --- can someone confirm?

3. Line 53 sets the maximum propagation time to an arbitrary value (line
53, using a value defined on line 4). I'd like to have this adjust
automatically based on the input data --- is this possible?  If so, can
someone show me how?

4. Line 60 sets the scalar range of the streamer mapper to an arbitrary
value.  I know I should be taking this from the data set --- where and how
should I get this information?

Thanks very much,
Greg Wilson

p.s. For those who haven't seen it yet, http://openscience.bnl.gov/ looks
very interesting...

001 from VTK import *
002
003 Resolution = 9
004 MaxTime = 1000.0
005
006 # boilerplate to create rendering control
007 renWin = vtkRenderWindow()
008 renWin.SetSize(500, 500)
009 renderer = vtkRenderer()
010 renWin.AddRenderer(renderer)
011 renderer.SetBackground(1., 1., 1.)
012 iren = vtkRenderWindowInteractor()
013 iren.SetRenderWindow(renWin)
014 
015 # load data
016 pl3d = vtkPLOT3DReader()
017 pl3d.SetXYZFileName("../../data/airflow/combxyz.bin")
018 pl3d.SetQFileName("../../data/airflow/combq.bin")
019 pl3d.SetVectorFunctionNumber(200)
020 pl3d.Update()
021 
022 # put an outline around the data
023 outline = vtkStructuredGridOutlineFilter()
024 outline.SetInput(pl3d.GetOutput())
025 outlineMapper = vtkPolyDataMapper()
026 outlineMapper.SetInput(outline.GetOutput())
027 outlineActor = vtkActor()
028 outlineActor.SetMapper(outlineMapper)
029 outlineActor.GetProperty().SetColor(0, 0, 0)
030 
031 # find extent of data
032 dims = pl3d.GetOutput().GetDimensions()
033 lowIndex = (((0 * dims[0]) + 0) * dims[1]) + dims[2]/2
034 highIndex = (((0 * dims[0]) + dims[1]-1) * dims[1]) + dims[2]/2
035 lowPoint = pl3d.GetOutput().GetPoint(lowIndex)
036 highPoint = pl3d.GetOutput().GetPoint(highIndex)
037 
038 # add a rake
039 rakeSource = vtkLineSource()
040 rakeSource.SetResolution(Resolution)
041 rakeSource.SetPoint1(lowPoint)
042 rakeSource.SetPoint2(highPoint)
043 rakeMapper = vtkPolyDataMapper()
044 rakeMapper.SetInput(rakeSource.GetOutput())
045 rake = vtkActor()
046 rake.SetMapper(rakeMapper)
047 rake.GetProperty().SetColor(1, .2, .2)
048 
049 # create streamlines
050 streamerSource = vtkStreamLine()
051 streamerSource.SetInput(pl3d.GetOutput()) # ???
052 streamerSource.SetSource(rakeSource.GetOutput())
053 streamerSource.SetMaximumPropagationTime(MaxTime)
054 streamerSource.SetStepLength(MaxTime / 50.0)
055 streamerSource.SetIntegrationStepLength(0.2)
056 streamerSource.Update()
057 
058 streamersMapper = vtkPolyDataMapper()
059 streamersMapper.SetInput(streamerSource.GetOutput())
060 streamersMapper.SetScalarRange((0.0, 10.0))
061 streamersMapper.ScalarVisibilityOff()
062 
063 streamers = vtkActor()
064 streamers.SetMapper(streamersMapper)
065 streamers.GetProperty().SetColor(0, 0, 0)
066 
067 # create the scene
068 renderer.AddActor(outlineActor)
069 renderer.AddActor(rake)
070 renderer.AddActor(streamers)
071 
072 # display
073 iren.Initialize()
074 iren.Start()




-----------------------------------------------------------------------------
This is the private VTK discussion list.  Please keep messages on-topic.
Check the FAQ at: <http://www.automatrix.com/cgi-bin/vtkfaq>
To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
<majordomo at gsao.med.ge.com>.  For help, send message body containing
"info vtkusers" to the same address.     Live long and prosper.
-----------------------------------------------------------------------------





More information about the vtkusers mailing list