Discussion:
[vtkusers] Question to use the vtkStreamTracer
Yu Zhou
2018-10-29 22:27:30 UTC
Permalink
Hello,


I have a problem with vtkStreamTracer.


Here is the code:


```

def generate_streamline(source_file, dest_file, axis, resolution=1):
reader = vtk.vtkXMLImageDataReader()
reader.SetFileName(source_file)
reader.GetPointDataArraySelection().DisableArray('density')
reader.Update()
extent = reader.GetOutput().GetExtent()
center = [np.mean(extent[0:2]), np.mean(extent[2:4]), np.mean(extent[4:6])]

seeds = vtk.vtkPointSource()
seeds.SetCenter(center)
seeds.SetRadius(10.5)
seeds.SetNumberOfPoints(100)
seeds.Update()

streamTracer = vtk.vtkStreamTracer()
streamTracer.SetInterpolatorTypeToDataSetPointLocator()
streamTracer.SetInputData(reader.GetOutputDataObject(0))
streamTracer.SetSourceData(seeds.GetOutputDataObject(0))
streamTracer.SetIntegratorTypeToRungeKutta45()
streamTracer.SetMaximumPropagation(104)
streamTracer.SetInitialIntegrationStep(0.2)
streamTracer.SetMaximumIntegrationStep(0.5)
streamTracer.SetIntegrationDirectionToBoth()
streamTracer.SetStartPosition(center)
streamTracer.SurfaceStreamlinesOn()
streamTracer.Update()

print(streamTracer.GetOutputDataObject(0))

```

The output is:
```

vtkPolyData (0x273ece0)
Debug: Off
Modified Time: 2638
Reference Count: 2
Registered Events: (none)
Information: 0x2ccb540
Data Released: False
Global Release Data: Off
UpdateTime: 2680
Field Data:
Debug: Off
Modified Time: 2628
Reference Count: 1
Registered Events: (none)
Number Of Arrays: 0
Number Of Components: 0
Number Of Tuples: 0
Number Of Points: 0
Number Of Cells: 0
Cell Data:
Debug: Off
Modified Time: 2636
Reference Count: 1
Registered Events:
Registered Observers:
vtkObserver (0x2ccc370)
Event: 33
EventName: ModifiedEvent
Command: 0x2ccb880
Priority: 0
Tag: 1
Number Of Arrays: 0
Number Of Components: 0
Number Of Tuples: 0
Copy Tuple Flags: ( 1 1 1 1 1 0 1 1 )
Interpolate Flags: ( 1 1 1 1 1 0 0 1 )
Pass Through Flags: ( 1 1 1 1 1 1 1 1 )
Scalars: (none)
Vectors: (none)
Normals: (none)
TCoords: (none)
Tensors: (none)
GlobalIds: (none)
PedigreeIds: (none)
EdgeFlag: (none)
Point Data:
Debug: Off
Modified Time: 2638
Reference Count: 1
Registered Events:
Registered Observers:
vtkObserver (0x2ccc210)
Event: 33
EventName: ModifiedEvent
Command: 0x2ccb880
Priority: 0
Tag: 1
Number Of Arrays: 0
Number Of Components: 0
Number Of Tuples: 0
Copy Tuple Flags: ( 1 1 1 1 1 0 1 1 )
Interpolate Flags: ( 1 1 1 1 1 0 0 1 )
Pass Through Flags: ( 1 1 1 1 1 1 1 1 )
Scalars: (none)
Vectors: (none)
Normals: (none)
TCoords: (none)
Tensors: (none)
GlobalIds: (none)
PedigreeIds: (none)
EdgeFlag: (none)
Bounds:
Xmin,Xmax: (1, -1)
Ymin,Ymax: (1, -1)
Zmin,Zmax: (1, -1)
Compute Time: 2692
Number Of Points: 0
Point Coordinates: 0
Locator: 0
Number Of Vertices: 0
Number Of Lines: 0
Number Of Polygons: 0
Number Of Triangle Strips: 0
Number Of Pieces: 1
Piece: 0
Ghost Level: 0
```

And I get an empty vtkPolyData without any streamline in it.

Attached please find the testing dataset.


Please help me.


Thanks,


Joey
kenichiro yoshimi
2018-11-03 06:19:38 UTC
Permalink
Hi,

You need to call setActivectors on the point data:
reader.GetOutput().GetPointData().SetActiveVectors('velocity')

