VTK  9.3.0
vtkPerspectiveTransform.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
3 
45 #ifndef vtkPerspectiveTransform_h
46 #define vtkPerspectiveTransform_h
47 
48 #include "vtkCommonTransformsModule.h" // For export macro
50 
51 #include "vtkMatrix4x4.h" // Needed for inline methods
52 
53 VTK_ABI_NAMESPACE_BEGIN
54 class VTKCOMMONTRANSFORMS_EXPORT vtkPerspectiveTransform : public vtkHomogeneousTransform
55 {
56 public:
59  void PrintSelf(ostream& os, vtkIndent indent) override;
60 
66  void Identity()
67  {
68  this->Concatenation->Identity();
69  this->Modified();
70  }
71 
77  void Inverse() override
78  {
79  this->Concatenation->Inverse();
80  this->Modified();
81  }
82 
91  void AdjustViewport(double oldXMin, double oldXMax, double oldYMin, double oldYMax,
92  double newXMin, double newXMax, double newYMin, double newYMax);
93 
101  void AdjustZBuffer(double oldNearZ, double oldFarZ, double newNearZ, double newFarZ);
102 
108  void Ortho(double xmin, double xmax, double ymin, double ymax, double znear, double zfar);
109 
116  void Frustum(double xmin, double xmax, double ymin, double ymax, double znear, double zfar);
117 
124  void Perspective(double angle, double aspect, double znear, double zfar);
125 
139  void Shear(double dxdz, double dydz, double zplane);
140 
151  void Stereo(double angle, double focaldistance);
152 
158  void SetupCamera(const double position[3], const double focalpoint[3], const double viewup[3]);
159 
160  void SetupCamera(double p0, double p1, double p2, double fp0, double fp1, double fp2, double vup0,
161  double vup1, double vup2);
162 
164 
168  void Translate(double x, double y, double z) { this->Concatenation->Translate(x, y, z); }
169  void Translate(const double x[3]) { this->Translate(x[0], x[1], x[2]); }
170  void Translate(const float x[3]) { this->Translate(x[0], x[1], x[2]); }
172 
174 
180  void RotateWXYZ(double angle, double x, double y, double z)
181  {
182  this->Concatenation->Rotate(angle, x, y, z);
183  }
184  void RotateWXYZ(double angle, const double axis[3])
185  {
186  this->RotateWXYZ(angle, axis[0], axis[1], axis[2]);
187  }
188  void RotateWXYZ(double angle, const float axis[3])
189  {
190  this->RotateWXYZ(angle, axis[0], axis[1], axis[2]);
191  }
193 
195 
200  void RotateX(double angle) { this->RotateWXYZ(angle, 1, 0, 0); }
201  void RotateY(double angle) { this->RotateWXYZ(angle, 0, 1, 0); }
202  void RotateZ(double angle) { this->RotateWXYZ(angle, 0, 0, 1); }
204 
206 
211  void Scale(double x, double y, double z) { this->Concatenation->Scale(x, y, z); }
212  void Scale(const double s[3]) { this->Scale(s[0], s[1], s[2]); }
213  void Scale(const float s[3]) { this->Scale(s[0], s[1], s[2]); }
215 
217 
221  void SetMatrix(vtkMatrix4x4* matrix) { this->SetMatrix(*matrix->Element); }
222  void SetMatrix(const double elements[16])
223  {
224  this->Identity();
225  this->Concatenate(elements);
226  }
228 
230 
234  void Concatenate(vtkMatrix4x4* matrix) { this->Concatenate(*matrix->Element); }
235  void Concatenate(const double elements[16]) { this->Concatenation->Concatenate(elements); }
237 
246 
254  void PreMultiply()
255  {
256  if (this->Concatenation->GetPreMultiplyFlag())
257  {
258  return;
259  }
260  this->Concatenation->SetPreMultiplyFlag(1);
261  this->Modified();
262  }
263 
272  {
273  if (!this->Concatenation->GetPreMultiplyFlag())
274  {
275  return;
276  }
277  this->Concatenation->SetPreMultiplyFlag(0);
278  this->Modified();
279  }
280 
286  {
287  return this->Concatenation->GetNumberOfTransforms() + (this->Input == nullptr ? 0 : 1);
288  }
289 
291 
299  {
301  if (this->Input == nullptr)
302  {
303  t = this->Concatenation->GetTransform(i);
304  }
305  else if (i < this->Concatenation->GetNumberOfPreTransforms())
306  {
307  t = this->Concatenation->GetTransform(i);
308  }
309  else if (i > this->Concatenation->GetNumberOfPreTransforms())
310  {
311  t = this->Concatenation->GetTransform(i - 1);
312  }
313  else if (this->GetInverseFlag())
314  {
315  t = this->Input->GetInverse();
316  }
317  else
318  {
319  t = this->Input;
320  }
321  return static_cast<vtkHomogeneousTransform*>(t);
322  }
324 
326 
335  vtkHomogeneousTransform* GetInput() { return this->Input; }
337 
345  vtkTypeBool GetInverseFlag() { return this->Concatenation->GetInverseFlag(); }
346 
348 
351  void Push()
352  {
353  if (this->Stack == nullptr)
354  {
355  this->Stack = vtkTransformConcatenationStack::New();
356  }
357  this->Stack->Push(&this->Concatenation);
358  this->Modified();
359  }
361 
363 
367  void Pop()
368  {
369  if (this->Stack == nullptr)
370  {
371  return;
372  }
373  this->Stack->Pop(&this->Concatenation);
374  this->Modified();
375  }
377 
383 
392  int CircuitCheck(vtkAbstractTransform* transform) override;
393 
397  vtkMTimeType GetMTime() override;
398 
399 protected:
402 
404  void InternalUpdate() override;
405 
409 
410 private:
412  void operator=(const vtkPerspectiveTransform&) = delete;
413 };
414 
415 VTK_ABI_NAMESPACE_END
416 #endif
superclass for all geometric transformations
vtkAbstractTransform * GetInverse()
Get the inverse of this transform.
superclass for homogeneous transformations
a simple class to control print indentation
Definition: vtkIndent.h:38
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:40
double Element[4][4]
The internal data is public for historical reasons. Do not use!
Definition: vtkMatrix4x4.h:43
virtual void Modified()
Update the modification time for this object.
describes a 4x4 matrix transformation
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...
vtkMTimeType GetMTime() override
Override GetMTime to account for input and concatenation.
void PreMultiply()
Sets the internal state of the transform to PreMultiply.
int CircuitCheck(vtkAbstractTransform *transform) override
Check for self-reference.
void Scale(const float s[3])
Create a scale matrix (i.e.
void SetInput(vtkHomogeneousTransform *input)
Set the input for this transformation.
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.
void Scale(double x, double y, double z)
Create a scale matrix (i.e.
vtkHomogeneousTransform * GetConcatenatedTransform(int i)
Get one of the concatenated transformations as a vtkAbstractTransform.
void SetMatrix(vtkMatrix4x4 *matrix)
Set the current matrix directly.
void RotateWXYZ(double angle, double x, double y, double z)
Create a rotation matrix and concatenate it with the current transformation according to PreMultiply ...
vtkAbstractTransform * MakeTransform() override
Make a new transform of the same type – you are responsible for deleting the transform when you are d...
void Concatenate(vtkMatrix4x4 *matrix)
Concatenates the matrix with the current transformation according to PreMultiply or PostMultiply sema...
static vtkPerspectiveTransform * New()
void Stereo(double angle, double focaldistance)
Create a stereo shear matrix and concatenate it with the current transformation.
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.
void Translate(const float x[3])
Create a translation matrix and concatenate it with the current transformation according to PreMultip...
vtkHomogeneousTransform * GetInput()
Set the input for this transformation.
void PostMultiply()
Sets the internal state of the transform to PostMultiply.
void RotateZ(double angle)
Create a rotation matrix about the X, Y, or Z axis and concatenate it with the current transformation...
vtkTransformConcatenationStack * Stack
int GetNumberOfConcatenatedTransforms()
Get the total number of transformations that are linked into this one via Concatenate() operations or...
void Identity()
Set this transformation to the identity transformation.
void Pop()
Deletes the transformation on the top of the stack and sets the top to the next transformation on the...
void Translate(double x, double y, double z)
Create a translation matrix and concatenate it with the current transformation according to PreMultip...
void Inverse() override
Invert the transformation.
void RotateX(double angle)
Create a rotation matrix about the X, Y, or Z axis and concatenate it with the current transformation...
void RotateY(double angle)
Create a rotation matrix about the X, Y, or Z axis and concatenate it with the current transformation...
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.
void Concatenate(const double elements[16])
Concatenates the matrix with the current transformation according to PreMultiply or PostMultiply sema...
void Scale(const double s[3])
Create a scale matrix (i.e.
void Push()
Pushes the current transformation onto the transformation stack.
void SetupCamera(double p0, double p1, double p2, double fp0, double fp1, double fp2, double vup0, double vup1, double vup2)
void Translate(const double x[3])
Create a translation matrix and concatenate it with the current transformation according to PreMultip...
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...
void InternalDeepCopy(vtkAbstractTransform *t) override
Perform any subclass-specific DeepCopy.
~vtkPerspectiveTransform() override
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void RotateWXYZ(double angle, const double axis[3])
Create a rotation matrix and concatenate it with the current transformation according to PreMultiply ...
void Concatenate(vtkHomogeneousTransform *transform)
Concatenate the specified transform with the current transformation according to PreMultiply or PostM...
void Shear(double dxdz, double dydz, double zplane)
Create a shear transformation about a plane at distance z from the camera.
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.
void InternalUpdate() override
Perform any subclass-specific Update.
vtkTypeBool GetInverseFlag()
Get the inverse flag of the transformation.
void RotateWXYZ(double angle, const float axis[3])
Create a rotation matrix and concatenate it with the current transformation according to PreMultiply ...
vtkHomogeneousTransform * Input
vtkTransformConcatenation * Concatenation
void SetMatrix(const double elements[16])
Set the current matrix directly.
static vtkTransformConcatenationStack * New()
@ position
Definition: vtkX3D.h:261
int vtkTypeBool
Definition: vtkABI.h:64
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:270