[vtk-developers] Casting vtkIntArray vs vtkIdTypeArray

Jim Peterson jimcp at cox.net
Sat Sep 18 09:54:15 EDT 2010


Also,
The vtkIDType is documented as:

vtkIdType is the integer type used for point and cell identification. 
This type may be either 32-bit or 64-bit, depending on whether 
VTK_USE_64BIT_IDS is defined.

So I believe SafeDownCast is doing it's job well to reject the transform 
from IDType to INT.

Jim


David Gobbi wrote:
> 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
>>
>>
>>
>>     
> _______________________________________________
> 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