0

I'm trying to extract streamlines from an unstructured grid by using the vtk python library:

import vtk

file_path = "my_file.vtk"

reader = vtk.vtkUnstructuredGridReader()
reader.SetFileName(file_path)
reader.Update()

streamer = vtk.vtkStreamTracer()
streamer.SetInputConnection(reader.GetOutputPort())
streamer.SetIntegratorTypeToRungeKutta45()
streamer.SetMaximumPropagation(500)
streamer.SetMaximumError(1.0e-8)
streamer.SetIntegrationDirection(2)
streamer.SetIntegrationStepUnit(2)
streamer.SetMinimumIntegrationStep(0.01)
streamer.SetMaximumIntegrationStep(0.5)
streamer.SetInitialIntegrationStep(0.2)
streamer.Update()

print(reader.GetOutput().GetNumberOfPoints()) # Output: 990000
print(streamer.GetOutput().GetNumberOfPoints()) # Output: 0

However, it seems that the streamTracer is not extracting any data form the input, as you can see from the last line of code. Am I missing something?

Francesco
  • 169
  • 1
  • 1
  • 8

1 Answers1

1

You need to specify some seeds, i.e. a list of points where the streamlines should pass, using SetSourceData or SetSourceConnection to use the output of a filter / reader / source.

See the doc (c++ but API is quite always the same) and this example

Nico Vuaille
  • 2,310
  • 1
  • 6
  • 14