VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkPerspectiveTransform.h 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 00047 #ifndef __vtkPerspectiveTransform_h 00048 #define __vtkPerspectiveTransform_h 00049 00050 #include "vtkCommonTransformsModule.h" // For export macro 00051 #include "vtkHomogeneousTransform.h" 00052 00053 #include "vtkMatrix4x4.h" // Needed for inline methods 00054 00055 class VTKCOMMONTRANSFORMS_EXPORT vtkPerspectiveTransform : public vtkHomogeneousTransform 00056 { 00057 public: 00058 static vtkPerspectiveTransform *New(); 00059 vtkTypeMacro(vtkPerspectiveTransform,vtkHomogeneousTransform); 00060 void PrintSelf(ostream& os, vtkIndent indent); 00061 00065 void Identity() { this->Concatenation->Identity(); this->Modified(); }; 00066 00070 void Inverse() { this->Concatenation->Inverse(); this->Modified(); }; 00071 00073 00079 void AdjustViewport(double oldXMin, double oldXMax, 00080 double oldYMin, double oldYMax, 00081 double newXMin, double newXMax, 00082 double newYMin, double newYMax); 00084 00086 00091 void AdjustZBuffer(double oldNearZ, double oldFarZ, 00092 double newNearZ, double newFarZ); 00094 00096 00099 void Ortho(double xmin, double xmax, double ymin, double ymax, 00100 double znear, double zfar); 00102 00104 00108 void Frustum(double xmin, double xmax, double ymin, double ymax, 00109 double znear, double zfar); 00111 00116 void Perspective(double angle, double aspect, double znear, double zfar); 00117 00128 void Shear(double dxdz, double dydz, double zplane); 00129 00137 void Stereo(double angle, double focaldistance); 00138 00140 00143 void SetupCamera(const double position[3], const double focalpoint[3], 00144 const double viewup[3]); 00146 00147 void SetupCamera(double p0, double p1, double p2, 00148 double fp0, double fp1, double fp2, 00149 double vup0, double vup1, double vup2); 00150 00152 00154 void Translate(double x, double y, double z) { 00155 this->Concatenation->Translate(x,y,z); }; 00156 void Translate(const double x[3]) { this->Translate(x[0], x[1], x[2]); }; 00157 void Translate(const float x[3]) { this->Translate(x[0], x[1], x[2]); }; 00159 00161 00165 void RotateWXYZ(double angle, double x, double y, double z) { 00166 this->Concatenation->Rotate(angle,x,y,z); }; 00167 void RotateWXYZ(double angle, const double axis[3]) { 00168 this->RotateWXYZ(angle, axis[0], axis[1], axis[2]); }; 00169 void RotateWXYZ(double angle, const float axis[3]) { 00170 this->RotateWXYZ(angle, axis[0], axis[1], axis[2]); }; 00172 00174 00177 void RotateX(double angle) { this->RotateWXYZ(angle, 1, 0, 0); }; 00178 void RotateY(double angle) { this->RotateWXYZ(angle, 0, 1, 0); }; 00179 void RotateZ(double angle) { this->RotateWXYZ(angle, 0, 0, 1); }; 00181 00183 00186 void Scale(double x, double y, double z) { 00187 this->Concatenation->Scale(x,y,z); }; 00188 void Scale(const double s[3]) { this->Scale(s[0], s[1], s[2]); }; 00189 void Scale(const float s[3]) { this->Scale(s[0], s[1], s[2]); }; 00191 00193 00195 void SetMatrix(vtkMatrix4x4 *matrix) { 00196 this->SetMatrix(*matrix->Element); }; 00197 void SetMatrix(const double elements[16]) { 00198 this->Identity(); this->Concatenate(elements); }; 00200 00202 00204 void Concatenate(vtkMatrix4x4 *matrix) { 00205 this->Concatenate(*matrix->Element); }; 00206 void Concatenate(const double elements[16]) { 00207 this->Concatenation->Concatenate(elements); }; 00209 00215 void Concatenate(vtkHomogeneousTransform *transform); 00216 00218 00223 void PreMultiply() { 00224 if (this->Concatenation->GetPreMultiplyFlag()) { return; } 00225 this->Concatenation->SetPreMultiplyFlag(1); this->Modified(); }; 00227 00229 00234 void PostMultiply() { 00235 if (!this->Concatenation->GetPreMultiplyFlag()) { return; } 00236 this->Concatenation->SetPreMultiplyFlag(0); this->Modified(); }; 00238 00240 00242 int GetNumberOfConcatenatedTransforms() { 00243 return this->Concatenation->GetNumberOfTransforms() + 00244 (this->Input == NULL ? 0 : 1); }; 00246 00248 00253 vtkHomogeneousTransform *GetConcatenatedTransform(int i) 00254 { 00255 vtkAbstractTransform *t; 00256 if (this->Input == NULL) 00257 { 00258 t=this->Concatenation->GetTransform(i); 00259 } 00260 else if (i < this->Concatenation->GetNumberOfPreTransforms()) 00261 { 00262 t=this->Concatenation->GetTransform(i); 00263 } 00264 else if (i > this->Concatenation->GetNumberOfPreTransforms()) 00265 { 00266 t=this->Concatenation->GetTransform(i-1); 00267 } 00268 else if (this->GetInverseFlag()) 00269 { 00270 t=this->Input->GetInverse(); 00271 } 00272 else 00273 { 00274 t=this->Input; 00275 } 00276 return static_cast<vtkHomogeneousTransform *>(t); 00277 } 00279 00281 00287 void SetInput(vtkHomogeneousTransform *input); 00288 vtkHomogeneousTransform *GetInput() { return this->Input; }; 00290 00292 00296 int GetInverseFlag() { 00297 return this->Concatenation->GetInverseFlag(); }; 00299 00301 00302 void Push() { if (this->Stack == NULL) { 00303 this->Stack = vtkTransformConcatenationStack::New(); } 00304 this->Stack->Push(&this->Concatenation); 00305 this->Modified(); }; 00307 00309 00311 void Pop() { if (this->Stack == NULL) { return; } 00312 this->Stack->Pop(&this->Concatenation); 00313 this->Modified(); }; 00315 00318 vtkAbstractTransform *MakeTransform(); 00319 00326 int CircuitCheck(vtkAbstractTransform *transform); 00327 00329 unsigned long GetMTime(); 00330 00331 protected: 00332 vtkPerspectiveTransform(); 00333 ~vtkPerspectiveTransform(); 00334 00335 void InternalDeepCopy(vtkAbstractTransform *t); 00336 void InternalUpdate(); 00337 00338 vtkHomogeneousTransform *Input; 00339 vtkTransformConcatenation *Concatenation; 00340 vtkTransformConcatenationStack *Stack; 00341 00342 private: 00343 vtkPerspectiveTransform(const vtkPerspectiveTransform&); // Not implemented 00344 void operator=(const vtkPerspectiveTransform&); // Not implemented 00345 }; 00346 00347 00348 #endif