[vtkusers] Determining Actor type

Kenneth Porter shiva at sewingwitch.com
Fri Feb 19 22:53:30 EST 2010


--On Friday, February 19, 2010 10:04 PM -0500 David Doria 
<daviddoria+vtk at gmail.com> wrote:

> What Ken said would probably work. You could also use GetClassName and do
> a string comparison, like this:
> http://www.vtk.org/Wiki/VTK/Examples/DetermineActorType
>
> You've got to be careful though - in this case I would have expected the
> first actor to be a "vtkActor", but it is really a vtkOpenGLActor.

Note that this example only works if the type you are working for is a leaf 
type. If you've got an Actor that's derived from the type you're looking 
for you won't find it.

If you use dynamic_cast, it walks the linked list of vtables for all base 
types to see if your pointer points to a derived type of one of them, and 
hence you can look for a non-leaf type. (This also works with multiple 
inheritance, by walking down each list of base classes.) I don't see any 
machinery to do this in the VTK RTTI machinery (as of 5.4.2).





More information about the vtkusers mailing list