Jason Houtekamer
Jason Houtekamer

Reputation: 111

VTK - Using vector data to color vtkStreamTracer lines

As part of an assignment I'm trying to visualize the flow of a viscous liquid through a mixer. The data provided for this is vtk StructuredPoint file, containing both scalar and vector data. The scalar data tells us if a given point is part of the mixer's structure, and the vector data contains the information about the flow of the liquid.

I've visualized the flow using streamlines, created using the vtkStreamTracer class. When the output is passed on to the vtkPolyDataMapper, it seems to default to using the scalar part of the data to color the lines.

I've been trying to find a way to change this, but I haven't been able to do so. I'm trying to use the magnitude of the flow vector to determine the color of the lines, so that the color represents the velocity of the liquid. Any hints? I've included the relevant part of the visualization code below. Thanks in advance!

seeds = vtk.vtkPointSource()
seeds.SetRadius(15)
seeds.SetCenter(0,30.5,30.5)
seeds.SetNumberOfPoints(100)

integrator=vtk.vtkRungeKutta45()
streamer = vtk.vtkStreamTracer()
streamer.SetInputConnection(reader.GetOutputPort())
streamer.SetSourceConnection(seeds.GetOutputPort())
streamer.SetIntegrationDirectionToBoth()
streamer.SetIntegrator(integrator)
streamer.SetMaximumPropagation(500)
streamer.SetComputeVorticity(True)


mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(streamer.GetOutputPort())
actor = vtk.vtkActor()
actor.SetMapper(mapper)

Upvotes: 1

Views: 1209

Answers (1)

MrPedru22
MrPedru22

Reputation: 1344

Check this website: http://www.uppmax.uu.se/docs/w/index.php/Streamlines It has an example of Streamlines that might be useful for you. It uses a color transfer function so that color represents the velocity of the wind in this case, similar to what you are trying to achieve.

Hope this helps!

Upvotes: 1

Related Questions