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

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 
00205   static void GetOrientation(double orient[3], vtkMatrix4x4 *matrix);
00206 
00208 
00210   void GetOrientationWXYZ(double wxyz[4]);
00211   void GetOrientationWXYZ(float wxyz[3]) {
00212     double temp[4]; this->GetOrientationWXYZ(temp); 
00213     wxyz[0]=static_cast<float>(temp[0]); 
00214     wxyz[1]=static_cast<float>(temp[1]); 
00215     wxyz[2]=static_cast<float>(temp[2]); 
00216     wxyz[3]=static_cast<float>(temp[3]);};
00217   double *GetOrientationWXYZ() { 
00218     this->GetOrientationWXYZ(this->ReturnValue); return this->ReturnValue; };
00220 
00222 
00225   void GetPosition(double pos[3]);
00226   void GetPosition(float pos[3]) {
00227     double temp[3]; this->GetPosition(temp); 
00228     pos[0] = static_cast<float>(temp[0]); 
00229     pos[1] = static_cast<float>(temp[1]); 
00230     pos[2] = static_cast<float>(temp[2]); };
00231   double *GetPosition() { 
00232     this->GetPosition(this->ReturnValue); return this->ReturnValue; };
00234 
00236 
00240   void GetScale(double scale[3]);
00241   void GetScale(float scale[3]) {
00242     double temp[3]; this->GetScale(temp); 
00243     scale[0] = static_cast<float>(temp[0]); 
00244     scale[1] = static_cast<float>(temp[1]); 
00245     scale[2] = static_cast<float>(temp[2]); };
00246   double *GetScale() { 
00247     this->GetScale(this->ReturnValue); return this->ReturnValue; };
00249 
00252   void GetInverse(vtkMatrix4x4 *inverse);
00253 
00257   void GetTranspose(vtkMatrix4x4 *transpose);
00258 
00260 
00266   void SetInput(vtkLinearTransform *input);
00267   vtkLinearTransform *GetInput() { return this->Input; };
00269 
00271 
00275   int GetInverseFlag() {
00276     return this->Concatenation->GetInverseFlag(); };
00278 
00280 
00281   void Push() { if (this->Stack == NULL) { 
00282                     this->Stack = vtkTransformConcatenationStack::New(); }
00283                 this->Stack->Push(&this->Concatenation); 
00284                 this->Modified(); };
00286 
00288 
00290   void Pop() { if (this->Stack == NULL) { return; }
00291                this->Stack->Pop(&this->Concatenation);
00292                this->Modified(); };
00294 
00301   int CircuitCheck(vtkAbstractTransform *transform);
00302 
00303   // Return an inverse transform which will always update itself
00304   // to match this transform.
00305   vtkAbstractTransform *GetInverse() { 
00306     return vtkLinearTransform::GetInverse(); }
00307 
00309   vtkAbstractTransform *MakeTransform();
00310 
00312   unsigned long GetMTime();
00313 
00315 
00318   void MultiplyPoint(const float in[4], float out[4]) {
00319     this->GetMatrix()->MultiplyPoint(in,out);};
00320   void MultiplyPoint(const double in[4], double out[4]) {      
00321     this->GetMatrix()->MultiplyPoint(in,out);};
00323 
00324 protected:
00325   vtkTransform ();
00326   ~vtkTransform ();
00327 
00328   void InternalDeepCopy(vtkAbstractTransform *t);
00329 
00330   void InternalUpdate();
00331 
00332   vtkLinearTransform *Input;
00333   vtkTransformConcatenation *Concatenation;
00334   vtkTransformConcatenationStack *Stack;
00335 
00336   // this allows us to check whether people have been fooling
00337   // around with our matrix
00338   unsigned long MatrixUpdateMTime;
00339 
00340   float Point[4];
00341   double DoublePoint[4];
00342   double ReturnValue[4];
00343 private:
00344   vtkTransform (const vtkTransform&);  // Not implemented
00345   void operator=(const vtkTransform&);  // Not implemented
00346 };
00347 
00348 #endif

Generated on Mon Jan 21 23:07:18 2008 for VTK by  doxygen 1.4.3-20050530