New VTK transform classes

David Gobbi dgobbi at irus.rri.on.ca
Mon Mar 6 10:55:31 EST 2000


Hi All,

I've added a new set of vtk*Transform classes to VTK recently.
These extent the vtkGeneralTransform heirarchy which was
introduced in VTK 3.1:

Abstract Classes                         Concrete Classes
----------------                         ----------------

vtkGeneralTransform
       |        \
       |         vtkWarpTransform ------ vtkThinPlateSplineTransform
       |                              \- vtkGridTransform (not ready yet)
       |
vtkPerspectiveTransform ---------------- vtkProjectionTransform
       |
vtkLinearTransform --------------------- vtkTransform
                                   \---- vtkQuaternionTransform
                                    \--- vtkIdentityTransform

The vtkGeneralTransform and vtkThinPlateSplineTransform were added in
vtk 3.1, and the vtkTransform goes waaay back.  All of the other transform
classes are new.  

The modifications to vtkTransform are 100% backwards compatible.


A brief description of each transform:
-------------------------------------

vtkTransform -- Describes a linear (i.e. affine) transformation.  In the
                past this was also used for perspective transformations --
                this is to be strongly discouraged.

vtkQuaternionTransform -- Describes a linear transformation based on 
                quaternions:  this restricts the transformation to
                rotation and isotropic scale.  It has an 
                InterpolateTransform() method that allows SLERP-style
                interpolation between key frames (anyone want to add
                SQUAD?)

vtkIdentityTransform -- Does absolutely nothing, but does it more efficently
                 than any other transformation.

vtkProjectionTransform -- Perspective (e.g. camera-style) transformations.
                 For now, you have to build the 4x4 projection matrix
                 yourself.  If anyone wants to move some of the
                 vtkCamera.cxx code to vtkProjectionTransform.cxx, that
                 would be great.

vtkThinPlateSplineTransform -- A warp transformation that uses a set
                 of control points and a radial basis function.  Right
                 now only two RBFs are available, more will be added
                 in the future.

vtkGridTransform -- A warp transformation defined in terms of a 
                 regularely sampled 3D grid of displacement vectors.
                 It's not in VTK yet, because I haven't found time
                 to properly test it.


The new transform pipeline
--------------------------

There are also a set of vtk*TransformConcatenation classes to allow
you to build a transformation pipeline:

vtkGeneralTransformConcatenation     - concatenate any transforms
vtkPerspectiveTransformConcatenation - concatenate perspective transforms
vtkLinearTransformConcatenation      - concatenate linear transforms

For example:

 vtkThinPlateSplineTransform     vtkTransform
          |                           |
          |                       [ invert ]
          |                           |
          \-----[ concatenate ]-------/ 
                       |
                       v
     [ vtkTransformPolyDataFilter SetTransform ]


vtkThinPlateSplineTransform warpTrans
warpTrans SetSourceLandmarks points1
warpTrans SetTargetLandmarks points2

vtkTransform linearTrans
linearTrans RotateX 30

vtkGeneralTransformConcatenation concat   # create identity
concat Concatenate warpTrans
concat Concatenate [linearTrans GetInverse]

vtkTransformPolyDataFilter poly
poly SetTransform concat
poly SetInput input       # some input vtkPolyData

Now 'concat' is a concatenation of 'warpTrans' and the inverse of
'linearTrans.'   If you modify one of the transforms (e.g. change the
ThinPlateSpline control points) the concatenation will automatically 
update to reflect the change.


Note that inversion is pipelined in a simlilar manner to concatenation,
e.g. if you do

vtkTransformPolyDataFilter poly
poly SetTransform [warpTrans GetInverse]

and then modify the warpTrans control points, you do not have to
call "poly SetTransform [warpTrans GetInverse]" again to force an
update -- everything is automatic.

The inversion is handled by a proxy class, vtkGeneralTransformInverse.


Tcl Examples
------------

contrib/thinPlate.tcl
contrib/TestWarpReslice.tcl
(More & better examples will be added soon)


Future changes
--------------

Currently only two other vtk classes know about the vtkGeneralTransform
heirarchy: vtkTransformPolyDataFilter and vtkImageReslice.  The following
classes can also also be changed with minimal work:

common/vtkImplicitFunction   - SetTransform(vtkGeneralTransform *)
graphics/vtkTransformFilter  - SetTransform(vtkGeneralTransform *)

As well, there are several classes that could be internally
modified to be implemented in terms of the new transformations.  
The best examples of this are vtkProp3D and vtkCamera.  I plan to
make the vtkProp3D (i.e. vtkActor) changes myself sometime this week.


Also, if anyone is interested in doing animation with VTK, it might
be worthwhile to make a vtkQuaternionTransformCollection that 
provides high-quality interpolation between a set of key-frame
transformations.  Key-frame interpolation can already be done in VTK
with the old vtkTransform, but the vtkQuaternionTransform is much 
better suited for this.  Between transform interpolation and the 
vtkLinearTransformConcatenation class (to handle joints etc)
there is a much greater potential for VTK to be used in animation.

 - David

--
  David Gobbi, MSc                    dgobbi at irus.rri.on.ca
  Advanced Imaging Research Group
  Robarts Research Institute, University of Western Ontario

--------------------------------------------------------------------
This is the private VTK discussion list. Please keep messages on-topic.
Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
<majordomo at public.kitware.com>. For help, send message body containing
"info vtkusers" to the same address.
--------------------------------------------------------------------



More information about the vtkusers mailing list