Regards
2018年10月30日(火) 7:27 Yu Zhou <***@live.com>:
>
> Hello,
>
>
> I have a problem with vtkStreamTracer.
>
> Here is the code:
>
>
> ```
>
> def generate_streamline(source_file, dest_file, axis, resolution=1):
> reader = vtk.vtkXMLImageDataReader()
> reader.SetFileName(source_file)
> reader.GetPointDataArraySelection().DisableArray('density')
> reader.Update()
> extent = reader.GetOutput().GetExtent()
> center = [np.mean(extent[0:2]), np.mean(extent[2:4]), np.mean(extent[4:6])]
>
> seeds = vtk.vtkPointSource()
> seeds.SetCenter(center)
> seeds.SetRadius(10.5)
> seeds.SetNumberOfPoints(100)
> seeds.Update()
>
> streamTracer = vtk.vtkStreamTracer()
> streamTracer.SetInterpolatorTypeToDataSetPointLocator()
> streamTracer.SetInputData(reader.GetOutputDataObject(0))
> streamTracer.SetSourceData(seeds.GetOutputDataObject(0))
> streamTracer.SetIntegratorTypeToRungeKutta45()
> streamTracer.SetMaximumPropagation(104)
> streamTracer.SetInitialIntegrationStep(0.2)
> streamTracer.SetMaximumIntegrationStep(0.5)
> streamTracer.SetIntegrationDirectionToBoth()
> streamTracer.SetStartPosition(center)
> streamTracer.SurfaceStreamlinesOn()
> streamTracer.Update()
>
> print(streamTracer.GetOutputDataObject(0))
>
> ```
>
> The output is:
> ```
>
> vtkPolyData (0x273ece0)
> Debug: Off
> Modified Time: 2638
> Reference Count: 2
> Registered Events: (none)
> Information: 0x2ccb540
> Data Released: False
> Global Release Data: Off
> UpdateTime: 2680
> Field Data:
> Debug: Off
> Modified Time: 2628
> Reference Count: 1
> Registered Events: (none)
> Number Of Arrays: 0
> Number Of Components: 0
> Number Of Tuples: 0
> Number Of Points: 0
> Number Of Cells: 0
> Cell Data:
> Debug: Off
> Modified Time: 2636
> Reference Count: 1
> Registered Events:
> Registered Observers:
> vtkObserver (0x2ccc370)
> Event: 33
> EventName: ModifiedEvent
> Command: 0x2ccb880
> Priority: 0
> Tag: 1
> Number Of Arrays: 0
> Number Of Components: 0
> Number Of Tuples: 0
> Copy Tuple Flags: ( 1 1 1 1 1 0 1 1 )
> Interpolate Flags: ( 1 1 1 1 1 0 0 1 )
> Pass Through Flags: ( 1 1 1 1 1 1 1 1 )
> Scalars: (none)
> Vectors: (none)
> Normals: (none)
> TCoords: (none)
> Tensors: (none)
> GlobalIds: (none)
> PedigreeIds: (none)
> EdgeFlag: (none)
> Point Data:
> Debug: Off
> Modified Time: 2638
> Reference Count: 1
> Registered Events:
> Registered Observers:
> vtkObserver (0x2ccc210)
> Event: 33
> EventName: ModifiedEvent
> Command: 0x2ccb880
> Priority: 0
> Tag: 1
> Number Of Arrays: 0
> Number Of Components: 0
> Number Of Tuples: 0
> Copy Tuple Flags: ( 1 1 1 1 1 0 1 1 )
> Interpolate Flags: ( 1 1 1 1 1 0 0 1 )
> Pass Through Flags: ( 1 1 1 1 1 1 1 1 )
> Scalars: (none)
> Vectors: (none)
> Normals: (none)
> TCoords: (none)
> Tensors: (none)
> GlobalIds: (none)
> PedigreeIds: (none)
> EdgeFlag: (none)
> Bounds:
> Xmin,Xmax: (1, -1)
> Ymin,Ymax: (1, -1)
> Zmin,Zmax: (1, -1)
> Compute Time: 2692
> Number Of Points: 0
> Point Coordinates: 0
> Locator: 0
> Number Of Vertices: 0
> Number Of Lines: 0
> Number Of Polygons: 0
> Number Of Triangle Strips: 0
> Number Of Pieces: 1
> Piece: 0
> Ghost Level: 0
> ```
>
> And I get an empty vtkPolyData without any streamline in it.
>
> Attached please find the testing dataset.
>
>
> Please help me.
>
>
> Thanks,
>
>
> Joey
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> https://public.kitware.com/mailman/listinfo/vtkusers
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
http
Yu Zhou
2018-11-03 21:09:50 UTC
Permalink
Hi Kenichiro,

It works!
Thank you so much! You saved my day!

Best regards,

Joey


________________________________
From: kenichiro yoshimi <***@gmail.com>
Sent: Saturday, November 3, 2018 0:19
To: ***@live.com
Cc: ***@public.kitware.com
Subject: Re: [vtkusers] Question to use the vtkStreamTracer

Hi,

You need to call setActivectors on the point data:
reader.GetOutput().GetPointData().SetActiveVectors('velocity')

