[vtkusers] Cast doubt on method vtkFloatArray::GetTuple

Renato N. Elias rnelias at nacad.ufrj.br
Wed Apr 16 09:45:10 EDT 2008


I see, I thought something would be lost in the first cast from double 
to float that could not be recovered when calling the GetTuple method. 
My doubt came from this.

thanks

Renato.

David C Thompson wrote:
>> Since vtkFloatArray is a float type, why (or how) does the GetTuple
>> method return a double?
>>     
> All the vtkDataArray subclasses use doubles for access to tuples. This
> is because they implement virtual methods defined on vtkDataArray and
> the return type may not be overridden. Internally, each array keeps a
> pointer to a single tuple's worth of doubles and copies values into it
> when you request a tuple.
>
>   
>> I'm using a vtkFloatArray to point to the output of a normals generation
>> filter. In this case, I had to performe a "SafeDownCast" from the output
>> of the normals filter to the vtkFloatArray. After that, when I was
>> getting the tuples from vtkFloatArray I noticed that the method returns
>> a double (again). Well, although not being a C++ programmer, it seemed a
>> bit weird. Is it safe (or even common in C++)?
>>     
> After you downcast to a particular subclass of vtkDataArray, you can use
> GetValue to access data via its native type. This method isn't inherited
> so the return type can vary from class to class. It only provides access
> to a single value at a time, though.
>
> 	David
>
>
>   




More information about the vtkusers mailing list