[vtkusers] Determining Actor type

Marcus D. Hanwell marcus.hanwell at kitware.com
Sat Feb 20 10:04:59 EST 2010


On Sat, Feb 20, 2010 at 8:27 AM, David Gobbi <david.gobbi at gmail.com> wrote:

> On Fri, Feb 19, 2010 at 11:43 PM, Kenneth Porter <shiva at sewingwitch.com>
> wrote:
> > --On Friday, February 19, 2010 10:18 PM -0700 David Gobbi
> > <david.gobbi at gmail.com> wrote:
> >
> >> All VTK classes also have a casting method called SafeDownCast() that
> >> should be used instead of dynamic_cast<>().
> >
> > Again, this only works for leaf classes. It doesn't have any machinery
> for
> > matching an intermediate class. Leaf classes are the most common case, so
> > this will work in most cases.
>
> Both IsA() and SafeDownCast() have the appropriate machinery and they
> just fine for intermediate classes.  Can you give an example where
> they don't work?
>

I was about to ask the same question. I have used IsA() to check whether a
vtAbstractArray was one of the vtkDataArray subclasses before doing a cast
and numerical calculations. I assumed that this was a general mechanism that
could be used. I thought for the vtkObject derived classes this was the
preferable method to dynamic_cast.

Marcus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100220/dddd90d3/attachment.htm>


More information about the vtkusers mailing list