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 vtkTypeMacro(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 {
00254 vtkAbstractTransform *t;
00255 if (this->Input == NULL)
00256 {
00257 t=this->Concatenation->GetTransform(i);
00258 }
00259 else if (i < this->Concatenation->GetNumberOfPreTransforms())
00260 {
00261 t=this->Concatenation->GetTransform(i);
00262 }
00263 else if (i > this->Concatenation->GetNumberOfPreTransforms())
00264 {
00265 t=this->Concatenation->GetTransform(i-1);
00266 }
00267 else if (this->GetInverseFlag())
00268 {
00269 t=this->Input->GetInverse();
00270 }
00271 else
00272 {
00273 t=this->Input;
00274 }
00275 return static_cast<vtkHomogeneousTransform *>(t);
00276 }
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&);
00343 void operator=(const vtkPerspectiveTransform&);
00344 };
00345
00346
00347 #endif