[vtk-developers] Casting vtkIntArray vs vtkIdTypeArray
david.cole at kitware.com
Fri Sep 17 15:57:29 EDT 2010
You cannot cast from one sibling class to another. It's not an is-a
relationship. You can only cast up or down the hierarchy according to what
the class of the object actually is.
To go from vtkDoubleArray to vtkFloatArray, you'd have to create a new
vtkFloatArray and then copy its elements over one by one, casting each
Casting only works up and down the parent class chain.
If casting is required, then there is a flaw in a design somewhere. In
general, it shouldn't be required for well-designed programs.
On Fri, Sep 17, 2010 at 3: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?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the vtk-developers