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 
00008 Copyright (c) 1993-2001 Ken Martin, Will Schroeder, Bill Lorensen 
00009 All rights reserved.
00010 
00011 Redistribution and use in source and binary forms, with or without
00012 modification, are permitted provided that the following conditions are met:
00013 
00014  * Redistributions of source code must retain the above copyright notice,
00015    this list of conditions and the following disclaimer.
00016 
00017  * Redistributions in binary form must reproduce the above copyright notice,
00018    this list of conditions and the following disclaimer in the documentation
00019    and/or other materials provided with the distribution.
00020 
00021  * Neither name of Ken Martin, Will Schroeder, or Bill Lorensen nor the names
00022    of any contributors may be used to endorse or promote products derived
00023    from this software without specific prior written permission.
00024 
00025  * Modified source versions must be plainly marked as such, and must not be
00026    misrepresented as being the original software.
00027 
00028 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
00029 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00030 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00031 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
00032 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00033 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00034 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00035 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00036 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00037 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00038 
00039 =========================================================================*/
00040 
00075 #ifndef __vtkTransform_h
00076 #define __vtkTransform_h
00077 
00078 #include "vtkLinearTransform.h"
00079 #include "vtkMatrix4x4.h"
00080 
00081 class VTK_EXPORT vtkTransform : public vtkLinearTransform
00082 {
00083  public:
00084   static vtkTransform *New();
00085   vtkTypeMacro(vtkTransform,vtkLinearTransform);
00086   void PrintSelf(ostream& os, vtkIndent indent);
00087 
00091   void Identity();
00092 
00096   void Inverse();
00097 
00100   void Translate(double x, double y, double z) {
00101     this->Concatenation->Translate(x,y,z); };
00102   void Translate(const double x[3]) { this->Translate(x[0], x[1], x[2]); };
00103   void Translate(const float x[3]) { this->Translate(x[0], x[1], x[2]); };
00104 
00109   void RotateWXYZ(double angle, double x, double y, double z) {
00110     this->Concatenation->Rotate(angle,x,y,z); };
00111   void RotateWXYZ(double angle, const double axis[3]) {
00112     this->RotateWXYZ(angle, axis[0], axis[1], axis[2]); };
00113   void RotateWXYZ(double angle, const float axis[3]) {
00114     this->RotateWXYZ(angle, axis[0], axis[1], axis[2]); };
00115 
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); };
00122 
00126   void Scale(double x, double y, double z) {
00127     this->Concatenation->Scale(x,y,z); };
00128   void Scale(const double s[3]) { this->Scale(s[0], s[1], s[2]); };
00129   void Scale(const float s[3]) { this->Scale(s[0], s[1], s[2]); };
00130 
00133   void SetMatrix(vtkMatrix4x4 *matrix) { 
00134     this->SetMatrix(*matrix->Element); };
00135   void SetMatrix(const double elements[16]) { 
00136     this->Identity(); this->Concatenate(elements); };
00137 
00140   void Concatenate(vtkMatrix4x4 *matrix) { 
00141     this->Concatenate(*matrix->Element); };
00142   void Concatenate(const double elements[16]) {
00143     this->Concatenation->Concatenate(elements); };
00144 
00150   void Concatenate(vtkLinearTransform *transform);
00151 
00157   void PreMultiply() { 
00158     if (this->Concatenation->GetPreMultiplyFlag()) { return; }
00159     this->Concatenation->SetPreMultiplyFlag(1); this->Modified(); };
00160 
00166   void PostMultiply()  { 
00167     if (!this->Concatenation->GetPreMultiplyFlag()) { return; }
00168     this->Concatenation->SetPreMultiplyFlag(0); this->Modified(); };
00169 
00172   void GetOrientation(double orient[3]);
00173   void GetOrientation(float orient[3]) {
00174     double temp[3]; this->GetOrientation(temp); 
00175     orient[0] = temp[0]; orient[1] = temp[1]; orient[2] = temp[2]; };
00176   float *GetOrientation() { 
00177     this->GetOrientation(this->ReturnValue); return this->ReturnValue; };
00178 
00180   void GetOrientationWXYZ(double wxyz[4]);
00181   void GetOrientationWXYZ(float wxyz[3]) {
00182     double temp[4]; this->GetOrientationWXYZ(temp); 
00183     wxyz[0]=temp[0]; wxyz[1]=temp[1]; wxyz[2]=temp[2]; wxyz[3]=temp[3];};
00184   float *GetOrientationWXYZ() { 
00185     this->GetOrientationWXYZ(this->ReturnValue); return this->ReturnValue; };
00186 
00190   void GetPosition(double pos[3]);
00191   void GetPosition(float pos[3]) {
00192     double temp[3]; this->GetPosition(temp); 
00193     pos[0] = temp[0]; pos[1] = temp[1]; pos[2] = temp[2]; };
00194   float *GetPosition() { 
00195     this->GetPosition(this->ReturnValue); return this->ReturnValue; };
00196 
00201   void GetScale(double scale[3]);
00202   void GetScale(float scale[3]) {
00203     double temp[3]; this->GetScale(temp); 
00204     scale[0] = temp[0]; scale[1] = temp[1]; scale[2] = temp[2]; };
00205   float *GetScale() { 
00206     this->GetScale(this->ReturnValue); return this->ReturnValue; };
00207 
00210   void GetInverse(vtkMatrix4x4 *inverse);
00211 
00215   void GetTranspose(vtkMatrix4x4 *transpose);
00216 
00218   void Push() { if (this->Stack == NULL) { 
00219                     this->Stack = vtkTransformConcatenationStack::New(); }
00220                 this->Stack->Push(&this->Concatenation); 
00221                 this->Modified(); };
00222 
00225   void Pop() { if (this->Stack == NULL) { return; }
00226                this->Stack->Pop(&this->Concatenation);
00227                this->Modified(); };
00228 
00233   void SetInput(vtkLinearTransform *input);
00234   vtkLinearTransform *GetInput() { return this->Input; };
00235 
00242   int CircuitCheck(vtkAbstractTransform *transform);
00243 
00244   // Return an inverse transform which will always update itself
00245   // to match this transform.
00246   vtkAbstractTransform *GetInverse() { 
00247     return vtkLinearTransform::GetInverse(); }
00248 
00250   vtkAbstractTransform *MakeTransform();
00251 
00253   unsigned long GetMTime();
00254 
00258   void MultiplyPoint(const float in[4], float out[4]) {
00259     this->GetMatrix()->MultiplyPoint(in,out);};
00260   void MultiplyPoint(const double in[4], double out[4]) {      
00261     this->GetMatrix()->MultiplyPoint(in,out);};
00262 
00263 #ifndef VTK_REMOVE_LEGACY_CODE
00264 
00266   void MultiplyPoints(vtkPoints *inPts, vtkPoints *outPts) 
00267     {VTK_LEGACY_METHOD(TransformPoints,"3.2"); this->TransformPoints(inPts,outPts);}
00268   void MultiplyVectors(vtkVectors *inVectors, vtkVectors *outVectors) 
00269     {VTK_LEGACY_METHOD(TransformVectors,"3.2"); this->TransformVectors(inVectors,outVectors);}
00270   void MultiplyNormals(vtkNormals *inNormals, vtkNormals *outNormals) 
00271     {VTK_LEGACY_METHOD(TransformNormals,"3.2"); this->TransformNormals(inNormals,outNormals);}
00272 #endif
00273   
00279   void Transpose() 
00280     {VTK_LEGACY_METHOD(Transpose,"3.2"); 
00281     double matrix[16];
00282     vtkMatrix4x4::DeepCopy(matrix,this->GetMatrix());
00283     vtkMatrix4x4::Transpose(matrix,matrix);
00284     this->Identity();
00285     this->SetInput(NULL);
00286     this->Concatenate(matrix); }    
00287 
00295   vtkSetVector4Macro(Point,float);
00296   vtkSetVector4Macro(DoublePoint,double);
00297   float *GetPoint();
00298   double *GetDoublePoint();
00299   void GetPoint(float p[4]);
00300 
00302   void Multiply4x4(vtkMatrix4x4 *a, vtkMatrix4x4 *b, vtkMatrix4x4 *c) 
00303     {VTK_LEGACY_METHOD(Multiply4x4,"3.2"); vtkMatrix4x4::Multiply4x4(a,b,c);}
00304   void Multiply4x4(const double a[16], const double b[16], double c[16]) 
00305     {VTK_LEGACY_METHOD(Multiply4x4,"3.2"); vtkMatrix4x4::Multiply4x4(a,b,c);} 
00306   void Multiply4x4(vtkMatrix4x4 &a, vtkMatrix4x4 &b, vtkMatrix4x4 &c) 
00307     {VTK_LEGACY_METHOD(Multiply4x4,"3.2"); vtkMatrix4x4::Multiply4x4(&a,&b,&c); } 
00308   void Concatenate(vtkMatrix4x4 &matrix)
00309     {VTK_LEGACY_METHOD(Concatenate,"3.2"); this->Concatenate(&matrix);}
00310   void SetMatrix(vtkMatrix4x4 &m)
00311     {VTK_LEGACY_METHOD(SetMatrix,"3.2"); this->SetMatrix(&m);}
00312   void GetTranspose (vtkMatrix4x4 &transpose)
00313     {VTK_LEGACY_METHOD(GetTranspose,"3.2"); this->GetTranspose(&transpose);}
00314   void GetInverse(vtkMatrix4x4& inverse)
00315     {VTK_LEGACY_METHOD(GetInverse,"3.2"); this->GetInverse(&inverse);};
00316 //BTX
00317   void GetOrientation(float *prx, float *pry, float *prz) 
00318     {VTK_LEGACY_METHOD(GetOrientation,"3.2"); 
00319     double temp[3]; this->GetOrientation(temp); 
00320     *prx = temp[0]; *pry = temp[1]; *prz = temp[2]; };    
00321   void GetOrientation(float& rx, float& ry, float& rz)
00322     {VTK_LEGACY_METHOD(GetOrientation,"3.2"); this->GetOrientation(&rx,&ry,&rz);}
00323   void GetPosition(float *px, float *py, float *pz) 
00324     {VTK_LEGACY_METHOD(GetPosition,"3.2"); 
00325     double temp[3]; this->GetPosition(temp); 
00326     *px = temp[0]; *py = temp[1]; *pz = temp[2]; };
00327   void GetPosition(float& x, float& y, float& z)
00328     {VTK_LEGACY_METHOD(GetPosition,"3.2"); this->GetPosition(&x, &y, &z);}
00329   void GetScale(float *psx, float *psy, float *psz) 
00330     {VTK_LEGACY_METHOD(GetScale,"3.2"); 
00331     double temp[3]; this->GetScale(temp); 
00332     *psx = temp[0]; *psy = temp[1]; *psz = temp[2]; };
00333   void GetScale(float& x, float& y, float& z)
00334     {VTK_LEGACY_METHOD(GetScale,"3.2"); this->GetScale(&x, &y, &z);}
00335 //ETX
00336 
00337 protected:
00338   vtkTransform ();
00339   ~vtkTransform ();
00340   vtkTransform (const vtkTransform& t);
00341   void operator=(const vtkTransform&) {};
00342 
00343   void InternalDeepCopy(vtkAbstractTransform *t);
00344 
00345   void InternalUpdate();
00346 
00347   vtkLinearTransform *Input;
00348   vtkTransformConcatenation *Concatenation;
00349   vtkTransformConcatenationStack *Stack;
00350 
00351 //BTX
00352   // this allows us to check whether people have been fooling
00353   // around with our matrix
00354 //ETX
00355   unsigned long MatrixUpdateMTime;
00356 
00357 //BTX
00358   // legacy 
00359 //ETX
00360   float Point[4];
00361   double DoublePoint[4];
00362   float ReturnValue[4];
00363 };
00364 
00365 #endif

Generated on Wed Nov 21 12:26:54 2001 for VTK by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001