Regards
2018$BG/(B10$B7n(B30$BF|(B($B2P(B) 7:27 Yu Zhou <***@live.com>:
>
> Hello,
>
>
> I have a problem with vtkStreamTracer.
>
> Here is the code:
>
>
> ```
>
> def generate_streamline(source_file, dest_file, axis, resolution=1):
> reader = vtk.vtkXMLImageDataReader()
> reader.SetFileName(source_file)
> reader.GetPointDataArraySelection().DisableArray('density')
> reader.Update()
> extent = reader.GetOutput().GetExtent()
> center = [np.mean(extent[0:2]), np.mean(extent[2:4]), np.mean(extent[4:6])]
>
> seeds = vtk.vtkPointSource()
> seeds.SetCenter(center)
> seeds.SetRadius(10.5)
> seeds.SetNumberOfPoints(100)
> seeds.Update()
>
> streamTracer = vtk.vtkStreamTracer()
> streamTracer.SetInterpolatorTypeToDataSetPointLocator()
> streamTracer.SetInputData(reader.GetOutputDataObject(0))
> streamTracer.SetSourceData(seeds.GetOutputDataObject(0))
> streamTracer.SetIntegratorTypeToRungeKutta45()
> streamTracer.SetMaximumPropagation(104)
> streamTracer.SetInitialIntegrationStep(0.2)
> streamTracer.SetMaximumIntegrationStep(0.5)
> streamTracer.SetIntegrationDirectionToBoth()
> streamTracer.SetStartPosition(center)
> streamTracer.SurfaceStreamlinesOn()
> streamTracer.Update()
>
> print(streamTracer.GetOutputDataObject(0))
>
> ```
>
> The output is:
> ```
>
> vtkPolyData (0x273ece0)
> Debug: Off
> Modified Time: 2638
> Reference Count: 2
> Registered Events: (none)
> Information: 0x2ccb540
> Data Released: False
> Global Release Data: Off
> UpdateTime: 2680
> Field Data:
> Debug: Off
> Modified Time: 2628
> Reference Count: 1
> Registered Events: (none)
> Number Of Arrays: 0
> Number Of Components: 0
> Number Of Tuples: 0
> Number Of Points: 0
> Number Of Cells: 0
> Cell Data:
> Debug: Off
> Modified Time: 2636
> Reference Count: 1
> Registered Events:
> Registered Observers:
> vtkObserver (0x2ccc370)
> Event: 33
> EventName: ModifiedEvent
> Command: 0x2ccb880
> Priority: 0
> Tag: 1
> Number Of Arrays: 0
> Number Of Components: 0
> Number Of Tuples: 0
> Copy Tuple Flags: ( 1 1 1 1 1 0 1 1 )
> Interpolate Flags: ( 1 1 1 1 1 0 0 1 )
> Pass Through Flags: ( 1 1 1 1 1 1 1 1 )
> Scalars: (none)
> Vectors: (none)
> Normals: (none)
> TCoords: (none)
> Tensors: (none)
> GlobalIds: (none)
> PedigreeIds: (none)
> EdgeFlag: (none)
> Point Data:
> Debug: Off
> Modified Time: 2638
> Reference Count: 1
> Registered Events:
> Registered Observers:
> vtkObserver (0x2ccc210)
> Event: 33
> EventName: ModifiedEvent
> Command: 0x2ccb880
> Priority: 0
> Tag: 1
> Number Of Arrays: 0
> Number Of Components: 0
> Number Of Tuples: 0
> Copy Tuple Flags: ( 1 1 1 1 1 0 1 1 )
> Interpolate Flags: ( 1 1 1 1 1 0 0 1 )
> Pass Through Flags: ( 1 1 1 1 1 1 1 1 )
> Scalars: (none)
> Vectors: (none)
> Normals: (none)
> TCoords: (none)
> Tensors: (none)
> GlobalIds: (none)
> PedigreeIds: (none)
> EdgeFlag: (none)
> Bounds:
> Xmin,Xmax: (1, -1)
> Ymin,Ymax: (1, -1)
> Zmin,Zmax: (1, -1)
> Compute Time: 2692
> Number Of Points: 0
> Point Coordinates: 0
> Locator: 0
> Number Of Vertices: 0
> Number Of Lines: 0
> Number Of Polygons: 0
> Number Of Triangle Strips: 0
> Number Of Pieces: 1
> Piece: 0
> Ghost Level: 0
> ```
>
> And I get an empty vtkPolyData without any streamline in it.
>
> Attached please find the testing dataset.
>
>
> Please help me.
>
>
> Thanks,
>
>
> Joey
>
> _______________________________________________
> Powered by www.kitware.com<http://www.kitware.com>
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> https://public.kitware.com/mailman/listinfo/vtkusers
Loading...