[vtkusers] vtkTransform problem: really roundoff error?

David Gobbi david.gobbi at gmail.com
Mon Feb 8 13:27:13 EST 2010


On Mon, Feb 8, 2010 at 10:57 AM, Michele Conconi
<michele.conconi at unibo.it> wrote:
>
> Thank you very much David, that was exactly the problem.
> I agree with everyone suggested me to modify my code and I will. Still, I
> could possible encounter again the same problem even with less inversion.
> Indeed, any modification affect the timestamp and I still have to modify
> many times my vtkTransform. Of course I can do something like delete and
> recreate the vtkTransform after a while, to reset the timestamp, but this
> should slow down my code. Do you know if there is a different way to obtain
> the same result, something like setMTime(zero)? What the purpose of
> timestamp? Why should I be limited in the number of modification to a vtk
> object?
>
> Thank you once again, I feel much better now :)

The timestamp counter is global, so you can't "reset" it by deleting
and recreating the transform.  I'm not going to go into any detail
here about what the timestamp is for, but you should read up on it in
the VTK book or the user guide.  The timestamp is an essential part of
VTK.

Your best bet is to use vtkMatrix4x4 instead of vtkTransform, and
write your own math code for actually doing the rotations etc.  Unlike
vtkTransform, when you do multiplication operations on a vtkMatrix4x4,
the timestamp is not updated.  This is because vtkMatrix4x4 is just
meant to be a data-container class.  The only vtkMatrix4x4 method that
changes the timestamp is SetElement(), and you can avoid this method
by using matrix->DeepCopy() or by setting matrix->Element directly.

Note that vtkTransformPolyDataFilter will also increment the
timestamp, so you shouldn't call it more than 2^32 times.  Instead of
using it, you can write your own code for using the matrix to change
all of the points.  In fact, since you are doing the transform so many
times, this is a good idea anyway because you can modify the points
in-place.

Most people don't have to do these kind of things, because 2^32 is a
very large number and most VTK users never have to worry about
overflowing the timestamp.  Actually, I suggest that you just compile
your code as 64-bit, since that will be much less work for you.

   David



More information about the vtkusers mailing list