[vtkusers] Animation without polling?

Guido Rodriguez guidorodriguez1952 at hotmail.com
Thu Sep 10 09:12:40 EDT 2009


Dear VTK users/developers,
I ask for guidance, how animated visualization is done right with VTK. What I have in mind is an application which calculates, let's say, a temperature field, which changes in time. Whenever the field is completely calculated for the next time step, the visualization should be updated. In parallel, the user should be able to work with the mouse/key controls to rotate the view, zoom, interact with 3D widgets, etc.

The obvious way would be to run VTK in one thread, and the calculation in another. Each finished calculation step would notify VTK to update. But it doesn't work like this. At least not with the X windows system. When I call some pipeline's Update() function from a different thread, I get an "invalid thread access".

Next attempt. I implement an event buffer, which is written to by the calculation thread, and which is read from by the VTK thread. This works like a charm. Now VTK can check whether an update is necessary and get the required data from the event buffer. But _when_ does VTK check for updates? I can't seem to find a solution which sets VTK to sleep until either a mouse/key event happens or until the calculation thread releases some lock, simply because any VTK callback waiting for notification from a different thread would stop VTK from reacting to mouse/key events during this period.

The only solution I can see is to add a timer event like every 10 ms, which checks the event buffer for updates. This works, but is it recommended? Threading libraries have introduced locks and notification to avoid the overhead from polling at interactive rates for events that may occur only every few seconds. How can good multithreading programming styles be applied to VTK?

I hope the problem is clear. Can a different thread trigger pipeline updates under X windows? Or do I have to write my own vtkRenderWindowInteractor?

Regards,
Guido
_________________________________________________________________
With Windows Live, you can organize, edit, and share your photos.
http://www.microsoft.com/middleeast/windows/windowslive/products/photo-gallery-edit.aspx
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090910/cdecbaaa/attachment.htm>


More information about the vtkusers mailing list