AnimationScripting

Many VTK files, one visualisation

Here is a little script which will take a MayaVi visualisation and iterate over a set of VTK files, writing out an image snapshot each change

#!/usr/bin/env python

import mayavi, glob

# directory listing...

input_list = glob.glob('*.vtk')

# instantiate a MayaVi

v = mayavi.mayavi()

# load the visualisation

v.load_visualization('my.mv')

# grab the DataVizManager list

dvms = v.get_dvm_names()

for n in range(len(input_list)):
    datafile = input_list[n]
    for i in dvms:

        # grab a handle to the DVM
        dvm = v.mayavi.data_viz_mgr[i]

        # follow the pipeline, and load in the new data file
        ds  = dvm.get_data_source()
        rdr = ds.get_reader()        
        rdr.SetFileName(datafile)
        ds.Update()
        ds.update_references()

    # re-render the scene
    v.Render()

    # write this image to the disk
    v.renwin.save_png('./output%04d.png' % n)

What this will leave you with is a set of PNG files in a directory reflecting the original my.mv visualisation but with data sets from the current directory

last edited 2003-12-17 03:02:12 by Prabhu Ramachandran


SourceForge.net Logo