streamlines2.py 912 B

123456789101112131415161718192021222324252627
  1. """Load an existing dataset and draw
  2. the streamlines of the velocity field"""
  3. from vedo import *
  4. ######################## vtk
  5. import vtk
  6. # Read the data and specify which scalars and vectors to read.
  7. pl3d = vtk.vtkMultiBlockPLOT3DReader()
  8. fpath = download(dataurl+"combxyz.bin")
  9. pl3d.SetXYZFileName(fpath)
  10. fpath = download(dataurl+"combq.bin")
  11. pl3d.SetQFileName(fpath)
  12. pl3d.SetScalarFunctionNumber(100)
  13. pl3d.SetVectorFunctionNumber(202)
  14. pl3d.Update()
  15. # this vtkStructuredGridData already has a vector field:
  16. sdata = pl3d.GetOutput().GetBlock(0)
  17. ######################## vedo
  18. domain = UnstructuredGrid(sdata).alpha(0.1).c('white')
  19. probe = Grid(s=[5,5], res=[6,6], c='white').rotate_y(90).pos(5,0,29)
  20. streamlines = domain.compute_streamlines(probe)
  21. streamlines.celldata.select("SeedIds")
  22. streamlines.cmap("Set1", on='cells')
  23. print(streamlines)
  24. show(domain, streamlines, probe, __doc__, axes=7, bg='bb').close()