/vol/vipdata/irtk/packages/transformation/include/irtkLinearFreeFormTransformation.h

00001 /*=========================================================================
00002 
00003   Library   : Image Registration Toolkit (IRTK)
00004   Module    : $Id: irtkLinearFreeFormTransformation.h 2 2008-12-23 12:40:14Z dr $
00005   Copyright : Imperial College, Department of Computing
00006               Visual Information Processing (VIP), 2008 onwards
00007   Date      : $Date: 2008-12-23 12:40:14 +0000 (Tue, 23 Dec 2008) $
00008   Version   : $Revision: 2 $
00009   Changes   : $Author: dr $
00010 
00011 =========================================================================*/
00012 
00013 #ifndef _IRTKLINEARFREEFORMTRANSFORMATION_H
00014 
00015 #define _IRTKLINEARFREEFORMTRANSFORMATION_H
00016 
00017 #include <irtkGeometry.h>
00018 
00025 class irtkLinearFreeFormTransformation : public irtkFreeFormTransformation3D
00026 {
00027 
00028 public:
00029 
00031   irtkLinearFreeFormTransformation();
00032 
00034   irtkLinearFreeFormTransformation(irtkBaseImage &, double = 1, double = 1, double = 1);
00035 
00037   irtkLinearFreeFormTransformation(double x1, double y1, double z1,
00038                                    double x2, double y2, double z2,
00039                                    double dx, double dy, double dz,
00040                                    double* xaxis, double* yaxis, double* zaxis);
00041 
00043   irtkLinearFreeFormTransformation(const class irtkLinearFreeFormTransformation &);
00044 
00046   irtkLinearFreeFormTransformation(const class irtkBSplineFreeFormTransformation3D &);
00047 
00049   virtual ~irtkLinearFreeFormTransformation();
00050 
00055   virtual double Approximate(double *, double *, double *,
00056                              double *, double *, double *, int);
00057 
00064   virtual void Interpolate(double* dxs, double* dys, double* dzs);
00065 
00067   virtual void Subdivide();
00068 
00070   virtual void FFD1(double &, double &, double &) const;
00071 
00073   virtual void FFD2(double &, double &, double &) const;
00074 
00076   virtual void Transform(double &, double &, double &, double = 0);
00077 
00079   virtual void Transform2(double &, double &, double &, double = 0);
00080 
00082   virtual void GlobalTransform(double &, double &, double &, double = 0);
00083 
00085   virtual void LocalTransform (double &, double &, double &, double = 0);
00086 
00088   virtual void GlobalDisplacement(double &, double &, double &, double = 0);
00089 
00091   virtual void LocalDisplacement(double &, double &, double &, double = 0);
00092 
00094   virtual void Jacobian(irtkMatrix &, double, double, double, double = 0);
00095 
00097   virtual void LocalJacobian(irtkMatrix &, double, double, double, double = 0);
00098 
00100   virtual void GlobalJacobian(irtkMatrix &, double, double, double, double = 0);
00101 
00103   virtual double Bending(double x, double y, double z);
00104 
00109   virtual void BoundingBox(int, irtkPoint &, irtkPoint &, double = 1) const;
00110 
00115   virtual void BoundingBox(int, double &, double &, double &,
00116                            double &, double &, double &, double = 1) const;
00117 
00122   virtual void BoundingBox(irtkGreyImage *, int, int &, int &, int &,
00123                            int &, int &, int &, double = 1) const;
00124 
00126   virtual void Print();
00127 
00129   static int CheckHeader(char *);
00130 
00132   virtual const char *NameOfClass();
00133 
00135   virtual irtkCifstream& Read(irtkCifstream&);
00136 
00138   virtual irtkCofstream& Write(irtkCofstream&);
00139 
00141   virtual istream& Import(istream&);
00142 
00144   virtual ostream& Export(ostream&);
00145 
00146 };
00147 
00148 inline void irtkLinearFreeFormTransformation::Transform(double &x, double &y, double &z, double)
00149 {
00150   double u, v, w;
00151 
00152   u = x;
00153   v = y;
00154   w = z;
00155 
00156   // Convert world coordinates in to FFD coordinates
00157   this->WorldToLattice(u, v, w);
00158 
00159   // Calculate FFD
00160   this->FFD1(u, v, w);
00161 
00162   // Add FFD to world coordinates
00163   x += u;
00164   y += v;
00165   z += w;
00166 
00167 }
00168 
00169 inline void irtkLinearFreeFormTransformation::Transform2(double &x, double &y, double &z, double)
00170 {
00171   double u, v, w;
00172 
00173   u = x;
00174   v = y;
00175   w = z;
00176 
00177   // Convert world coordinates in to FFD coordinates
00178   this->WorldToLattice(u, v, w);
00179 
00180   // Calculate FFD
00181   this->FFD2(u, v, w);
00182 
00183   // Add FFD to world coordinates
00184   x += u;
00185   y += v;
00186   z += w;
00187 }
00188 
00189 inline void irtkLinearFreeFormTransformation::GlobalTransform(double &x, double &y, double &z, double)
00190 {}
00191 
00192 inline void irtkLinearFreeFormTransformation::LocalTransform(double &x, double &y, double &z, double t)
00193 {
00194   double u, v, w;
00195 
00196   u = x;
00197   v = y;
00198   w = z;
00199 
00200   // calculate displacement
00201   this->LocalDisplacement(u, v, w, t);
00202 
00203   // Add displacement
00204   x += u;
00205   y += v;
00206   z += w;
00207 }
00208 
00209 inline void irtkLinearFreeFormTransformation::GlobalDisplacement(double &x, double &y, double &z, double)
00210 {
00211   x = 0;
00212   y = 0;
00213   z = 0;
00214 }
00215 
00216 inline void irtkLinearFreeFormTransformation::LocalDisplacement(double &x, double &y, double &z, double)
00217 {
00218   // Convert world coordinates in to FFD coordinates
00219   this->WorldToLattice(x, y, z);
00220 
00221   // Calculate FFD
00222   this->FFD1(x, y, z);
00223 }
00224 
00225 inline const char *irtkLinearFreeFormTransformation::NameOfClass()
00226 {
00227   return "irtkLinearFreeFormTransformation";
00228 }
00229 
00230 #endif