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

vtkPerspectiveTransform.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkPerspectiveTransform.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 
00057 #ifndef __vtkPerspectiveTransform_h
00058 #define __vtkPerspectiveTransform_h
00059 
00060 #include "vtkHomogeneousTransform.h"
00061 
00062 #include "vtkMatrix4x4.h" // Needed for inline methods
00063 
00064 class VTK_COMMON_EXPORT vtkPerspectiveTransform : public vtkHomogeneousTransform
00065 {
00066  public:
00067   static vtkPerspectiveTransform *New();
00068   vtkTypeRevisionMacro(vtkPerspectiveTransform,vtkHomogeneousTransform);
00069   void PrintSelf(ostream& os, vtkIndent indent);
00070 
00074   void Identity() { this->Concatenation->Identity(); this->Modified(); };
00075 
00079   void Inverse() { this->Concatenation->Inverse(); this->Modified(); };
00080 
00082 
00088   void AdjustViewport(double oldXMin, double oldXMax, 
00089                       double oldYMin, double oldYMax,
00090                       double newXMin, double newXMax, 
00091                       double newYMin, double newYMax);
00093 
00095 
00100   void AdjustZBuffer(double oldNearZ, double oldFarZ,
00101                      double newNearZ, double newFarZ);
00103 
00105 
00108   void Ortho(double xmin, double xmax, double ymin, double ymax, 
00109              double znear, double zfar);
00111 
00113 
00117   void Frustum(double xmin, double xmax, double ymin, double ymax, 
00118                double znear, double zfar);
00120 
00125   void Perspective(double angle, double aspect, double znear, double zfar);
00126 
00137   void Shear(double dxdz, double dydz, double zplane);
00138 
00146   void Stereo(double angle, double focaldistance);
00147 
00149 
00152   void SetupCamera(const double position[3], const double focalpoint[3],
00153                    const double viewup[3]);
00155 
00156   void SetupCamera(double p0, double p1, double p2,
00157                    double fp0, double fp1, double fp2,
00158                    double vup0, double vup1, double vup2);
00159 
00161 
00163   void Translate(double x, double y, double z) {
00164     this->Concatenation->Translate(x,y,z); };
00165   void Translate(const double x[3]) { this->Translate(x[0], x[1], x[2]); };
00166   void Translate(const float x[3]) { this->Translate(x[0], x[1], x[2]); };
00168 
00170 
00174   void RotateWXYZ(double angle, double x, double y, double z) {
00175     this->Concatenation->Rotate(angle,x,y,z); };
00176   void RotateWXYZ(double angle, const double axis[3]) {
00177     this->RotateWXYZ(angle, axis[0], axis[1], axis[2]); };
00178   void RotateWXYZ(double angle, const float axis[3]) {
00179     this->RotateWXYZ(angle, axis[0], axis[1], axis[2]); };
00181 
00183 
00186   void RotateX(double angle) { this->RotateWXYZ(angle, 1, 0, 0); };
00187   void RotateY(double angle) { this->RotateWXYZ(angle, 0, 1, 0); };
00188   void RotateZ(double angle) { this->RotateWXYZ(angle, 0, 0, 1); };
00190 
00192 
00195   void Scale(double x, double y, double z) {
00196     this->Concatenation->Scale(x,y,z); };
00197   void Scale(const double s[3]) { this->Scale(s[0], s[1], s[2]); };
00198   void Scale(const float s[3]) { this->Scale(s[0], s[1], s[2]); };
00200 
00202 
00204   void SetMatrix(vtkMatrix4x4 *matrix) { 
00205     this->SetMatrix(*matrix->Element); };
00206   void SetMatrix(const double elements[16]) { 
00207     this->Identity(); this->Concatenate(elements); };
00209 
00211 
00213   void Concatenate(vtkMatrix4x4 *matrix) { 
00214     this->Concatenate(*matrix->Element); };
00215   void Concatenate(const double elements[16]) {
00216     this->Concatenation->Concatenate(elements); };
00218 
00224   void Concatenate(vtkHomogeneousTransform *transform);
00225 
00227 
00232   void PreMultiply() { 
00233     if (this->Concatenation->GetPreMultiplyFlag()) { return; }
00234     this->Concatenation->SetPreMultiplyFlag(1); this->Modified(); };
00236 
00238 
00243   void PostMultiply()  { 
00244     if (!this->Concatenation->GetPreMultiplyFlag()) { return; }
00245     this->Concatenation->SetPreMultiplyFlag(0); this->Modified(); };
00247 
00249 
00251   int GetNumberOfConcatenatedTransforms() {
00252     return this->Concatenation->GetNumberOfTransforms() + 
00253       (this->Input == NULL ? 0 : 1); };
00255 
00257 
00262   vtkHomogeneousTransform *GetConcatenatedTransform(int i) {
00263     if (this->Input == NULL) {
00264       return (vtkHomogeneousTransform *)this->Concatenation->GetTransform(i); }
00265     else if (i < this->Concatenation->GetNumberOfPreTransforms()) {
00266       return (vtkHomogeneousTransform *)this->Concatenation->GetTransform(i); }
00267     else if (i > this->Concatenation->GetNumberOfPreTransforms()) {
00268       return (vtkHomogeneousTransform*)this->Concatenation->GetTransform(i-1);}
00269     else if (this->GetInverseFlag()) {
00270       return (vtkHomogeneousTransform *)this->Input->GetInverse(); }
00271     else {
00272       return (vtkHomogeneousTransform *)this->Input; } };
00274 
00276 
00282   void SetInput(vtkHomogeneousTransform *input);
00283   vtkHomogeneousTransform *GetInput() { return this->Input; };
00285 
00287 
00291   int GetInverseFlag() {
00292     return this->Concatenation->GetInverseFlag(); };
00294 
00296 
00297   void Push() { if (this->Stack == NULL) { 
00298                     this->Stack = vtkTransformConcatenationStack::New(); }
00299                 this->Stack->Push(&this->Concatenation); 
00300                 this->Modified(); };
00302 
00304 
00306   void Pop() { if (this->Stack == NULL) { return; }
00307                this->Stack->Pop(&this->Concatenation);
00308                this->Modified(); };
00310 
00313   vtkAbstractTransform *MakeTransform();
00314 
00321   int CircuitCheck(vtkAbstractTransform *transform);
00322 
00324   unsigned long GetMTime();
00325 
00326 protected:
00327   vtkPerspectiveTransform();
00328   ~vtkPerspectiveTransform();
00329 
00330   void InternalDeepCopy(vtkAbstractTransform *t);
00331   void InternalUpdate();
00332 
00333   vtkHomogeneousTransform *Input;
00334   vtkTransformConcatenation *Concatenation;
00335   vtkTransformConcatenationStack *Stack;
00336 
00337 private:
00338   vtkPerspectiveTransform(const vtkPerspectiveTransform&);  // Not implemented
00339   void operator=(const vtkPerspectiveTransform&);  // Not implemented
00340 };
00341 
00342 
00343 #endif