Thanks for the reply! <div><br></div><div>Thats basically the conclusion I came too. My plan is to acquire the scene data in the main thread, then pass this on to any background worker thread. </div><div><br></div><div>Will I run into the same issues with modifying a collection of actors? My intent is to have a collection of polydata objects updated in the background that are streamed into the viewer. Do you think I'll hav issues with this?</div>
<div><br></div><div>Thanks</div><div>Justin<span></span><br><br>On Wednesday, May 9, 2012, Marcus D. Hanwell wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
The VTK rendering classes are not thread safe, and we do not<br>
initialize OpenGL to render in a thread safe fashion. There are<br>
several methods that are likely to cause issues if called from<br>
multiple threads.<br>
<br>
You could communicate across threads but restrict the VTK calls to the<br>
main thread.<br>
<br>
Marcus<br>
<br>
On Sun, Apr 29, 2012 at 5:43 PM, Justin Rosen <<a>jmylesrosen@gmail.com</a>> wrote:<br>
> Nevermind, bunch of print statements must of been slowing things down, it<br>
> still crashes immediately without any print statements :(<br>
><br>
> On Sun, Apr 29, 2012 at 2:38 PM, Justin Rosen <<a>jmylesrosen@gmail.com</a>> wrote:<br>
>><br>
>> Grabbing a copy of the camera in a separate thread seems to do the trick.<br>
>> Can anyone shed some light onto this topic?<br>
>><br>
>> vtkCamera *camera = vtkCamera::New();<br>
>> camera->ShallowCopy(renderer->GetActiveCamera());<br>
>><br>
>> Thanks,<br>
>> Justin<br>
>><br>
>><br>
>> On Sat, Apr 28, 2012 at 9:52 PM, Justin Rosen <<a>jmylesrosen@gmail.com</a>><br>
>> wrote:<br>
>>><br>
>>> It looks like vtkCamera->GetFrustumPlanes isn't thread safe? It makes<br>
>>> quite a few changes to some of the it's member variables. I tried adding a<br>
>>> mutex lock between vtkCommand::Start/EndEvent, but I'm still seg faulting.<br>
>>><br>
>>> Thanks,<br>
>>> Justin<br>
>>><br>
>>> On Sat, Apr 28, 2012 at 3:23 PM, Justin Rosen <<a>jmylesrosen@gmail.com</a>><br>
>>> wrote:<br>
>>>><br>
>>>> If anyone one knows a bit about using vtk and boost threads I'd really<br>
>>>> appreciate the help. I'm fairly new to vtk and threads in general and I'm<br>
>>>> trying to figure out why calling vtkCamera->GetFrustumPlanes from a boost<br>
>>>> thread eventually segfaults. It takes quite a few of iterations before the<br>
>>>> segfault occurs.<br>
>>>><br>
>>>> The general idea is that I have main application UI and a worker thread<br>
>>>> in the background which'll be doing some processing (Eventually<br>
>>>> updating/modifying a list of actors). At the moment I'm just trying to get<br>
>>>> the cameras view frustum...<br>
>>>><br>
>>>> If I remove the call to camera->GetFrustumPlanes the application runs<br>
>>>> without seg faulting. Any idea what I may be doing wrong?<br>
>>>><br>
>>>> void workerFunc(vtkCamera *camera)<br>
>>>> {<br>
>>>> double prevUp[3] = {0, 0, 0};<br>
>>>> double prevFocal[3] = {0, 0, 0};<br>
>>>> double prevPos[3] = {0, 0, 0};<br>
>>>><br>
>>>> while(true){<br>
>>>> double *up = camera->GetViewUp();<br>
>>>> double *focal = camera->GetFocalPoint();<br>
>>>> double *pos = camera->GetPosition();<br>
>>>><br>
>>>> bool viewpointChanged = false;<br>
>>>><br>
>>>> // Check up vector<br>
>>>> if(up[0] != prevUp[0] || up[1] != prevUp[1] || up[2] != prevUp[2])<br>
>>>> viewpointChanged = true;<br>
>>>><br>
>>>> // Check focal point<br>
>>>> if(focal[0] != prevFocal[0] || focal[1] != prevFocal[1] || focal[2]<br>
>>>> != prevFocal[2])<br>
>>>> viewpointChanged = true;<br>
>>>><br>
>>>> // Check position<br>
>>>> if(pos[0] != prevPos[0] || pos[1] != prevPos[1] || pos[2] !=<br>
>>>> prevPos[2])<br>
>>>> viewpointChanged = true;<br>
>>>><br>
>>>> // If the viewpoints changed get the cameras frustum<br>
>>>> if (viewpointChanged){<br>
>>>> prevUp[0] = up[0]; prevUp[1] = up[1]; prevUp[2] = up[2];<br>
>>>> prevFocal[0] = focal[0]; prevFocal[1] = focal[1]; prevFocal[2] =<br>
>>>> focal[2];<br>
>>>> prevPos[0] = pos[0]; prevPos[1] = pos[1]; prevPos[2] = pos[2];<br>
>>>><br>
>>>> cout << "View Changed" << endl;<br>
>>>> cout << "Up: <" << up[0] << ", " << up[1] << ", " << up[2] << ">"<br>
>>> _______________________________________________<br>
> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
><br>
> Visit other Kitware open-source projects at<br>
> <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
><br>
> Please keep messages on-topic and check the VTK FAQ at:<br>
> <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
><br>
> Follow this link to subscribe/unsubscribe:<br>
> <a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
><br>
</blockquote></div>