[vtkusers] Remove polygonal props, leave volume intact

David Doria daviddoria at gmail.com
Wed Mar 16 12:40:41 EDT 2011


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110316/661b9dbb/attachment.htm>


More information about the vtkusers mailing list