VTK
dox/Common/Transforms/vtkGeneralTransform.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkGeneralTransform.h
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 =========================================================================*/
00031 #ifndef __vtkGeneralTransform_h
00032 #define __vtkGeneralTransform_h
00033 
00034 #include "vtkCommonTransformsModule.h" // For export macro
00035 #include "vtkAbstractTransform.h"
00036 
00037 #include "vtkMatrix4x4.h" // Needed for inline methods
00038 
00039 class VTKCOMMONTRANSFORMS_EXPORT vtkGeneralTransform : public vtkAbstractTransform
00040 {
00041 public:
00042   static vtkGeneralTransform *New();
00043 
00044   vtkTypeMacro(vtkGeneralTransform,vtkAbstractTransform);
00045   void PrintSelf(ostream& os, vtkIndent indent);
00046 
00050   void Identity() { this->Concatenation->Identity(); this->Modified(); };
00051 
00055   void Inverse() { this->Concatenation->Inverse(); this->Modified(); };
00056 
00058 
00060   void Translate(double x, double y, double z) {
00061     this->Concatenation->Translate(x,y,z); };
00062   void Translate(const double x[3]) { this->Translate(x[0], x[1], x[2]); };
00063   void Translate(const float x[3]) { this->Translate(x[0], x[1], x[2]); };
00065 
00067 
00071   void RotateWXYZ(double angle, double x, double y, double z) {
00072     this->Concatenation->Rotate(angle,x,y,z); };
00073   void RotateWXYZ(double angle, const double axis[3]) {
00074     this->RotateWXYZ(angle, axis[0], axis[1], axis[2]); };
00075   void RotateWXYZ(double angle, const float axis[3]) {
00076     this->RotateWXYZ(angle, axis[0], axis[1], axis[2]); };
00078 
00080 
00083   void RotateX(double angle) { this->RotateWXYZ(angle, 1, 0, 0); };
00084   void RotateY(double angle) { this->RotateWXYZ(angle, 0, 1, 0); };
00085   void RotateZ(double angle) { this->RotateWXYZ(angle, 0, 0, 1); };
00087 
00089 
00092   void Scale(double x, double y, double z) {
00093     this->Concatenation->Scale(x,y,z); };
00094   void Scale(const double s[3]) { this->Scale(s[0], s[1], s[2]); };
00095   void Scale(const float s[3]) { this->Scale(s[0], s[1], s[2]); };
00097 
00099 
00101   void Concatenate(vtkMatrix4x4 *matrix) {
00102     this->Concatenate(*matrix->Element); };
00103   void Concatenate(const double elements[16]) {
00104     this->Concatenation->Concatenate(elements); };
00106 
00112   void Concatenate(vtkAbstractTransform *transform);
00113 
00115 
00120   void PreMultiply() {
00121     if (this->Concatenation->GetPreMultiplyFlag()) { return; }
00122     this->Concatenation->SetPreMultiplyFlag(1); this->Modified(); };
00124 
00126 
00131   void PostMultiply()  {
00132     if (!this->Concatenation->GetPreMultiplyFlag()) { return; }
00133     this->Concatenation->SetPreMultiplyFlag(0); this->Modified(); };
00135 
00137 
00139   int GetNumberOfConcatenatedTransforms() {
00140     return this->Concatenation->GetNumberOfTransforms() +
00141       (this->Input == NULL ? 0 : 1); };
00143 
00145 
00150   vtkAbstractTransform *GetConcatenatedTransform(int i) {
00151     if (this->Input == NULL) {
00152       return this->Concatenation->GetTransform(i); }
00153     else if (i < this->Concatenation->GetNumberOfPreTransforms()) {
00154       return this->Concatenation->GetTransform(i); }
00155     else if (i > this->Concatenation->GetNumberOfPreTransforms()) {
00156       return this->Concatenation->GetTransform(i-1); }
00157     else if (this->GetInverseFlag()) {
00158       return this->Input->GetInverse(); }
00159     else {
00160       return this->Input; } };
00162 
00164 
00170   void SetInput(vtkAbstractTransform *input);
00171   vtkAbstractTransform *GetInput() { return this->Input; };
00173 
00175 
00179   int GetInverseFlag() {
00180     return this->Concatenation->GetInverseFlag(); };
00182 
00184 
00185   void Push() { if (this->Stack == NULL) {
00186                     this->Stack = vtkTransformConcatenationStack::New(); }
00187                 this->Stack->Push(&this->Concatenation);
00188                 this->Modified(); };
00190 
00192 
00194   void Pop() { if (this->Stack == NULL) { return; }
00195                this->Stack->Pop(&this->Concatenation);
00196                this->Modified(); };
00198 
00200 
00202   void InternalTransformPoint(const float in[3], float out[3]);
00203   void InternalTransformPoint(const double in[3], double out[3]);
00205 
00207 
00209   void InternalTransformDerivative(const float in[3], float out[3],
00210                                    float derivative[3][3]);
00211   void InternalTransformDerivative(const double in[3], double out[3],
00212                                    double derivative[3][3]);
00214 
00221   int CircuitCheck(vtkAbstractTransform *transform);
00222 
00224   vtkAbstractTransform *MakeTransform();
00225 
00227   unsigned long GetMTime();
00228 
00229 protected:
00230   vtkGeneralTransform();
00231   ~vtkGeneralTransform();
00232 
00233   void InternalDeepCopy(vtkAbstractTransform *t);
00234   void InternalUpdate();
00235 
00236   vtkAbstractTransform *Input;
00237   vtkTransformConcatenation *Concatenation;
00238   vtkTransformConcatenationStack *Stack;
00239 private:
00240   vtkGeneralTransform(const vtkGeneralTransform&);  // Not implemented.
00241   void operator=(const vtkGeneralTransform&);  // Not implemented.
00242 };
00243 
00244 
00245 #endif
00246 
00247 
00248 
00249 
00250