Hello,

in the Mayavi documentation guide/ch04.html there is a python example

>>> # generate the data.
>>> from Numeric import *
>>> import scipy
>>> x = (arange(50.0)-25)/2.0
>>> y = (arange(50.0)-25)/2.0
>>> r = sqrt(x[:,NewAxis]**2+y**2)
>>> z = 5.0*scipy.special.j0(r)  # Bessel function of order 0
>>> # now dump the data to a VTK file.
>>> import pyvtk
>>> # Flatten the 2D array data as per VTK's requirements.
>>> z1 = reshape(transpose(z), (-1,))
>>> point_data = pyvtk.PointData(pyvtk.Scalars(z1))
>>> grid = pyvtk.StructuredPoints((50,50, 1), (-12.5, -12.5, 0), (0.5, 0.5,1))
>>> data = pyvtk.VtkData(grid, point_data)
>>> data.tofile('/tmp/test.vtk')

the module name/classes/functions appears to have has changed slightly

#!/usr/bin/env python
#generate the data.
from Numeric import *
import scipy
x = (arange(50.0)-25)/2.0
y = (arange(50.0)-25)/2.0
r = sqrt(x[:,NewAxis]**2+y**2)
z = 5.0*scipy.special.j0(r)  # Bessel function of order 0
# now dump the data to a VTK file.
from vtk import *
# Flatten the 2D array data as per VTK's requirements.
z1 = reshape(transpose(z), (-1,))
point_data = vtkPointData(vtkScalars(z1))
grid = vtkStructuredPoints((50,50, 1), (-12.5, -12.5, 0), (0.5, 0.5, 1))
data = vtkVtkData(grid, point_data)
data.tofile('/tmp/test.vtk')

However vtkScalars is now deprecated (actually does not exist in vtk4.4)
so the program does not run.  The documentation I have found on web about
how to handle this change is for C++ and I cannot translate what needs to be
done in python.  I have only just started to look at mayavi and vtk.


thanks
-- 
Tony Maher

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
MayaVi-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mayavi-users

Reply via email to