[vtkusers] Multithreading and VTK
Berk Geveci
berk.geveci at kitware.com
Fri Sep 12 10:23:25 EDT 2003
> If it's not too much of an imposition--what would you do in my
> situation? Perhaps you have a better idea. Is there a built-in framework
> within vtk that I have overlooked, that better handles this problem?
I tend to like separating simulation and visualization code. Specially
if they are independent (this might not be the case in your situation).
If the data generated by the simulation is not too big, I would use
two processes communicating through sockets (non-blocking). Polling
the socket every now and then in the interaction loop (using timers)
usually work well. Of course, this does not change the fact that you
have to lock the data while it's being received. One solution is to
create a dummy VTK source as the first thing in the pipeline and call
Modified() on it once the data is received. Then during the next
render, the pipeline should execute. To force a render, you can again
use timers. All this source has to do is to copy (ShallowCopy probably)
the data to it's output during execution. This should work for both a
multithreaded and a socket-based application. You might run into issues
if a user interaction causes a render while another render, due to
a timer event, is in progress. The best way to find the problems is
to write a sample program and test it.
-Berk
More information about the vtkusers
mailing list