[vtkusers] Threading

Lars Friedrich lfriedri at imtek.de
Mon Jan 29 01:58:31 EST 2007


Hello,

from the VTK docs I get that VTK is generally not thread safe. I guess
that this basically means that one has to take care that not two
interfering requests to the library are made at the same time. I tried
the following from python:

#*****************
from threading import Thread
from time import sleep

import vtk as V

w = V.vtkRenderWindow()
ren = V.vtkRenderer()
w.AddRenderer(ren)

class vtkThread(Thread):
	def __init__(self, win):
		Thread.__init__(self)
		self.win = win
	def run(self):
		for i in range(10):
			self.win.Render()
			sleep(1)

t = vtkThread(w)

t.start()
t.join()
#*****************

On my Linux machine this runs fine. It displays the black VTKwindow I
wanted to see.

On Windows however, the VTKwindow first is black (as expected) but gets
white when I try to move it around. After the ten seconds are over, I
get a window with some error messages in, but it is displayed very
shortly, so I cannot read anything.

What am I doing wrong?

Thanks for every comment

Lars




More information about the vtkusers mailing list