[vtkusers] vtk iteration over actors to change entity parameters, how?

David Lee Lambert as4109 at wayne.edu
Mon Feb 27 19:25:39 EST 2006


Dr. A. M. Zsaki wrote:

>[...] say, I have three actors (0, 1, 2). I want to change the color of
>the second one but so far I have not discovered any means of differentiating
>actors from each other...
>
>Is there a better way of doing this other than keeping track of which actor
>is where in the list of actors (and when it was added,etc), like assigning a
>name to an actor or something similar?!?
>  
>
A "vtkActor *" is just a pointer to a C++ object.  Make a global 
variable,  or a class variable in any object available when you create 
the actors as well as when you change thir propertied;   something like

  vtkActor* special_actor;

Then change your for (;;) loop to test that variable:

        for (int i=0;i<iNumberOfActors;++i) {
            if (i==1) {
	                vtkActor* actor=actors->GetNextActor();
			if (actor == special_actor) {
				// do something special
			} else {
				// do the other thing
			}
		}
            actors->GetNextActor();
        }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 251 bytes
Desc: OpenPGP digital signature
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20060227/3b9439ad/attachment.pgp>


More information about the vtkusers mailing list