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

vtkGeneralTransform.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkGeneralTransform.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 =========================================================================*/
00041 #ifndef __vtkGeneralTransform_h
00042 #define __vtkGeneralTransform_h
00043 
00044 #include "vtkAbstractTransform.h"
00045 
00046 #include "vtkMatrix4x4.h" // Needed for inline methods
00047 
00048 class VTK_COMMON_EXPORT vtkGeneralTransform : public vtkAbstractTransform
00049 {
00050 public:
00051   static vtkGeneralTransform *New();
00052 
00053   vtkTypeRevisionMacro(vtkGeneralTransform,vtkAbstractTransform);
00054   void PrintSelf(ostream& os, vtkIndent indent);
00055   
00059   void Identity() { this->Concatenation->Identity(); this->Modified(); };
00060 
00064   void Inverse() { this->Concatenation->Inverse(); this->Modified(); };
00065 
00067 
00069   void Translate(double x, double y, double z) {
00070     this->Concatenation->Translate(x,y,z); };
00071   void Translate(const double x[3]) { this->Translate(x[0], x[1], x[2]); };
00072   void Translate(const float x[3]) { this->Translate(x[0], x[1], x[2]); };
00074 
00076 
00080   void RotateWXYZ(double angle, double x, double y, double z) {
00081     this->Concatenation->Rotate(angle,x,y,z); };
00082   void RotateWXYZ(double angle, const double axis[3]) {
00083     this->RotateWXYZ(angle, axis[0], axis[1], axis[2]); };
00084   void RotateWXYZ(double angle, const float axis[3]) {
00085     this->RotateWXYZ(angle, axis[0], axis[1], axis[2]); };
00087 
00089 
00092   void RotateX(double angle) { this->RotateWXYZ(angle, 1, 0, 0); };
00093   void RotateY(double angle) { this->RotateWXYZ(angle, 0, 1, 0); };
00094   void RotateZ(double angle) { this->RotateWXYZ(angle, 0, 0, 1); };
00096 
00098 
00101   void Scale(double x, double y, double z) {
00102     this->Concatenation->Scale(x,y,z); };
00103   void Scale(const double s[3]) { this->Scale(s[0], s[1], s[2]); };
00104   void Scale(const float s[3]) { this->Scale(s[0], s[1], s[2]); };
00106 
00108 
00110   void Concatenate(vtkMatrix4x4 *matrix) { 
00111     this->Concatenate(*matrix->Element); };
00112   void Concatenate(const double elements[16]) {
00113     this->Concatenation->Concatenate(elements); };
00115 
00121   void Concatenate(vtkAbstractTransform *transform);
00122 
00124 
00129   void PreMultiply() { 
00130     if (this->Concatenation->GetPreMultiplyFlag()) { return; }
00131     this->Concatenation->SetPreMultiplyFlag(1); this->Modified(); };
00133 
00135 
00140   void PostMultiply()  { 
00141     if (!this->Concatenation->GetPreMultiplyFlag()) { return; }
00142     this->Concatenation->SetPreMultiplyFlag(0); this->Modified(); };
00144 
00146 
00148   int GetNumberOfConcatenatedTransforms() {
00149     return this->Concatenation->GetNumberOfTransforms() + 
00150       (this->Input == NULL ? 0 : 1); };
00152 
00154 
00159   vtkAbstractTransform *GetConcatenatedTransform(int i) {
00160     if (this->Input == NULL) {
00161       return this->Concatenation->GetTransform(i); }
00162     else if (i < this->Concatenation->GetNumberOfPreTransforms()) {
00163       return this->Concatenation->GetTransform(i); }
00164     else if (i > this->Concatenation->GetNumberOfPreTransforms()) {
00165       return this->Concatenation->GetTransform(i-1); } 
00166     else if (this->GetInverseFlag()) {
00167       return this->Input->GetInverse(); }
00168     else {
00169       return this->Input; } };
00171 
00173 
00179   void SetInput(vtkAbstractTransform *input);
00180   vtkAbstractTransform *GetInput() { return this->Input; };
00182 
00184 
00188   int GetInverseFlag() {
00189     return this->Concatenation->GetInverseFlag(); };
00191 
00193 
00194   void Push() { if (this->Stack == NULL) { 
00195                     this->Stack = vtkTransformConcatenationStack::New(); }
00196                 this->Stack->Push(&this->Concatenation); 
00197                 this->Modified(); };
00199 
00201 
00203   void Pop() { if (this->Stack == NULL) { return; }
00204                this->Stack->Pop(&this->Concatenation);
00205                this->Modified(); };
00207 
00209 
00211   void InternalTransformPoint(const float in[3], float out[3]);
00212   void InternalTransformPoint(const double in[3], double out[3]);
00214 
00216 
00218   void InternalTransformDerivative(const float in[3], float out[3],
00219                                    float derivative[3][3]);
00220   void InternalTransformDerivative(const double in[3], double out[3],
00221                                    double derivative[3][3]);
00223 
00230   int CircuitCheck(vtkAbstractTransform *transform);
00231 
00233   vtkAbstractTransform *MakeTransform();
00234 
00236   unsigned long GetMTime();
00237 
00238 protected:
00239   vtkGeneralTransform();
00240   ~vtkGeneralTransform();
00241 
00242   void InternalDeepCopy(vtkAbstractTransform *t);
00243   void InternalUpdate();
00244 
00245   vtkAbstractTransform *Input;
00246   vtkTransformConcatenation *Concatenation;
00247   vtkTransformConcatenationStack *Stack;
00248 private:
00249   vtkGeneralTransform(const vtkGeneralTransform&);  // Not implemented.
00250   void operator=(const vtkGeneralTransform&);  // Not implemented.
00251 };
00252 
00253 
00254 #endif
00255 
00256 
00257 
00258 
00259