[vtkusers] Rendering during ITK Registration
Jaety Edwards
jaetye at gmail.com
Mon Sep 15 19:53:56 EDT 2008
Hello all,
I have a question about threading and VTK. Specifically, about how I can
have a renderWindow that can be updated either from a renderWindowInteractor
running on one thread, or from a separate worker thread.
In more detail, I'm doing some image registration work (using ITK), and I
would like to use VTK to visualize the progress of the registration at every
n'th iteration. So far, no problem. But I would also like to be able to
interact with the visualization window at the same time, for example to
rotate the viewpoint as it progresses. To make this work, what I've done is
to have my registration code running in its own thread and then launch an
interactor on the main one. At each iteration, the registration code calls
SetPosition on the appropriate vtkActor. So far, all of this works fine, and
if I interact with the renderWindow (for example click and drag the mouse),
the renderWindow redraws, picking up the changes that my registration code
has made to the actor's position.
What I can't figure out how to do is to have the registration code safely
tell the renderWindow to re-render itself without me interacting with the
window. I can't for example call window->Render() directly from the
registration thread without causing errors. My best guess as to why comes
from this note:
http://public.kitware.com/pipermail/vtkusers/2003-December/070728.html
which explains that trying to use the same OpenGL context across two threads
is a big no-no, and that seems to be exactly what I'm doing when I go that
route. So I need to make sure that the Render call is always made from the
main thread, but I don't know how to make that happen, and any tips from the
community will be greatly appreciated.
Thanks so much,
Jaety
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20080915/93cd9ad1/attachment.htm>
More information about the vtkusers
mailing list