[vtkusers] Displaying vtkPolyData while writing on it within Qt objects (QVTKWidget)
Barth, Sebastian
sebastian.barth at iosb.fraunhofer.de
Tue Jun 22 09:35:03 EDT 2010
Thanks for your help!
All what I need to know is, if it is possible to manipulate a vtkPolyData AND update its mapper in one thread while another one is currently updating a camera or other objects without displaying the changes on the vtkPolyData.
The best would be if I could set the mapper to use its previous rendered input data (my vtkPolyData) until I have manipulated and precached it in the second thread. I could not find any similar method.
I've tried to set the current mapper static (to avoid that it updates from out the main thread) and modified the vtkPolyData in the second thread. Further I've created a new mapper in this second thread, gave him the modified vtkPolyData, let him update, and then replaced the previous static mapper by the new updated mapper. This anyway, let my application crash.
void CloudData::update()
{
this->mapper->StaticOn();
vtkPolyDataMapper * newMapper = vtkPolyDataMapper::New();
// Modify the data
modifiePolyData();
this->polyData->Modified();
newMapper->SetInput(polyData);
newMapper->SetColorModeToDefault();
newMapper->Update();
this->actor->SetMapper(mapper);
this->mapper->Delete();
this->mapper = newMapper;
}
Any idea?
What's the common way to interrupt the pipeline?
Thanks for any help!
Sebastian
-----Ursprüngliche Nachricht-----
Von: David E DeMarle [mailto:dave.demarle at kitware.com]
Gesendet: Montag, 21. Juni 2010 15:10
An: Barth, Sebastian
Cc: Clinton Stimpson; vtkusers at vtk.org
Betreff: Re: [vtkusers] Displaying vtkPolyData while writing on it within Qt objects (QVTKWidget)
Unfortunately, VTK is not thread safe (with the important exception of
things that happen inside image filters). So, you will have to provide
you own synchronization, making sure that no two threads access the
same (or coupled) VTK data structures at the same time. A few people
on this list have done this before, perhaps they will chime in with
advice.
David E DeMarle
Kitware, Inc.
R&D Engineer
28 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-371-3971 x109
On Mon, Jun 21, 2010 at 3:47 AM, Barth, Sebastian
<sebastian.barth at iosb.fraunhofer.de> wrote:
> Hello Clint,
>
> yes, I call Modified() and it's working, but that's not the problem. The point ist that Qt does not invoke the QTimer event while the mouse is moving. This is a Qt problem and I guess I have to use different threads to avoid this: One for the interface with the QVTKWidget and one for the QTimer which forces the manipulation of the vtkPolyData. I don't know if there is a better way.
>
> For this I want to know if there are some things I have to know if I want to have access to one vtkPolyData from out two different threads (QThread). There are few informations about QThread and almost none about VTK at a multithreading point.
>
> I hope someone can give me some instructions, because I know almost nothing about threads in this scope (VTK + Qt).
>
> Thanks a lot
>
> Sebastian
>
> -----Ursprüngliche Nachricht-----
> Von: vtkusers-bounces at vtk.org [mailto:vtkusers-bounces at vtk.org] Im Auftrag von Clinton Stimpson
> Gesendet: Freitag, 18. Juni 2010 22:23
> An: vtkusers at vtk.org
> Betreff: Re: [vtkusers] Displaying vtkPolyData while writing on it within Qt objects (QVTKWidget)
>
> On Friday, June 18, 2010 09:22:42 am Barth, Sebastian wrote:
>> Hello vtkusers,
>>
>> my application uses the QVTKWidget with Qt 4.6.2 and VTK 5.6.0 as a part of
>> it's window.
>>
>> I have a 3D visualisation of a cluster of points stored in a vtkPolyData.
>> On my Qt window I can start a QTimer whose timeout() signal is connected
>> to a slot which manipulates the points in the vtkPolyData and updates the
>> visualisation pipeline with QVTKWidget::update().
>>
>> My vtkRendererWindow uses the default interactor style (trackball camera).
>>
>> While moving the camera (mouse interaction) the QVTKWindow gets updated,
>> but the vtkPolyData does not. This of course, is a Qt problem, but I want
>> to know if I have to do anything special if I want to write on the
>> vtkPolyData object from out another thread (QThread) while I'm moving the
>> camera and displaying the current written Data. Maybe there is a simplier
>> solution, I don't know!
>>
>> It's the first time I work with VTK, QT and even threads and I appreciate
>> every help!
>>
>
> Are you calling Modifed() on the vtkPolyData after modifying its points?
>
> Clint
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
More information about the vtkusers
mailing list