[vtk-developers] Casting vtkIntArray vs vtkIdTypeArray

David Gobbi david.gobbi at gmail.com
Fri Sep 17 16:03:54 EDT 2010


Hi David,

I think you misunderstand what "SafeDownCast" does.
After every SafeDownCast(), you must check the result
to make sure that it isn't NULL.  That is what dynamic
casting is all about: it is an _attempt_ to do a cast when
you aren't sure if the object is of the correct type.

You can write code that is robust to a large number of
array types by adding a "switch" statement.  If you combine
the switch with a templated function, then you will
end up with the same mechanism that VTK's image filters
use to deal with arrays of different types.

  David


On Fri, Sep 17, 2010 at 1:53 PM, David Doria <daviddoria at gmail.com> wrote:
> On Fri, Sep 17, 2010 at 3:50 PM, David Cole <david.cole at kitware.com> wrote:
>>
>> That's not a C++ cast, that's a transformation operation....
>> All the array classes are siblings of each other, aren't they?
>>
>
> Maybe my terminology is off, but whatever it is called I feel that it should
> work and it currently doesn't :)
> Yes, they are all siblings. Are you recommending first SafeDownCasting to a
> vtkDataArray, checking the type, and then performing the appropriate
> SafeDownCast? That seems like a lot of trouble, no?
> David
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtk-developers
>
>
>



More information about the vtk-developers mailing list