Common/vtkTransform.h Source File

Main Page Class Hierarchy Alphabetical List Compound List File List Compound 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   Language:  C++
    00006
    00007   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen
    00008   All rights reserved.
    00009   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
    00010
    00011      This software is distributed WITHOUT ANY WARRANTY; without even
    00012      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
    00013      PURPOSE.  See the above copyright notice for more information.
    00014
    00015 =========================================================================*/
    00016
    00069 #ifndef __vtkTransform_h
    00070 #define __vtkTransform_h
    00071
    00072 #include "vtkLinearTransform.h"
    00073
    00074 #include "vtkMatrix4x4.h" // Needed for inline methods
    00075
    00076 class VTK_COMMON_EXPORT vtkTransform : public vtkLinearTransform
    00077 {
    00078  public:
    00079   static vtkTransform *New();
    00080   vtkTypeRevisionMacro(vtkTransform,vtkLinearTransform);
    00081   void PrintSelf(ostream& os, vtkIndent indent);
    00082
    00086   void Identity();
    00087
    00091   void Inverse();
    00092
    00094
    00096   void Translate(double x, double y, double z) {
    00097     this->Concatenation->Translate(x,y,z); };
    00098   void Translate(const double x[3]) { this->Translate(x[0], x[1], x[2]); };
    00099   void Translate(const float x[3]) { this->Translate(x[0], x[1], x[2]); };
    00101
    00103
    00107   void RotateWXYZ(double angle, double x, double y, double z) {
    00108     this->Concatenation->Rotate(angle,x,y,z); };
    00109   void RotateWXYZ(double angle, const double axis[3]) {
    00110     this->RotateWXYZ(angle, axis[0], axis[1], axis[2]); };
    00111   void RotateWXYZ(double angle, const float axis[3]) {
    00112     this->RotateWXYZ(angle, axis[0], axis[1], axis[2]); };
    00114
    00116
    00119   void RotateX(double angle) { this->RotateWXYZ(angle, 1, 0, 0); };
    00120   void RotateY(double angle) { this->RotateWXYZ(angle, 0, 1, 0); };
    00121   void RotateZ(double angle) { this->RotateWXYZ(angle, 0, 0, 1); };
    00123
    00125
    00128   void Scale(double x, double y, double z) {
    00129     this->Concatenation->Scale(x,y,z); };
    00130   void Scale(const double s[3]) { this->Scale(s[0], s[1], s[2]); };
    00131   void Scale(const float s[3]) { this->Scale(s[0], s[1], s[2]); };
    00133
    00135
    00137   void SetMatrix(vtkMatrix4x4 *matrix) {
    00138     this->SetMatrix(*matrix->Element); };
    00139   void SetMatrix(const double elements[16]) {
    00140     this->Identity(); this->Concatenate(elements); };
    00142
    00144
    00146   void Concatenate(vtkMatrix4x4 *matrix) {
    00147     this->Concatenate(*matrix->Element); };
    00148   void Concatenate(const double elements[16]) {
    00149     this->Concatenation->Concatenate(elements); };
    00151
    00157   void Concatenate(vtkLinearTransform *transform);
    00158
    00160
    00165   void PreMultiply() {
    00166     if (this->Concatenation->GetPreMultiplyFlag()) { return; }
    00167     this->Concatenation->SetPreMultiplyFlag(1); this->Modified(); };
    00169
    00171
    00176   void PostMultiply()  {
    00177     if (!this->Concatenation->GetPreMultiplyFlag()) { return; }
    00178     this->Concatenation->SetPreMultiplyFlag(0); this->Modified(); };
    00180
    00182
    00184   int GetNumberOfConcatenatedTransforms() {
    00185     return this->Concatenation->GetNumberOfTransforms() +
    00186       (this->Input == NULL ? 0 : 1); };
    00188
    00190
    00195   vtkLinearTransform *GetConcatenatedTransform(int i) {
    00196     if (this->Input == NULL) {
    00197       return (vtkLinearTransform *)this->Concatenation->GetTransform(i); }
    00198     else if (i < this->Concatenation->GetNumberOfPreTransforms()) {
    00199       return (vtkLinearTransform *)this->Concatenation->GetTransform(i); }
    00200     else if (i > this->Concatenation->GetNumberOfPreTransforms()) {
    00201       return (vtkLinearTransform *)this->Concatenation->GetTransform(i-1); }
    00202     else if (this->GetInverseFlag()) {
    00203       return (vtkLinearTransform *)this->Input->GetInverse(); }
    00204     else {
    00205       return (vtkLinearTransform *)this->Input; } };
    00207
    00209
    00211   void GetOrientation(double orient[3]);
    00212   void GetOrientation(float orient[3]) {
    00213     double temp[3]; this->GetOrientation(temp);
    00214     orient[0] = static_cast<float>(temp[0]);
    00215     orient[1] = static_cast<float>(temp[1]);
    00216     orient[2] = static_cast<float>(temp[2]); };
    00217   float *GetOrientation() {
    00218     this->GetOrientation(this->ReturnValue); return this->ReturnValue; };
    00220
    00222
    00223   void GetOrientationWXYZ(double wxyz[4]);
    00224   void GetOrientationWXYZ(float wxyz[3]) {
    00225     double temp[4]; this->GetOrientationWXYZ(temp);
    00226     wxyz[0]=static_cast<float>(temp[0]);
    00227     wxyz[1]=static_cast<float>(temp[1]);
    00228     wxyz[2]=static_cast<float>(temp[2]);
    00229     wxyz[3]=static_cast<float>(temp[3]);};
    00230   float *GetOrientationWXYZ() {
    00231     this->GetOrientationWXYZ(this->ReturnValue); return this->ReturnValue; };
    00233
    00235
    00238   void GetPosition(double pos[3]);
    00239   void GetPosition(float pos[3]) {
    00240     double temp[3]; this->GetPosition(temp);
    00241     pos[0] = static_cast<float>(temp[0]);
    00242     pos[1] = static_cast<float>(temp[1]);
    00243     pos[2] = static_cast<float>(temp[2]); };
    00244   float *GetPosition() {
    00245     this->GetPosition(this->ReturnValue); return this->ReturnValue; };
    00247
    00249
    00253   void GetScale(double scale[3]);
    00254   void GetScale(float scale[3]) {
    00255     double temp[3]; this->GetScale(temp);
    00256     scale[0] = static_cast<float>(temp[0]);
    00257     scale[1] = static_cast<float>(temp[1]);
    00258     scale[2] = static_cast<float>(temp[2]); };
    00259   float *GetScale() {
    00260     this->GetScale(this->ReturnValue); return this->ReturnValue; };
    00262
    00265   void GetInverse(vtkMatrix4x4 *inverse);
    00266
    00270   void GetTranspose(vtkMatrix4x4 *transpose);
    00271
    00273
    00279   void SetInput(vtkLinearTransform *input);
    00280   vtkLinearTransform *GetInput() { return this->Input; };
    00282
    00284
    00288   int GetInverseFlag() {
    00289     return this->Concatenation->GetInverseFlag(); };
    00291
    00293
    00294   void Push() { if (this->Stack == NULL) {
    00295                     this->Stack = vtkTransformConcatenationStack::New(); }
    00296                 this->Stack->Push(&this->Concatenation);
    00297                 this->Modified(); };
    00299
    00301
    00303   void Pop() { if (this->Stack == NULL) { return; }
    00304                this->Stack->Pop(&this->Concatenation);
    00305                this->Modified(); };
    00307
    00314   int CircuitCheck(vtkAbstractTransform *transform);
    00315
    00316   // Return an inverse transform which will always update itself
    00317   // to match this transform.
    00318   vtkAbstractTransform *GetInverse() {
    00319     return vtkLinearTransform::GetInverse(); }
    00320
    00322   vtkAbstractTransform *MakeTransform();
    00323
    00325   unsigned long GetMTime();
    00326
    00328
    00331   void MultiplyPoint(const float in[4], float out[4]) {
    00332     this->GetMatrix()->MultiplyPoint(in,out);};
    00333   void MultiplyPoint(const double in[4], double out[4]) {
    00334     this->GetMatrix()->MultiplyPoint(in,out);};
    00336
    00337 protected:
    00338   vtkTransform ();
    00339   ~vtkTransform ();
    00340
    00341   void InternalDeepCopy(vtkAbstractTransform *t);
    00342
    00343   void InternalUpdate();
    00344
    00345   vtkLinearTransform *Input;
    00346   vtkTransformConcatenation *Concatenation;
    00347   vtkTransformConcatenationStack *Stack;
    00348
    00349   // this allows us to check whether people have been fooling
    00350   // around with our matrix
    00351   unsigned long MatrixUpdateMTime;
    00352
    00353   float Point[4];
    00354   double DoublePoint[4];
    00355   float ReturnValue[4];
    00356 private:
    00357   vtkTransform (const vtkTransform&);  // Not implemented
    00358   void operator=(const vtkTransform&);  // Not implemented
    00359 };
    00360
    00361 #endif