[vtkusers] downcasting in python wrappers in VTK 4.2.2

Justin Binns binns at mcs.anl.gov
Mon Jun 30 17:43:08 EDT 2003


I'm having a problem in VTK 4.2.2 - it appears the behavior of the python 
wrappers is different between a windows build and a linux build, with the 
Windows build behavior being 'correct' (seemingly).  To set the stage, 
these are both from the same tarball, from the latest stable release of 
VTK (4.2.2).  They're built with the same options.  The data file 
'anlsx.1.vtu' is identical.  I've double and triple checked that I'm 
getting the right libraries and everything on both machines.  The output 
from the Windows box is as follows:

D:\Projects\PyViz>python
ActivePython 2.2.1 Build 222 (ActiveState Corp.) based on
Python 2.2.1 (#34, Apr 15 2002, 09:51:39) [MSC 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import vtk
>>> ugridReader=vtk.vtkXMLUnstructuredGridReader()
>>> ugridReader.SetFileName("./anlsx.1.vtu")
>>> ugridReader
<vtkIOPython.vtkXMLUnstructuredGridReader vtkobject at 00DC8080>
>>> ugridReader.GetOutput()
<vtkCommonPython.vtkUnstructuredGrid vtkobject at 00DC80E8>
>>> ugridReader.GetOutput().GetPointData()
<vtkCommonPython.vtkPointData vtkobject at 00DC8128>
>>>

Notice: the object type of the GetOutput() call is an UnstructuredGrid, 
and the output from the GetOutput().GetPointData() is a likewise-useful 
PointData object.  These are useful objects, and what one would expect.

Now, under Linux:

[binns at oddball2 PyViz]$ vtkpython
vtk version 4.2.1, vtk source $Revision: 1.1495 $, $Date: 2003/02/18 
03:45:04 $ (GMT)
Python 2.2 (#1, Apr 12 2002, 15:29:57)
[GCC 2.96 20000731 (Red Hat Linux 7.2 2.96-109)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import vtk
>>> ugridReader=vtk.vtkXMLUnstructuredGridReader()
>>> ugridReader.SetFileName("./anlsx.1.vtu")
>>> ugridReader
<libvtkIOPython.vtkXMLUnstructuredGridReader vtkobject at 0x825a778>
>>> ugridReader.GetOutput()
<libvtkImagingPython.vtkDataSet vtkobject at 0x825bf60>
>>> ugridReader.GetOutput().GetPointData()
<libvtkFilteringPython.vtkObject vtkobject at 0x824e3a8>
>>> ugridReader.Update()
>>> ugridReader.GetOutput()
<libvtkImagingPython.vtkDataSet vtkobject at 0x825bec8>
>>> ugridReader.GetOutput().GetPointData()
<libvtkFilteringPython.vtkObject vtkobject at 0x825c4d8>
>>>

Notice: the object type of the GetOutput() is a generic DataSet, and the 
output from the GetPointData() is a completely useless vtkObject.  Even 
after an Update() (and it has noticably read the file), the objects are 
the same generic types.  It appears that under Linux, the object isn't 
being cast back to it's appropriate type before return, while under 
windows, it is.

Any thoughts on how I might fix this?  Which sources to look in?  Is this 
already fixed in CVS?  Thanks much!

Justin Binns
Scientific Programmer
Futures Lab / Argonne National Laboratory





More information about the vtkusers mailing list