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 
36 #ifndef vtkPerspectiveTransform_h
37 #define vtkPerspectiveTransform_h
38 
39 #include "vtkCommonTransformsModule.h" // For export macro
41 
42 #include "vtkMatrix4x4.h" // Needed for inline methods
43 
44 VTK_ABI_NAMESPACE_BEGIN
45 class VTKCOMMONTRANSFORMS_EXPORT vtkPerspectiveTransform : public vtkHomogeneousTransform
46 {
47 public:
50  void PrintSelf(ostream& os, vtkIndent indent) override;
51 
57  void Identity()
58  {
59  this->Concatenation->Identity();
60  this->Modified();
61  }
62 
68  void Inverse() override
69  {
70  this->Concatenation->Inverse();
71  this->Modified();
72  }
73 
82  void AdjustViewport(double oldXMin, double oldXMax, double oldYMin, double oldYMax,
83  double newXMin, double newXMax, double newYMin, double newYMax);
84 
92  void AdjustZBuffer(double oldNearZ, double oldFarZ, double newNearZ, double newFarZ);
93 
99  void Ortho(double xmin, double xmax, double ymin, double ymax, double znear, double zfar);
100 
107  void Frustum(double xmin, double xmax, double ymin, double ymax, double znear, double zfar);
108 
115  void Perspective(double angle, double aspect, double znear, double zfar);
116 
130  void Shear(double dxdz, double dydz, double zplane);
131 
142  void Stereo(double angle, double focaldistance);
143 
149  void SetupCamera(const double position[3], const double focalpoint[3], const double viewup[3]);
150 
151  void SetupCamera(double p0, double p1, double p2, double fp0, double fp1, double fp2, double vup0,
152  double vup1, double vup2);
153 
155 
159  void Translate(double x, double y, double z) { this->Concatenation->Translate(x, y, z); }
160  void Translate(const double x[3]) { this->Translate(x[0], x[1], x[2]); }
161  void Translate(const float x[3]) { this->Translate(x[0], x[1], x[2]); }
163 
165 
171  void RotateWXYZ(double angle, double x, double y, double z)
172  {
173  this->Concatenation->Rotate(angle, x, y, z);
174  }
175  void RotateWXYZ(double angle, const double axis[3])
176  {
177  this->RotateWXYZ(angle, axis[0], axis[1], axis[2]);
178  }
179  void RotateWXYZ(double angle, const float axis[3])
180  {
181  this->RotateWXYZ(angle, axis[0], axis[1], axis[2]);
182  }
184 
186 
191  void RotateX(double angle) { this->RotateWXYZ(angle, 1, 0, 0); }
192  void RotateY(double angle) { this->RotateWXYZ(angle, 0, 1, 0); }
193  void RotateZ(double angle) { this->RotateWXYZ(angle, 0, 0, 1); }
195 
197 
202  void Scale(double x, double y, double z) { this->Concatenation->Scale(x, y, z); }
203  void Scale(const double s[3]) { this->Scale(s[0], s[1], s[2]); }
204  void Scale(const float s[3]) { this->Scale(s[0], s[1], s[2]); }
206 
208 
212  void SetMatrix(vtkMatrix4x4* matrix) { this->SetMatrix(*matrix->Element); }
213  void SetMatrix(const double elements[16])
214  {
215  this->Identity();
216  this->Concatenate(elements);
217  }
219 
221 
225  void Concatenate(vtkMatrix4x4* matrix) { this->Concatenate(*matrix->Element); }
226  void Concatenate(const double elements[16]) { this->Concatenation->Concatenate(elements); }
228 
237 
245  void PreMultiply()
246  {
247  if (this->Concatenation->GetPreMultiplyFlag())
248  {
249  return;
250  }
251  this->Concatenation->SetPreMultiplyFlag(1);
252  this->Modified();
253  }
254 
263  {
264  if (!this->Concatenation->GetPreMultiplyFlag())
265  {
266  return;
267  }
268  this->Concatenation->SetPreMultiplyFlag(0);
269  this->Modified();
270  }
271 
277  {
278  return this->Concatenation->GetNumberOfTransforms() + (this->Input == nullptr ? 0 : 1);
279  }
280 
282 
290  {
292  if (this->Input == nullptr)
293  {
294  t = this->Concatenation->GetTransform(i);
295  }
296  else if (i < this->Concatenation->GetNumberOfPreTransforms())
297  {
298  t = this->Concatenation->GetTransform(i);
299  }
300  else if (i > this->Concatenation->GetNumberOfPreTransforms())
301  {
302  t = this->Concatenation->GetTransform(i - 1);
303  }
304  else if (this->GetInverseFlag())
305  {
306  t = this->Input->GetInverse();
307  }
308  else
309  {
310  t = this->Input;
311  }
312  return static_cast<vtkHomogeneousTransform*>(t);
313  }
315 
317 
326  vtkHomogeneousTransform* GetInput() { return this->Input; }
328 
336  vtkTypeBool GetInverseFlag() { return this->Concatenation->GetInverseFlag(); }
337 
339 
342  void Push()
343  {
344  if (this->Stack == nullptr)
345  {
346  this->Stack = vtkTransformConcatenationStack::New();
347  }
348  this->Stack->Push(&this->Concatenation);
349  this->Modified();
350  }
352 
354 
358  void Pop()
359  {
360  if (this->Stack == nullptr)
361  {
362  return;
363  }
364  this->Stack->Pop(&this->Concatenation);
365  this->Modified();
366  }
368 
374 
383  int CircuitCheck(vtkAbstractTransform* transform) override;
384 
388  vtkMTimeType GetMTime() override;
389 
390 protected:
393 
395  void InternalUpdate() override;
396 
400 
401 private:
403  void operator=(const vtkPerspectiveTransform&) = delete;
404 };
405 
406 VTK_ABI_NAMESPACE_END
407 #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:29
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:31
double Element[4][4]
The internal data is public for historical reasons. Do not use!
Definition: vtkMatrix4x4.h:34
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