vtk-python and serialization

David Gobbi dgobbi at irus.rri.on.ca
Fri May 5 11:06:29 EDT 2000


On Fri, 5 May 2000, Vetle Roeim wrote:

> I have som questions about the python bindings for vtk.. Before I ask the
> questions, I'd just like to say that I'm no Python expert ;-)
> 
> - Would it be possible to serialize the vtk objects somehow? I gave it a
> shot with the pickle module, but it dumped core.

No, it isn't and this would be fairly hard to add.  You might be able
to find a way for pickle to work via the object readers/writers using
temporary files or named pipes.  This would only work for the data
classes, there is no way to do something similar to a chunk of VTK
pipeline.  

> - I've noticed that the vtk objects are a little strange. For an example:
> 
>   >>> camera = vtkCamera()
>   >>> print camera
>   vtkOpenGLCamera (0x2ff3f8)
>     Debug: Off
>     No Delete Method
>     Modified Time: 2
>     Reference Count: 1
[snip]
> 
> instead of writing something like <somethinginstance at someaddress> it
> prints (all?) its attributes and values.
> would it be possible to _easily_ construct a new vtkCamera object based on
> this information? without manually writing functions to read it?
> 
> .. and why does the object write all this?

Well, because the python 'print' is translated directly 
into camera->Print(stdout).  Yes, I agree, this is silly,
especially if you try to print a list of several VTK objects.

The solution would be to change the python wrappers so that
you can use camera.Print() instead.  Then, repr(camera) 
could be changed so that it returned '<vtkCamera at 2ff3f8>'
which is much more consistent with the Python way of doing things.
I might shy away from printing 'instance' because vtk objects
are not instances of python classes.

 - David
 
--
  David Gobbi, MSc                    dgobbi at irus.rri.on.ca
  Advanced Imaging Research Group
  Robarts Research Institute, University of Western Ontario

--------------------------------------------------------------------
This is the private VTK discussion list. Please keep messages on-topic.
Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
<majordomo at public.kitware.com>. For help, send message body containing
"info vtkusers" to the same address.
--------------------------------------------------------------------



More information about the vtkusers mailing list