00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00047 #ifndef __vtkPerspectiveTransform_h
00048 #define __vtkPerspectiveTransform_h
00049
00050 #include "vtkHomogeneousTransform.h"
00051
00052 #include "vtkMatrix4x4.h"
00053
00054 class VTK_COMMON_EXPORT vtkPerspectiveTransform : public vtkHomogeneousTransform
00055 {
00056 public:
00057 static vtkPerspectiveTransform *New();
00058 vtkTypeRevisionMacro(vtkPerspectiveTransform,vtkHomogeneousTransform);
00059 void PrintSelf(ostream& os, vtkIndent indent);
00060
00064 void Identity() { this->Concatenation->Identity(); this->Modified(); };
00065
00069 void Inverse() { this->Concatenation->Inverse(); this->Modified(); };
00070
00072
00078 void AdjustViewport(double oldXMin, double oldXMax,
00079 double oldYMin, double oldYMax,
00080 double newXMin, double newXMax,
00081 double newYMin, double newYMax);
00083
00085
00090 void AdjustZBuffer(double oldNearZ, double oldFarZ,
00091 double newNearZ, double newFarZ);
00093
00095
00098 void Ortho(double xmin, double xmax, double ymin, double ymax,
00099 double znear, double zfar);
00101
00103
00107 void Frustum(double xmin, double xmax, double ymin, double ymax,
00108 double znear, double zfar);
00110
00115 void Perspective(double angle, double aspect, double znear, double zfar);
00116
00127 void Shear(double dxdz, double dydz, double zplane);
00128
00136 void Stereo(double angle, double focaldistance);
00137
00139
00142 void SetupCamera(const double position[3], const double focalpoint[3],
00143 const double viewup[3]);
00145
00146 void SetupCamera(double p0, double p1, double p2,
00147 double fp0, double fp1, double fp2,
00148 double vup0, double vup1, double vup2);
00149
00151
00153 void Translate(double x, double y, double z) {
00154 this->Concatenation->Translate(x,y,z); };
00155 void Translate(const double x[3]) { this->Translate(x[0], x[1], x[2]); };
00156 void Translate(const float x[3]) { this->Translate(x[0], x[1], x[2]); };
00158
00160
00164 void RotateWXYZ(double angle, double x, double y, double z) {
00165 this->Concatenation->Rotate(angle,x,y,z); };
00166 void RotateWXYZ(double angle, const double axis[3]) {
00167 this->RotateWXYZ(angle, axis[0], axis[1], axis[2]); };
00168 void RotateWXYZ(double angle, const float axis[3]) {
00169 this->RotateWXYZ(angle, axis[0], axis[1], axis[2]); };
00171
00173
00176 void RotateX(double angle) { this->RotateWXYZ(angle, 1, 0, 0); };
00177 void RotateY(double angle) { this->RotateWXYZ(angle, 0, 1, 0); };
00178 void RotateZ(double angle) { this->RotateWXYZ(angle, 0, 0, 1); };
00180
00182
00185 void Scale(double x, double y, double z) {
00186 this->Concatenation->Scale(x,y,z); };
00187 void Scale(const double s[3]) { this->Scale(s[0], s[1], s[2]); };
00188 void Scale(const float s[3]) { this->Scale(s[0], s[1], s[2]); };
00190
00192
00194 void SetMatrix(vtkMatrix4x4 *matrix) {
00195 this->SetMatrix(*matrix->Element); };
00196 void SetMatrix(const double elements[16]) {
00197 this->Identity(); this->Concatenate(elements); };
00199
00201
00203 void Concatenate(vtkMatrix4x4 *matrix) {
00204 this->Concatenate(*matrix->Element); };
00205 void Concatenate(const double elements[16]) {
00206 this->Concatenation->Concatenate(elements); };
00208
00214 void Concatenate(vtkHomogeneousTransform *transform);
00215
00217
00222 void PreMultiply() {
00223 if (this->Concatenation->GetPreMultiplyFlag()) { return; }
00224 this->Concatenation->SetPreMultiplyFlag(1); this->Modified(); };
00226
00228
00233 void PostMultiply() {
00234 if (!this->Concatenation->GetPreMultiplyFlag()) { return; }
00235 this->Concatenation->SetPreMultiplyFlag(0); this->Modified(); };
00237
00239
00241 int GetNumberOfConcatenatedTransforms() {
00242 return this->Concatenation->GetNumberOfTransforms() +
00243 (this->Input == NULL ? 0 : 1); };
00245
00247
00252 vtkHomogeneousTransform *GetConcatenatedTransform(int i) {
00253 if (this->Input == NULL) {
00254 return (vtkHomogeneousTransform *)this->Concatenation->GetTransform(i); }
00255 else if (i < this->Concatenation->GetNumberOfPreTransforms()) {
00256 return (vtkHomogeneousTransform *)this->Concatenation->GetTransform(i); }
00257 else if (i > this->Concatenation->GetNumberOfPreTransforms()) {
00258 return (vtkHomogeneousTransform*)this->Concatenation->GetTransform(i-1);}
00259 else if (this->GetInverseFlag()) {
00260 return (vtkHomogeneousTransform *)this->Input->GetInverse(); }
00261 else {
00262 return (vtkHomogeneousTransform *)this->Input; } };
00264
00266
00272 void SetInput(vtkHomogeneousTransform *input);
00273 vtkHomogeneousTransform *GetInput() { return this->Input; };
00275
00277
00281 int GetInverseFlag() {
00282 return this->Concatenation->GetInverseFlag(); };
00284
00286
00287 void Push() { if (this->Stack == NULL) {
00288 this->Stack = vtkTransformConcatenationStack::New(); }
00289 this->Stack->Push(&this->Concatenation);
00290 this->Modified(); };
00292
00294
00296 void Pop() { if (this->Stack == NULL) { return; }
00297 this->Stack->Pop(&this->Concatenation);
00298 this->Modified(); };
00300
00303 vtkAbstractTransform *MakeTransform();
00304
00311 int CircuitCheck(vtkAbstractTransform *transform);
00312
00314 unsigned long GetMTime();
00315
00316 protected:
00317 vtkPerspectiveTransform();
00318 ~vtkPerspectiveTransform();
00319
00320 void InternalDeepCopy(vtkAbstractTransform *t);
00321 void InternalUpdate();
00322
00323 vtkHomogeneousTransform *Input;
00324 vtkTransformConcatenation *Concatenation;
00325 vtkTransformConcatenationStack *Stack;
00326
00327 private:
00328 vtkPerspectiveTransform(const vtkPerspectiveTransform&);
00329 void operator=(const vtkPerspectiveTransform&);
00330 };
00331
00332
00333 #endif