Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Common/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 
00061 #ifndef __vtkPerspectiveTransform_h
00062 #define __vtkPerspectiveTransform_h
00063 
00064 #include "vtkHomogeneousTransform.h"
00065 
00066 #include "vtkMatrix4x4.h" // Needed for inline methods
00067 
00068 class VTK_COMMON_EXPORT vtkPerspectiveTransform : public vtkHomogeneousTransform
00069 {
00070  public:
00071   static vtkPerspectiveTransform *New();
00072   vtkTypeRevisionMacro(vtkPerspectiveTransform,vtkHomogeneousTransform);
00073   void PrintSelf(ostream& os, vtkIndent indent);
00074 
00078   void Identity() { this->Concatenation->Identity(); this->Modified(); };
00079 
00083   void Inverse() { this->Concatenation->Inverse(); this->Modified(); };
00084 
00086 
00092   void AdjustViewport(double oldXMin, double oldXMax, 
00093                       double oldYMin, double oldYMax,
00094                       double newXMin, double newXMax, 
00095                       double newYMin, double newYMax);
00097 
00099 
00104   void AdjustZBuffer(double oldNearZ, double oldFarZ,
00105                      double newNearZ, double newFarZ);
00107 
00109 
00112   void Ortho(double xmin, double xmax, double ymin, double ymax, 
00113              double znear, double zfar);
00115 
00117 
00121   void Frustum(double xmin, double xmax, double ymin, double ymax, 
00122                double znear, double zfar);
00124 
00129   void Perspective(double angle, double aspect, double znear, double zfar);
00130 
00141   void Shear(double dxdz, double dydz, double zplane);
00142 
00150   void Stereo(double angle, double focaldistance);
00151 
00153 
00156   void SetupCamera(const double position[3], const double focalpoint[3],
00157                    const double viewup[3]);
00159 
00160   void SetupCamera(double p0, double p1, double p2,
00161                    double fp0, double fp1, double fp2,
00162                    double vup0, double vup1, double vup2);
00163 
00165 
00167   void Translate(double x, double y, double z) {
00168     this->Concatenation->Translate(x,y,z); };
00169   void Translate(const double x[3]) { this->Translate(x[0], x[1], x[2]); };
00170   void Translate(const float x[3]) { this->Translate(x[0], x[1], x[2]); };
00172 
00174 
00178   void RotateWXYZ(double angle, double x, double y, double z) {
00179     this->Concatenation->Rotate(angle,x,y,z); };
00180   void RotateWXYZ(double angle, const double axis[3]) {
00181     this->RotateWXYZ(angle, axis[0], axis[1], axis[2]); };
00182   void RotateWXYZ(double angle, const float axis[3]) {
00183     this->RotateWXYZ(angle, axis[0], axis[1], axis[2]); };
00185 
00187 
00190   void RotateX(double angle) { this->RotateWXYZ(angle, 1, 0, 0); };
00191   void RotateY(double angle) { this->RotateWXYZ(angle, 0, 1, 0); };
00192   void RotateZ(double angle) { this->RotateWXYZ(angle, 0, 0, 1); };
00194 
00196 
00199   void Scale(double x, double y, double z) {
00200     this->Concatenation->Scale(x,y,z); };
00201   void Scale(const double s[3]) { this->Scale(s[0], s[1], s[2]); };
00202   void Scale(const float s[3]) { this->Scale(s[0], s[1], s[2]); };
00204 
00206 
00208   void SetMatrix(vtkMatrix4x4 *matrix) { 
00209     this->SetMatrix(*matrix->Element); };
00210   void SetMatrix(const double elements[16]) { 
00211     this->Identity(); this->Concatenate(elements); };
00213 
00215 
00217   void Concatenate(vtkMatrix4x4 *matrix) { 
00218     this->Concatenate(*matrix->Element); };
00219   void Concatenate(const double elements[16]) {
00220     this->Concatenation->Concatenate(elements); };
00222 
00228   void Concatenate(vtkHomogeneousTransform *transform);
00229 
00231 
00236   void PreMultiply() { 
00237     if (this->Concatenation->GetPreMultiplyFlag()) { return; }
00238     this->Concatenation->SetPreMultiplyFlag(1); this->Modified(); };
00240 
00242 
00247   void PostMultiply()  { 
00248     if (!this->Concatenation->GetPreMultiplyFlag()) { return; }
00249     this->Concatenation->SetPreMultiplyFlag(0); this->Modified(); };
00251 
00253 
00255   int GetNumberOfConcatenatedTransforms() {
00256     return this->Concatenation->GetNumberOfTransforms() + 
00257       (this->Input == NULL ? 0 : 1); };
00259 
00261 
00266   vtkHomogeneousTransform *GetConcatenatedTransform(int i) {
00267     if (this->Input == NULL) {
00268       return (vtkHomogeneousTransform *)this->Concatenation->GetTransform(i); }
00269     else if (i < this->Concatenation->GetNumberOfPreTransforms()) {
00270       return (vtkHomogeneousTransform *)this->Concatenation->GetTransform(i); }
00271     else if (i > this->Concatenation->GetNumberOfPreTransforms()) {
00272       return (vtkHomogeneousTransform*)this->Concatenation->GetTransform(i-1);}
00273     else if (this->GetInverseFlag()) {
00274       return (vtkHomogeneousTransform *)this->Input->GetInverse(); }
00275     else {
00276       return (vtkHomogeneousTransform *)this->Input; } };
00278 
00280 
00286   void SetInput(vtkHomogeneousTransform *input);
00287   vtkHomogeneousTransform *GetInput() { return this->Input; };
00289 
00291 
00295   int GetInverseFlag() {
00296     return this->Concatenation->GetInverseFlag(); };
00298 
00300 
00301   void Push() { if (this->Stack == NULL) { 
00302                     this->Stack = vtkTransformConcatenationStack::New(); }
00303                 this->Stack->Push(&this->Concatenation); 
00304                 this->Modified(); };
00306 
00308 
00310   void Pop() { if (this->Stack == NULL) { return; }
00311                this->Stack->Pop(&this->Concatenation);
00312                this->Modified(); };
00314 
00317   vtkAbstractTransform *MakeTransform();
00318 
00325   int CircuitCheck(vtkAbstractTransform *transform);
00326 
00328   unsigned long GetMTime();
00329 
00330 protected:
00331   vtkPerspectiveTransform();
00332   ~vtkPerspectiveTransform();
00333 
00334   void InternalDeepCopy(vtkAbstractTransform *t);
00335   void InternalUpdate();
00336 
00337   vtkHomogeneousTransform *Input;
00338   vtkTransformConcatenation *Concatenation;
00339   vtkTransformConcatenationStack *Stack;
00340 
00341 private:
00342   vtkPerspectiveTransform(const vtkPerspectiveTransform&);  // Not implemented
00343   void operator=(const vtkPerspectiveTransform&);  // Not implemented
00344 };
00345 
00346 
00347 #endif