<DIV>Just so let you know. I finally derived my own actor class with your method. </DIV>
<DIV> </DIV>
<DIV>However, I made some changes to your class to make it compile in my application(VC6.0&MFC)</DIV>
<DIV> </DIV>
<DIV>1) I have to change the super class from vtkActor to vtkOpenGLActor. Otherwise, the render window won't render. I don't know why.</DIV>
<DIV> </DIV>
<DIV>2) I change the new method to</DIV>
<DIV>vtkMyActor* vtkMyActor::New() {<BR> vtkObject* ret = vtkObjectFactory::CreateInstance("vtkActor");<BR> if(ret)<BR> {<BR> return (vtkMyActor*)ret;<BR> }<BR> return (vtkMyActor*) new vtkMyActor;<BR>}</DIV>
<DIV> </DIV>
<DIV>Thank for your help!</DIV>
<DIV> </DIV>
<DIV> Luke</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>On 08.03.2004, at 21:19, Luke Hua wrote:<BR><BR>> Is there any way to retrieve actor by ID or properties? My renderer <BR>> has various kind of actors and I need to delete and add them <BR>> dynamically. It's very difficult to track the position of actors using <BR>> Initialtraversal().<BR>> <BR>> There is no return values for addActor(). Could vtk make some changes <BR>> so that the addActor() can return a ID for each actor therefore easier <BR>> to retrieve actors?<BR>> <BR>> Or there is any other way to retrieve actors?<BR><BR>You can extend vtkActor to have an ID. Did that and it works <BR>flawlessly. Just use the extended vtkActor instead of the original. <BR>When your picker/renderer returns an actor you can get the ID easily. <BR>If you don't want to set that ID yourself you can add a static variable <BR>that "counts" actors, i.e. it has to be incremented inside the New() <BR>method, then set the ID accordingly.<BR><BR><BR>vtkMyActor.h looks
like this:<BR><BR>#ifndef MYACT_H<BR>#define MYACT_H<BR><BR>#include <vtkActor.h><BR><BR>class vtkMyActor : public vtkActor {<BR> public:<BR> int GetID();<BR> void SetID(int id);<BR> static vtkMyActor* New();<BR> void Delete();<BR><BR> private:<BR> int id; // id of this glyph's actor<BR><BR>};<BR>#endif<BR><BR><BR><BR>vtkMyActor.cc looks like this:<BR><BR>#include "vtkMyActor.h"<BR><BR>vtkMyActor* vtkMyActor::New() {<BR> vtkActor::New();<BR>}<BR><BR>void vtkMyActor::Delete() {<BR> vtkActor::Delete();<BR>}<BR><BR>int vtkMyActor::GetID() {<BR> return this->id;<BR>}<BR><BR>void vtkMyActor::SetID(int id) {<BR> this->id = id;<BR>}<BR><BR><BR>Hope
that helps...<BR><BR>Ciao!<BR> Wiebke<BR><BR>_______________________________________________<BR>This is the private VTK discussion list. <BR>Please keep messages on-topic. Check the FAQ at: <<A href="http://public.kitware.com/cgi-bin/vtkfaq">http://public.kitware.com/cgi-bin/vtkfaq</A>><BR>Follow this link to subscribe/unsubscribe:<BR><A href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</A></DIV><p><font face=arial size=-1>Do you Yahoo!?<br>
<a href="http://taxes.yahoo.com/filing.html"><b>Yahoo! Finance Tax Center</a></b> - File online. File on time.