VTK  9.1.0
vtkPerspectiveTransform.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkPerspectiveTransform.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
15 
64 #ifndef vtkPerspectiveTransform_h
65 #define vtkPerspectiveTransform_h
66 
67 #include "vtkCommonTransformsModule.h" // For export macro
69 
70 #include "vtkMatrix4x4.h" // Needed for inline methods
71 
72 class VTKCOMMONTRANSFORMS_EXPORT vtkPerspectiveTransform : public vtkHomogeneousTransform
73 {
74 public:
77  void PrintSelf(ostream& os, vtkIndent indent) override;
78 
84  void Identity()
85  {
86  this->Concatenation->Identity();
87  this->Modified();
88  }
89 
95  void Inverse() override
96  {
97  this->Concatenation->Inverse();
98  this->Modified();
99  }
100 
109  void AdjustViewport(double oldXMin, double oldXMax, double oldYMin, double oldYMax,
110  double newXMin, double newXMax, double newYMin, double newYMax);
111 
119  void AdjustZBuffer(double oldNearZ, double oldFarZ, double newNearZ, double newFarZ);
120 
126  void Ortho(double xmin, double xmax, double ymin, double ymax, double znear, double zfar);
127 
134  void Frustum(double xmin, double xmax, double ymin, double ymax, double znear, double zfar);
135 
142  void Perspective(double angle, double aspect, double znear, double zfar);
143 
157  void Shear(double dxdz, double dydz, double zplane);
158 
169  void Stereo(double angle, double focaldistance);
170 
176  void SetupCamera(const double position[3], const double focalpoint[3], const double viewup[3]);
177 
178  void SetupCamera(double p0, double p1, double p2, double fp0, double fp1, double fp2, double vup0,
179  double vup1, double vup2);
180 
182 
186  void Translate(double x, double y, double z) { this->Concatenation->Translate(x, y, z); }
187  void Translate(const double x[3]) { this->Translate(x[0], x[1], x[2]); }
188  void Translate(const float x[3]) { this->Translate(x[0], x[1], x[2]); }
190 
192 
198  void RotateWXYZ(double angle, double x, double y, double z)
199  {
200  this->Concatenation->Rotate(angle, x, y, z);
201  }
202  void RotateWXYZ(double angle, const double axis[3])
203  {
204  this->RotateWXYZ(angle, axis[0], axis[1], axis[2]);
205  }
206  void RotateWXYZ(double angle, const float axis[3])
207  {
208  this->RotateWXYZ(angle, axis[0], axis[1], axis[2]);
209  }
211 
213 
218  void RotateX(double angle) { this->RotateWXYZ(angle, 1, 0, 0); }
219  void RotateY(double angle) { this->RotateWXYZ(angle, 0, 1, 0); }
220  void RotateZ(double angle) { this->RotateWXYZ(angle, 0, 0, 1); }
222 
224 
229  void Scale(double x, double y, double z) { this->Concatenation->Scale(x, y, z); }
230  void Scale(const double s[3]) { this->Scale(s[0], s[1], s[2]); }
231  void Scale(const float s[3]) { this->Scale(s[0], s[1], s[2]); }
233 
235 
239  void SetMatrix(vtkMatrix4x4* matrix) { this->SetMatrix(*matrix->Element); }
240  void SetMatrix(const double elements[16])
241  {
242  this->Identity();
243  this->Concatenate(elements);
244  }
246 
248 
252  void Concatenate(vtkMatrix4x4* matrix) { this->Concatenate(*matrix->Element); }
253  void Concatenate(const double elements[16]) { this->Concatenation->Concatenate(elements); }
255 
264 
272  void PreMultiply()
273  {
274  if (this->Concatenation->GetPreMultiplyFlag())
275  {
276  return;
277  }
278  this->Concatenation->SetPreMultiplyFlag(1);
279  this->Modified();
280  }
281 
290  {
291  if (!this->Concatenation->GetPreMultiplyFlag())
292  {
293  return;
294  }
295  this->Concatenation->SetPreMultiplyFlag(0);
296  this->Modified();
297  }
298 
304  {
305  return this->Concatenation->GetNumberOfTransforms() + (this->Input == nullptr ? 0 : 1);
306  }
307 
309 
317  {
319  if (this->Input == nullptr)
320  {
321  t = this->Concatenation->GetTransform(i);
322  }
323  else if (i < this->Concatenation->GetNumberOfPreTransforms())
324  {
325  t = this->Concatenation->GetTransform(i);
326  }
327  else if (i > this->Concatenation->GetNumberOfPreTransforms())
328  {
329  t = this->Concatenation->GetTransform(i - 1);
330  }
331  else if (this->GetInverseFlag())
332  {
333  t = this->Input->GetInverse();
334  }
335  else
336  {
337  t = this->Input;
338  }
339  return static_cast<vtkHomogeneousTransform*>(t);
340  }
342 
344 
353  vtkHomogeneousTransform* GetInput() { return this->Input; }
355 
363  int GetInverseFlag() { return this->Concatenation->GetInverseFlag(); }
364 
366 
369  void Push()
370  {
371  if (this->Stack == nullptr)
372  {
373  this->Stack = vtkTransformConcatenationStack::New();
374  }
375  this->Stack->Push(&this->Concatenation);
376  this->Modified();
377  }
379 
381 
385  void Pop()
386  {
387  if (this->Stack == nullptr)
388  {
389  return;
390  }
391  this->Stack->Pop(&this->Concatenation);
392  this->Modified();
393  }
395 
401 
410  int CircuitCheck(vtkAbstractTransform* transform) override;
411 
415  vtkMTimeType GetMTime() override;
416 
417 protected:
420 
422  void InternalUpdate() override;
423 
427 
428 private:
430  void operator=(const vtkPerspectiveTransform&) = delete;
431 };
432 
433 #endif
vtkPerspectiveTransform::Scale
void Scale(const double s[3])
Create a scale matrix (i.e.
Definition: vtkPerspectiveTransform.h:230
vtkHomogeneousTransform
superclass for homogeneous transformations
Definition: vtkHomogeneousTransform.h:35
vtkPerspectiveTransform::Perspective
void Perspective(double angle, double aspect, double znear, double zfar)
Create a perspective projection matrix by specifying the view angle (this angle is in the y direction...
vtkPerspectiveTransform::SetMatrix
void SetMatrix(vtkMatrix4x4 *matrix)
Set the current matrix directly.
Definition: vtkPerspectiveTransform.h:239
vtkPerspectiveTransform::Translate
void Translate(double x, double y, double z)
Create a translation matrix and concatenate it with the current transformation according to PreMultip...
Definition: vtkPerspectiveTransform.h:186
vtkAbstractTransform
superclass for all geometric transformations
Definition: vtkAbstractTransform.h:52
vtkPerspectiveTransform::Concatenate
void Concatenate(vtkHomogeneousTransform *transform)
Concatenate the specified transform with the current transformation according to PreMultiply or PostM...
vtkPerspectiveTransform::Scale
void Scale(const float s[3])
Create a scale matrix (i.e.
Definition: vtkPerspectiveTransform.h:231
vtkMatrix4x4::Element
double Element[4][4]
The internal data is public for historical reasons. Do not use!
Definition: vtkMatrix4x4.h:148
vtkTransformConcatenationStack
Definition: vtkAbstractTransform.h:483
vtkPerspectiveTransform::Concatenate
void Concatenate(vtkMatrix4x4 *matrix)
Concatenates the matrix with the current transformation according to PreMultiply or PostMultiply sema...
Definition: vtkPerspectiveTransform.h:252
vtkPerspectiveTransform::PostMultiply
void PostMultiply()
Sets the internal state of the transform to PostMultiply.
Definition: vtkPerspectiveTransform.h:289
vtkPerspectiveTransform::RotateX
void RotateX(double angle)
Create a rotation matrix about the X, Y, or Z axis and concatenate it with the current transformation...
Definition: vtkPerspectiveTransform.h:218
vtkPerspectiveTransform::PreMultiply
void PreMultiply()
Sets the internal state of the transform to PreMultiply.
Definition: vtkPerspectiveTransform.h:272
vtkPerspectiveTransform::InternalUpdate
void InternalUpdate() override
Perform any subclass-specific Update.
vtkObject::Modified
virtual void Modified()
Update the modification time for this object.
vtkPerspectiveTransform::RotateZ
void RotateZ(double angle)
Create a rotation matrix about the X, Y, or Z axis and concatenate it with the current transformation...
Definition: vtkPerspectiveTransform.h:220
vtkPerspectiveTransform::Inverse
void Inverse() override
Invert the transformation.
Definition: vtkPerspectiveTransform.h:95
vtkPerspectiveTransform::Input
vtkHomogeneousTransform * Input
Definition: vtkPerspectiveTransform.h:424
vtkPerspectiveTransform::SetMatrix
void SetMatrix(const double elements[16])
Set the current matrix directly.
Definition: vtkPerspectiveTransform.h:240
vtkPerspectiveTransform::GetNumberOfConcatenatedTransforms
int GetNumberOfConcatenatedTransforms()
Get the total number of transformations that are linked into this one via Concatenate() operations or...
Definition: vtkPerspectiveTransform.h:303
vtkPerspectiveTransform::Push
void Push()
Pushes the current transformation onto the transformation stack.
Definition: vtkPerspectiveTransform.h:369
vtkPerspectiveTransform::RotateWXYZ
void RotateWXYZ(double angle, double x, double y, double z)
Create a rotation matrix and concatenate it with the current transformation according to PreMultiply ...
Definition: vtkPerspectiveTransform.h:198
vtkPerspectiveTransform::Translate
void Translate(const double x[3])
Create a translation matrix and concatenate it with the current transformation according to PreMultip...
Definition: vtkPerspectiveTransform.h:187
vtkAbstractTransform::GetInverse
vtkAbstractTransform * GetInverse()
Get the inverse of this transform.
vtkPerspectiveTransform::Identity
void Identity()
Set this transformation to the identity transformation.
Definition: vtkPerspectiveTransform.h:84
vtkX3D::position
@ position
Definition: vtkX3D.h:267
vtkPerspectiveTransform::InternalDeepCopy
void InternalDeepCopy(vtkAbstractTransform *t) override
Perform any subclass-specific DeepCopy.
vtkPerspectiveTransform::RotateWXYZ
void RotateWXYZ(double angle, const float axis[3])
Create a rotation matrix and concatenate it with the current transformation according to PreMultiply ...
Definition: vtkPerspectiveTransform.h:206
vtkPerspectiveTransform::GetConcatenatedTransform
vtkHomogeneousTransform * GetConcatenatedTransform(int i)
Get one of the concatenated transformations as a vtkAbstractTransform.
Definition: vtkPerspectiveTransform.h:316
vtkPerspectiveTransform::RotateY
void RotateY(double angle)
Create a rotation matrix about the X, Y, or Z axis and concatenate it with the current transformation...
Definition: vtkPerspectiveTransform.h:219
vtkPerspectiveTransform::AdjustViewport
void AdjustViewport(double oldXMin, double oldXMax, double oldYMin, double oldYMax, double newXMin, double newXMax, double newYMin, double newYMax)
Perform an adjustment to the viewport coordinates.
vtkPerspectiveTransform::SetInput
void SetInput(vtkHomogeneousTransform *input)
Set the input for this transformation.
vtkHomogeneousTransform.h
vtkMatrix4x4.h
vtkPerspectiveTransform::Translate
void Translate(const float x[3])
Create a translation matrix and concatenate it with the current transformation according to PreMultip...
Definition: vtkPerspectiveTransform.h:188
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:113
vtkMatrix4x4
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:145
vtkPerspectiveTransform::Ortho
void Ortho(double xmin, double xmax, double ymin, double ymax, double znear, double zfar)
Create an orthogonal projection matrix and concatenate it by the current transformation.
vtkPerspectiveTransform::GetInput
vtkHomogeneousTransform * GetInput()
Set the input for this transformation.
Definition: vtkPerspectiveTransform.h:353
vtkPerspectiveTransform::Concatenate
void Concatenate(const double elements[16])
Concatenates the matrix with the current transformation according to PreMultiply or PostMultiply sema...
Definition: vtkPerspectiveTransform.h:253
vtkPerspectiveTransform::Concatenation
vtkTransformConcatenation * Concatenation
Definition: vtkPerspectiveTransform.h:425
vtkPerspectiveTransform::Shear
void Shear(double dxdz, double dydz, double zplane)
Create a shear transformation about a plane at distance z from the camera.
vtkTransformConcatenationStack::New
static vtkTransformConcatenationStack * New()
Definition: vtkAbstractTransform.h:485
vtkPerspectiveTransform::~vtkPerspectiveTransform
~vtkPerspectiveTransform() override
vtkPerspectiveTransform
describes a 4x4 matrix transformation
Definition: vtkPerspectiveTransform.h:73
vtkPerspectiveTransform::CircuitCheck
int CircuitCheck(vtkAbstractTransform *transform) override
Check for self-reference.
vtkPerspectiveTransform::RotateWXYZ
void RotateWXYZ(double angle, const double axis[3])
Create a rotation matrix and concatenate it with the current transformation according to PreMultiply ...
Definition: vtkPerspectiveTransform.h:202
vtkPerspectiveTransform::Scale
void Scale(double x, double y, double z)
Create a scale matrix (i.e.
Definition: vtkPerspectiveTransform.h:229
vtkPerspectiveTransform::GetMTime
vtkMTimeType GetMTime() override
Override GetMTime to account for input and concatenation.
vtkPerspectiveTransform::Stack
vtkTransformConcatenationStack * Stack
Definition: vtkPerspectiveTransform.h:426
vtkPerspectiveTransform::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkPerspectiveTransform::New
static vtkPerspectiveTransform * New()
vtkPerspectiveTransform::Stereo
void Stereo(double angle, double focaldistance)
Create a stereo shear matrix and concatenate it with the current transformation.
vtkPerspectiveTransform::SetupCamera
void SetupCamera(double p0, double p1, double p2, double fp0, double fp1, double fp2, double vup0, double vup1, double vup2)
vtkPerspectiveTransform::MakeTransform
vtkAbstractTransform * MakeTransform() override
Make a new transform of the same type – you are responsible for deleting the transform when you are d...
vtkPerspectiveTransform::Frustum
void Frustum(double xmin, double xmax, double ymin, double ymax, double znear, double zfar)
Create an perspective projection matrix and concatenate it by the current transformation.
vtkPerspectiveTransform::SetupCamera
void SetupCamera(const double position[3], const double focalpoint[3], const double viewup[3])
Set a view transformation matrix for the camera (this matrix does not contain any perspective) and co...
vtkPerspectiveTransform::GetInverseFlag
int GetInverseFlag()
Get the inverse flag of the transformation.
Definition: vtkPerspectiveTransform.h:363
vtkPerspectiveTransform::vtkPerspectiveTransform
vtkPerspectiveTransform()
vtkTransformConcatenation
Definition: vtkAbstractTransform.h:377
vtkPerspectiveTransform::AdjustZBuffer
void AdjustZBuffer(double oldNearZ, double oldFarZ, double newNearZ, double newFarZ)
Perform an adjustment to the Z-Buffer range that the near and far clipping planes map to.
vtkMTimeType
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:287
vtkPerspectiveTransform::Pop
void Pop()
Deletes the transformation on the top of the stack and sets the top to the next transformation on the...
Definition: vtkPerspectiveTransform.h:385