[vtkusers] Cast doubt on method vtkFloatArray::GetTuple

David C Thompson dcthomp at sandia.gov
Tue Apr 15 12:32:33 EDT 2008


> 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