<font size="2"><font face="verdana,sans-serif">I just checked, calling IsA() also crashes the program.</font></font><div><font size="2"><font face="verdana,sans-serif"><br></font></font></div><div><font size="2"><font face="verdana,sans-serif">At first I could not understand what SafeDownCast is supposed to do from the docs (</font></font><a href="http://www.vtk.org/doc/release/5.6/html/a02127.html#5790c5359ba54a168bd2824ab46286b4">http://www.vtk.org/doc/release/5.6/html/a02127.html#5790c5359ba54a168bd2824ab46286b4</a><span class="Apple-style-span" style="font-family: verdana, sans-serif; ">), but then I got it to work:</span></div>

<div><span class="Apple-style-span" style="font-family: verdana, sans-serif; "><br></span></div><div><span class="Apple-style-span" style="font-family: verdana, sans-serif; "><div>void MainWindow::on_actionClear_polygonal_data_activated()</div>

<div>{</div><div>    vtkPropCollection *props=vis-&gt;GetRenderWindow()-&gt;GetRenderers()-&gt;GetFirstRenderer()-&gt;GetViewProps();</div><div>    for (int i=props-&gt;GetNumberOfItems()-1; i&gt;=0; i--)</div><div>        if (!vtkVolume::SafeDownCast(props-&gt;GetItemAsObject(i)))</div>

<div>            props-&gt;RemoveItem(i);</div><div>    vis-&gt;GetRenderWindow()-&gt;Render();</div><div>}</div><div><br></div><div>However before that I found a simpler way:</div><div><br></div><div><div>void MainWindow::on_actionClear_polygonal_data_activated()</div>

<div>{</div><div>    vtkProp *volume=vis-&gt;GetRenderWindow()-&gt;GetRenderers()-&gt;GetFirstRenderer()-&gt;GetVolumes()-&gt;GetLastProp();</div><div>    vis-&gt;GetRenderWindow()-&gt;GetRenderers()-&gt;GetFirstRenderer()-&gt;GetViewProps()-&gt;RemoveAllItems(); //this also removes the volume</div>

<div>    vis-&gt;GetRenderWindow()-&gt;GetRenderers()-&gt;GetFirstRenderer()-&gt;AddVolume(volume);</div><div>    vis-&gt;GetRenderWindow()-&gt;Render();</div><div>}</div></div></span></div><div><br></div><div>Thanks for help,</div>

<div>Dženan</div><div><br><div class="gmail_quote">2011/3/16 Dženan Zukić <span dir="ltr">&lt;<a href="mailto:dzenanz@gmail.com">dzenanz@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div><div></div><div class="h5"><div class="gmail_quote">2011/3/16 David Doria <span dir="ltr">&lt;<a href="mailto:daviddoria@gmail.com" target="_blank">daviddoria@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<div class="gmail_quote"><div><div></div><div>2011/3/16 Dženan Zukić <span dir="ltr">&lt;<a href="mailto:dzenanz@gmail.com" target="_blank">dzenanz@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">



<font size="2"><font face="verdana,sans-serif"><div>Hi all,</div><div><br></div><div>I want to remove (and delete to free the memory) all polygonal actors, but leaving the volume in the scene. This is my attempt:</div><div>





<br></div><div><div>void MainWindow::on_actionClear_polygonal_data_activated()</div><div>{</div><div>    vtkPropCollection *props=vis-&gt;GetRenderWindow()-&gt;GetRenderers()-&gt;GetFirstRenderer()-&gt;GetViewProps();</div>





<div>    for (int i=props-&gt;GetNumberOfItems()-1; i&gt;=0; i--)</div><div>        if (!props[i].IsTypeOf(&quot;vtkVolume&quot;)) //vtkObjectBase both volume and polyogonal</div><div>            props-&gt;RemoveItem(i);</div>





<div>    vis-&gt;GetRenderWindow()-&gt;Render();</div><div>}</div></div><div><br></div><div>However this also removes the volume. I have a feeling the problem is in some small detail. Do you have any suggestions?</div><div>





<br></div><div>Regards,</div><div>Dženan</div><div><br></div></font></font></blockquote><div><br></div></div></div><div>Did you try outputting GetClassName() for the props that are deleted?</div><div><br></div><div>You could also try the IsA() function.</div>



<div><br></div><div>Even better, try to downcast (SafeDownCast()) to a vtkVolume. If the cast succeeds, do not delete the object.</div><div class="gmail_quote"><br></div>Let us know how it goes.</div><div class="gmail_quote">



<br><font color="#888888">David</font></div>
</blockquote></div></div></div>Executing GetClassName() crashes the program. I will try IsA() tomorrow when I get back to university.<div><br></div><div>Thanks for taking interest.</div>
</blockquote></div><br></div>