Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

Common/vtkTransform.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkTransform.h,v $
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00015 
00051 #ifndef __vtkTransform_h
00052 #define __vtkTransform_h
00053 
00054 #include "vtkLinearTransform.h"
00055 
00056 #include "vtkMatrix4x4.h" // Needed for inline methods
00057 
00058 class VTK_COMMON_EXPORT vtkTransform : public vtkLinearTransform
00059 {
00060  public:
00061   static vtkTransform *New();
00062   vtkTypeRevisionMacro(vtkTransform,vtkLinearTransform);
00063   void PrintSelf(ostream& os, vtkIndent indent);
00064 
00068   void Identity();
00069 
00073   void Inverse();
00074 
00076 
00078   void Translate(double x, double y, double z) {
00079     this->Concatenation->Translate(x,y,z); };
00080   void Translate(const double x[3]) { this->Translate(x[0], x[1], x[2]); };
00081   void Translate(const float x[3]) { this->Translate(x[0], x[1], x[2]); };
00083 
00085 
00089   void RotateWXYZ(double angle, double x, double y, double z) {
00090     this->Concatenation->Rotate(angle,x,y,z); };
00091   void RotateWXYZ(double angle, const double axis[3]) {
00092     this->RotateWXYZ(angle, axis[0], axis[1], axis[2]); };
00093   void RotateWXYZ(double angle, const float axis[3]) {
00094     this->RotateWXYZ(angle, axis[0], axis[1], axis[2]); };
00096 
00098 
00101   void RotateX(double angle) { this->RotateWXYZ(angle, 1, 0, 0); };
00102   void RotateY(double angle) { this->RotateWXYZ(angle, 0, 1, 0); };
00103   void RotateZ(double angle) { this->RotateWXYZ(angle, 0, 0, 1); };
00105 
00107 
00110   void Scale(double x, double y, double z) {
00111     this->Concatenation->Scale(x,y,z); };
00112   void Scale(const double s[3]) { this->Scale(s[0], s[1], s[2]); };
00113   void Scale(const float s[3]) { this->Scale(s[0], s[1], s[2]); };
00115 
00117 
00119   void SetMatrix(vtkMatrix4x4 *matrix) { 
00120     this->SetMatrix(*matrix->Element); };
00121   void SetMatrix(const double elements[16]) { 
00122     this->Identity(); this->Concatenate(elements); };
00124 
00126 
00128   void Concatenate(vtkMatrix4x4 *matrix) { 
00129     this->Concatenate(*matrix->Element); };
00130   void Concatenate(const double elements[16]) {
00131     this->Concatenation->Concatenate(elements); };
00133 
00139   void Concatenate(vtkLinearTransform *transform);
00140 
00142 
00147   void PreMultiply() { 
00148     if (this->Concatenation->GetPreMultiplyFlag()) { return; }
00149     this->Concatenation->SetPreMultiplyFlag(1); this->Modified(); };
00151 
00153 
00158   void PostMultiply()  { 
00159     if (!this->Concatenation->GetPreMultiplyFlag()) { return; }
00160     this->Concatenation->SetPreMultiplyFlag(0); this->Modified(); };
00162 
00164 
00166   int GetNumberOfConcatenatedTransforms() {
00167     return this->Concatenation->GetNumberOfTransforms() + 
00168       (this->Input == NULL ? 0 : 1); };
00170 
00172 
00177   vtkLinearTransform *GetConcatenatedTransform(int i) {
00178     if (this->Input == NULL) {
00179       return (vtkLinearTransform *)this->Concatenation->GetTransform(i); }
00180     else if (i < this->Concatenation->GetNumberOfPreTransforms()) {
00181       return (vtkLinearTransform *)this->Concatenation->GetTransform(i); }
00182     else if (i > this->Concatenation->GetNumberOfPreTransforms()) {
00183       return (vtkLinearTransform *)this->Concatenation->GetTransform(i-1); } 
00184     else if (this->GetInverseFlag()) {
00185       return (vtkLinearTransform *)this->Input->GetInverse(); }
00186     else {
00187       return (vtkLinearTransform *)this->Input; } };
00189 
00191 
00193   void GetOrientation(double orient[3]);
00194   void GetOrientation(float orient[3]) {
00195     double temp[3]; this->GetOrientation(temp); 
00196     orient[0] = static_cast<float>(temp[0]); 
00197     orient[1] = static_cast<float>(temp[1]); 
00198     orient[2] = static_cast<float>(temp[2]); };
00199   double *GetOrientation() { 
00200     this->GetOrientation(this->ReturnValue); return this->ReturnValue; };
00202 
00204 
00205   void GetOrientationWXYZ(double wxyz[4]);
00206   void GetOrientationWXYZ(float wxyz[3]) {
00207     double temp[4]; this->GetOrientationWXYZ(temp); 
00208     wxyz[0]=static_cast<float>(temp[0]); 
00209     wxyz[1]=static_cast<float>(temp[1]); 
00210     wxyz[2]=static_cast<float>(temp[2]); 
00211     wxyz[3]=static_cast<float>(temp[3]);};
00212   double *GetOrientationWXYZ() { 
00213     this->GetOrientationWXYZ(this->ReturnValue); return this->ReturnValue; };
00215 
00217 
00220   void GetPosition(double pos[3]);
00221   void GetPosition(float pos[3]) {
00222     double temp[3]; this->GetPosition(temp); 
00223     pos[0] = static_cast<float>(temp[0]); 
00224     pos[1] = static_cast<float>(temp[1]); 
00225     pos[2] = static_cast<float>(temp[2]); };
00226   double *GetPosition() { 
00227     this->GetPosition(this->ReturnValue); return this->ReturnValue; };
00229 
00231 
00235   void GetScale(double scale[3]);
00236   void GetScale(float scale[3]) {
00237     double temp[3]; this->GetScale(temp); 
00238     scale[0] = static_cast<float>(temp[0]); 
00239     scale[1] = static_cast<float>(temp[1]); 
00240     scale[2] = static_cast<float>(temp[2]); };
00241   double *GetScale() { 
00242     this->GetScale(this->ReturnValue); return this->ReturnValue; };
00244 
00247   void GetInverse(vtkMatrix4x4 *inverse);
00248 
00252   void GetTranspose(vtkMatrix4x4 *transpose);
00253 
00255 
00261   void SetInput(vtkLinearTransform *input);
00262   vtkLinearTransform *GetInput() { return this->Input; };
00264 
00266 
00270   int GetInverseFlag() {
00271     return this->Concatenation->GetInverseFlag(); };
00273 
00275 
00276   void Push() { if (this->Stack == NULL) { 
00277                     this->Stack = vtkTransformConcatenationStack::New(); }
00278                 this->Stack->Push(&this->Concatenation); 
00279                 this->Modified(); };
00281 
00283 
00285   void Pop() { if (this->Stack == NULL) { return; }
00286                this->Stack->Pop(&this->Concatenation);
00287                this->Modified(); };
00289 
00296   int CircuitCheck(vtkAbstractTransform *transform);
00297 
00298   // Return an inverse transform which will always update itself
00299   // to match this transform.
00300   vtkAbstractTransform *GetInverse() { 
00301     return vtkLinearTransform::GetInverse(); }
00302 
00304   vtkAbstractTransform *MakeTransform();
00305 
00307   unsigned long GetMTime();
00308 
00310 
00313   void MultiplyPoint(const float in[4], float out[4]) {
00314     this->GetMatrix()->MultiplyPoint(in,out);};
00315   void MultiplyPoint(const double in[4], double out[4]) {      
00316     this->GetMatrix()->MultiplyPoint(in,out);};
00318 
00319 protected:
00320   vtkTransform ();
00321   ~vtkTransform ();
00322 
00323   void InternalDeepCopy(vtkAbstractTransform *t);
00324 
00325   void InternalUpdate();
00326 
00327   vtkLinearTransform *Input;
00328   vtkTransformConcatenation *Concatenation;
00329   vtkTransformConcatenationStack *Stack;
00330 
00331   // this allows us to check whether people have been fooling
00332   // around with our matrix
00333   unsigned long MatrixUpdateMTime;
00334 
00335   float Point[4];
00336   double DoublePoint[4];
00337   double ReturnValue[4];
00338 private:
00339   vtkTransform (const vtkTransform&);  // Not implemented
00340   void operator=(const vtkTransform&);  // Not implemented
00341 };
00342 
00343 #endif