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

00001 /*=========================================================================
00002 
00003   Library   : Image Registration Toolkit (IRTK)
00004   Module    : $Id: irtkMultiLevelFreeFormTransformation.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 _IRTKMULTILEVELFREEFORMTRANSFORMATION_H
00014 
00015 #define _IRTKMULTILEVELFREEFORMTRANSFORMATION_H
00016 
00017 #include <irtkGeometry.h>
00018 
00019 #define MAX_TRANS 100
00020 
00030 class irtkMultiLevelFreeFormTransformation : public irtkAffineTransformation
00031 {
00032 
00033 public:
00034 
00036   irtkFreeFormTransformation *_localTransformation[MAX_TRANS];
00037 
00039   int _NumberOfLevels;
00040 
00042   irtkMultiLevelFreeFormTransformation();
00043 
00045   irtkMultiLevelFreeFormTransformation(const irtkRigidTransformation &);
00046 
00048   irtkMultiLevelFreeFormTransformation(const irtkAffineTransformation &);
00049 
00051   irtkMultiLevelFreeFormTransformation(const irtkMultiLevelFreeFormTransformation &);
00052 
00054   virtual ~irtkMultiLevelFreeFormTransformation();
00055 
00057   virtual int NumberOfLevels() const;
00058 
00060   virtual irtkFreeFormTransformation *GetLocalTransformation(int);
00061 
00063   virtual void PutLocalTransformation(irtkFreeFormTransformation *, int);
00064 
00066   virtual void PushLocalTransformation(irtkFreeFormTransformation *);
00067 
00069   virtual irtkFreeFormTransformation *PopLocalTransformation();
00070 
00072   virtual void Transform(double &, double &, double &, double = 0);
00073 
00075   virtual void Displacement(double& x, double& y, double& z, double = 0);
00076 
00078   virtual void GlobalTransform(double &, double &, double &, double = 0);
00079 
00081   virtual void LocalTransform (double &, double &, double &, double = 0);
00082 
00084   virtual void GlobalDisplacement(double &, double &, double &, double = 0);
00085 
00087   virtual void LocalDisplacement(double &, double &, double &, double = 0);
00088 
00090   virtual void Transform(int, double &, double &, double &, double = 0);
00091 
00093   virtual void LocalTransform (int, double &, double &, double &, double = 0);
00094 
00096   virtual void LocalDisplacement(int, double &, double &, double &, double = 0);
00097 
00099   virtual void Jacobian(irtkMatrix &, double, double, double, double = 0);
00100 
00102   virtual void LocalJacobian(irtkMatrix &, double, double, double, double = 0);
00103 
00108   virtual double Approximate(double *, double *, double *,
00109                              double *, double *, double *, int);
00110 
00112   virtual double Inverse(double &, double &, double &, double = 0, double = 0.01);
00113 
00115   virtual double Inverse(int, double &, double &, double &, double = 0, double = 0.01);
00116 
00118   virtual Bool IsIdentity();
00119 
00121   virtual void Print();
00122 
00124   static int CheckHeader(char *);
00125 
00127   virtual const char *NameOfClass();
00128 
00130   virtual irtkCifstream& Read(irtkCifstream&);
00131 
00133   virtual irtkCofstream& Write(irtkCofstream&);
00134 
00136   virtual istream& Import(istream&);
00137 
00139   virtual ostream& Export(ostream&);
00140 
00141 };
00142 
00143 inline int irtkMultiLevelFreeFormTransformation::NumberOfLevels() const
00144 {
00145   return _NumberOfLevels;
00146 }
00147 
00148 inline irtkFreeFormTransformation *irtkMultiLevelFreeFormTransformation::GetLocalTransformation(int level)
00149 {
00150   if (level < _NumberOfLevels) {
00151     return _localTransformation[level];
00152   } else {
00153     cerr << "irtkMultiLevelFreeFormTransformation::GetLocalTransformation: No such "
00154          << "transformation" << endl;
00155     exit(1);
00156   }
00157 }
00158 
00159 inline void irtkMultiLevelFreeFormTransformation::PutLocalTransformation(irtkFreeFormTransformation *transformation, int i)
00160 {
00161   if (i < _NumberOfLevels) {
00162     _localTransformation[i] = transformation;
00163   } else {
00164     cerr << "irtkMultiLevelFreeFormTransformation::PutLocalTransformation: No such "
00165          << "transformation" << endl;
00166     exit(1);
00167   }
00168 }
00169 
00170 inline void irtkMultiLevelFreeFormTransformation::PushLocalTransformation(irtkFreeFormTransformation *transformation)
00171 {
00172   if (_NumberOfLevels < MAX_TRANS) {
00173     _localTransformation[_NumberOfLevels] = transformation;
00174     _NumberOfLevels++;
00175   } else {
00176     cerr << "irtkMultiLevelFreeFormTransformation::PushLocalTransformation: Stack "
00177          << "overflow" << endl;
00178     exit(1);
00179   }
00180 }
00181 
00182 inline irtkFreeFormTransformation *irtkMultiLevelFreeFormTransformation::PopLocalTransformation()
00183 {
00184   irtkFreeFormTransformation *localTransformation;
00185 
00186   if (_NumberOfLevels > 0) {
00187     localTransformation = _localTransformation[_NumberOfLevels-1];
00188     _localTransformation[_NumberOfLevels-1] = NULL;
00189     _NumberOfLevels--;
00190   } else {
00191     cerr << "irtkMultiLevelFreeFormTransformation:PopLocalTransformation: Stack "
00192          << "underflow" << endl;
00193     exit(1);
00194   }
00195   return localTransformation;
00196 }
00197 
00198 inline const char *irtkMultiLevelFreeFormTransformation::NameOfClass()
00199 {
00200   return "irtkMultiLevelFreeFormTransformation";
00201 
00202 }
00203 
00204 #endif