Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | 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   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 
00051 #ifndef __vtkPerspectiveTransform_h
00052 #define __vtkPerspectiveTransform_h
00053 
00054 #include "vtkHomogeneousTransform.h"
00055 
00056 #include "vtkMatrix4x4.h" // Needed for inline methods
00057 
00058 class VTK_COMMON_EXPORT vtkPerspectiveTransform : public vtkHomogeneousTransform
00059 {
00060  public:
00061   static vtkPerspectiveTransform *New();
00062   vtkTypeRevisionMacro(vtkPerspectiveTransform,vtkHomogeneousTransform);
00063   void PrintSelf(ostream& os, vtkIndent indent);
00064 
00068   void Identity() { this->Concatenation->Identity(); this->Modified(); };
00069 
00073   void Inverse() { this->Concatenation->Inverse(); this->Modified(); };
00074 
00076 
00082   void AdjustViewport(double oldXMin, double oldXMax, 
00083                       double oldYMin, double oldYMax,
00084                       double newXMin, double newXMax, 
00085                       double newYMin, double newYMax);
00087 
00089 
00094   void AdjustZBuffer(double oldNearZ, double oldFarZ,
00095                      double newNearZ, double newFarZ);
00097 
00099 
00102   void Ortho(double xmin, double xmax, double ymin, double ymax, 
00103              double znear, double zfar);
00105 
00107 
00111   void Frustum(double xmin, double xmax, double ymin, double ymax, 
00112                double znear, double zfar);
00114 
00119   void Perspective(double angle, double aspect, double znear, double zfar);
00120 
00131   void Shear(double dxdz, double dydz, double zplane);
00132 
00140   void Stereo(double angle, double focaldistance);
00141 
00143 
00146   void SetupCamera(const double position[3], const double focalpoint[3],
00147                    const double viewup[3]);
00149 
00150   void SetupCamera(double p0, double p1, double p2,
00151                    double fp0, double fp1, double fp2,
00152                    double vup0, double vup1, double vup2);
00153 
00155 
00157   void Translate(double x, double y, double z) {
00158     this->Concatenation->Translate(x,y,z); };
00159   void Translate(const double x[3]) { this->Translate(x[0], x[1], x[2]); };
00160   void Translate(const float x[3]) { this->Translate(x[0], x[1], x[2]); };
00162 
00164 
00168   void RotateWXYZ(double angle, double x, double y, double z) {
00169     this->Concatenation->Rotate(angle,x,y,z); };
00170   void RotateWXYZ(double angle, const double axis[3]) {
00171     this->RotateWXYZ(angle, axis[0], axis[1], axis[2]); };
00172   void RotateWXYZ(double angle, const float axis[3]) {
00173     this->RotateWXYZ(angle, axis[0], axis[1], axis[2]); };
00175 
00177 
00180   void RotateX(double angle) { this->RotateWXYZ(angle, 1, 0, 0); };
00181   void RotateY(double angle) { this->RotateWXYZ(angle, 0, 1, 0); };
00182   void RotateZ(double angle) { this->RotateWXYZ(angle, 0, 0, 1); };
00184 
00186 
00189   void Scale(double x, double y, double z) {
00190     this->Concatenation->Scale(x,y,z); };
00191   void Scale(const double s[3]) { this->Scale(s[0], s[1], s[2]); };
00192   void Scale(const float s[3]) { this->Scale(s[0], s[1], s[2]); };
00194 
00196 
00198   void SetMatrix(vtkMatrix4x4 *matrix) { 
00199     this->SetMatrix(*matrix->Element); };
00200   void SetMatrix(const double elements[16]) { 
00201     this->Identity(); this->Concatenate(elements); };
00203 
00205 
00207   void Concatenate(vtkMatrix4x4 *matrix) { 
00208     this->Concatenate(*matrix->Element); };
00209   void Concatenate(const double elements[16]) {
00210     this->Concatenation->Concatenate(elements); };
00212 
00218   void Concatenate(vtkHomogeneousTransform *transform);
00219 
00221 
00226   void PreMultiply() { 
00227     if (this->Concatenation->GetPreMultiplyFlag()) { return; }
00228     this->Concatenation->SetPreMultiplyFlag(1); this->Modified(); };
00230 
00232 
00237   void PostMultiply()  { 
00238     if (!this->Concatenation->GetPreMultiplyFlag()) { return; }
00239     this->Concatenation->SetPreMultiplyFlag(0); this->Modified(); };
00241 
00243 
00245   int GetNumberOfConcatenatedTransforms() {
00246     return this->Concatenation->GetNumberOfTransforms() + 
00247       (this->Input == NULL ? 0 : 1); };
00249 
00251 
00256   vtkHomogeneousTransform *GetConcatenatedTransform(int i) {
00257     if (this->Input == NULL) {
00258       return (vtkHomogeneousTransform *)this->Concatenation->GetTransform(i); }
00259     else if (i < this->Concatenation->GetNumberOfPreTransforms()) {
00260       return (vtkHomogeneousTransform *)this->Concatenation->GetTransform(i); }
00261     else if (i > this->Concatenation->GetNumberOfPreTransforms()) {
00262       return (vtkHomogeneousTransform*)this->Concatenation->GetTransform(i-1);}
00263     else if (this->GetInverseFlag()) {
00264       return (vtkHomogeneousTransform *)this->Input->GetInverse(); }
00265     else {
00266       return (vtkHomogeneousTransform *)this->Input; } };
00268 
00270 
00276   void SetInput(vtkHomogeneousTransform *input);
00277   vtkHomogeneousTransform *GetInput() { return this->Input; };
00279 
00281 
00285   int GetInverseFlag() {
00286     return this->Concatenation->GetInverseFlag(); };
00288 
00290 
00291   void Push() { if (this->Stack == NULL) { 
00292                     this->Stack = vtkTransformConcatenationStack::New(); }
00293                 this->Stack->Push(&this->Concatenation); 
00294                 this->Modified(); };
00296 
00298 
00300   void Pop() { if (this->Stack == NULL) { return; }
00301                this->Stack->Pop(&this->Concatenation);
00302                this->Modified(); };
00304 
00307   vtkAbstractTransform *MakeTransform();
00308 
00315   int CircuitCheck(vtkAbstractTransform *transform);
00316 
00318   unsigned long GetMTime();
00319 
00320 protected:
00321   vtkPerspectiveTransform();
00322   ~vtkPerspectiveTransform();
00323 
00324   void InternalDeepCopy(vtkAbstractTransform *t);
00325   void InternalUpdate();
00326 
00327   vtkHomogeneousTransform *Input;
00328   vtkTransformConcatenation *Concatenation;
00329   vtkTransformConcatenationStack *Stack;
00330 
00331 private:
00332   vtkPerspectiveTransform(const vtkPerspectiveTransform&);  // Not implemented
00333   void operator=(const vtkPerspectiveTransform&);  // Not implemented
00334 };
00335 
00336 
00337 #endif