[vtkusers] [Paraview] Combining vtk and paraview python scripts

Andy Bauer andy.bauer at kitware.com
Tue Jul 14 15:20:08 EDT 2015


ParaView's Python Programmable Filter and Python Programmable Source use
VTK Python wrapping to do the work while making it available in Paraview.
Check out http://www.paraview.org/Wiki/Python_Programmable_Filter.

On Tue, Jul 14, 2015 at 2:59 PM, Jeff Becker <jeffrey.c.becker at nasa.gov>
wrote:

> Hi.
>
> As a proof of concept, I have a vtk script that reads some binary data,
> and produces a vti file. I then have a second script that I generated using
> ParaView's tracing facility while viewing the data. Now I'd like to combine
> them, so as to eliminate the intermediate file, i.e., go from binary data
> directly to rendering. To be specific, my vtk script ends like this:
>
> steinbmag = steinbmag.reshape(nx,ny,nz).T
>
> vtkImporter = vtk.vtkImageImport()
> vtkImporter.CopyImportVoidPointer(steinbmag, steinbmag.nbytes)
>
> vtkImporter.SetDataScalarTypeToFloat()
> vtkImporter.SetNumberOfScalarComponents(1)
> vtkImporter.SetDataExtent(0, nx-1, 0, ny-1, 0, nz-1)
> vtkImporter.SetWholeExtent(0, nx-1, 0, ny-1, 0, nz-1)
> vtkImporter.SetScalarArrayName('B field magnitude')
>
> writer=vtk.vtkXMLImageDataWriter()
> writer.SetFileName(out_fname)
> writer.SetInputConnection(vtkImporter.GetOutputPort())
> writer.Write()
>
> and the ParaView script starts like this:
>
> from paraview.simple import *
>
> paraview.simple._DisableFirstRenderCameraReset()
>
> filepfx = '/nobackup/jcbecker/steinBmag_0'
> infile = filepfx+'.vti'
> # create a new 'XML Image Data Reader'
> steinBmag_ = XMLImageDataReader(FileName=infile)
> steinBmag_.CellArrayStatus = []
> steinBmag_.PointArrayStatus = ['B field magnitude']
>
> # get animation scene
> animationScene1 = GetAnimationScene()
>
> # update animation scene based on data timesteps
> animationScene1.UpdateAnimationUsingDataTimeSteps()
>
> # get active view
> renderView1 = GetActiveViewOrCreate('RenderView')
> # uncomment following to set a specific view size
> renderView1.ViewSize = [1090, 761]
>
> I'm looking at the VTK examples and pvpython documentation, but any help
> is appreciated.
>
> Thanks.
>
> -jeff
> _______________________________________________
> 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 ParaView Wiki at:
> http://paraview.org/Wiki/ParaView
>
> Search the list archives at: http://markmail.org/search/?q=ParaView
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/paraview
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20150714/e3cb86d4/attachment.html>


More information about the vtkusers mailing list