[vtkusers] Remove polygonal props, leave volume intact

Dženan Zukić dzenanz at gmail.com
Wed Mar 16 12:47:38 EDT 2011


2011/3/16 David Doria <daviddoria at gmail.com>

> 2011/3/16 Dženan Zukić <dzenanz at gmail.com>
>
>> Hi all,
>>
>> I want to remove (and delete to free the memory) all polygonal actors, but
>> leaving the volume in the scene. This is my attempt:
>>
>> void MainWindow::on_actionClear_polygonal_data_activated()
>> {
>>     vtkPropCollection
>> *props=vis->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->GetViewProps();
>>     for (int i=props->GetNumberOfItems()-1; i>=0; i--)
>>         if (!props[i].IsTypeOf("vtkVolume")) //vtkObjectBase both volume
>> and polyogonal
>>             props->RemoveItem(i);
>>     vis->GetRenderWindow()->Render();
>> }
>>
>> However this also removes the volume. I have a feeling the problem is in
>> some small detail. Do you have any suggestions?
>>
>> Regards,
>> Dženan
>>
>>
> Did you try outputting GetClassName() for the props that are deleted?
>
> You could also try the IsA() function.
>
> Even better, try to downcast (SafeDownCast()) to a vtkVolume. If the cast
> succeeds, do not delete the object.
>
> Let us know how it goes.
>
> David
>
Executing GetClassName() crashes the program. I will try IsA() tomorrow when
I get back to university.

Thanks for taking interest.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110316/f20352c0/attachment.htm>


More information about the vtkusers mailing list