[vtkusers] Rendering during ITK Registration

Karthik Krishnan karthik.krishnan at kitware.com
Wed Sep 17 11:16:55 EDT 2008


As Pat mentioned, on similar applications, we use a timer based
strategy, with the main thread checking every second or so, to see if
it needs to render and renders.

You would need a vtkMutexLock on the ImageRegistration thread where
the dataobject to be rendered is being updated.  This part would be
done in the CommandObserver responding to every 10th IterationEvent
during registration.

Likewise, you will need a vtkMutexLock on the Main thread where the
dataobject is being accessed (or deep copied) prior to rendering.

In practice, to avoid keeping the mutexes waiting, you will need to
judiciously make sure that the dataobjects you are updating aren't
enormous. For instance contouring the datasets or rendering just one
slice etc...

VTK has the ability to create repeating timers. See TestInteractorTimer test


On Mon, Sep 15, 2008 at 7:53 PM, Jaety Edwards <jaetye at gmail.com> wrote:
> 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
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>



-- 
Karthik Krishnan
R&D Engineer,
Kitware Inc.
Ph: 518 371 3971 x119
Fax: 518 371 3971



More information about the vtkusers mailing list