VTK  9.3.1
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:
48  static vtkPerspectiveTransform* New();
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 
236  void Concatenate(vtkHomogeneousTransform* transform);
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 
325  void SetInput(vtkHomogeneousTransform* input);
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:
392  ~vtkPerspectiveTransform() override;
393 
394  void InternalDeepCopy(vtkAbstractTransform* t) override;
395  void InternalUpdate() override;
396 
400 
401 private:
403  void operator=(const vtkPerspectiveTransform&) = delete;
404 };
405 
406 VTK_ABI_NAMESPACE_END
407 #endif
void PostMultiply()
Sets the internal state of the transform to PostMultiply.
vtkTypeBool GetInverseFlag()
Get the inverse flag of the transformation.
void RotateZ(double angle)
Create a rotation matrix about the X, Y, or Z axis and concatenate it with the current transformation...
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:30
vtkHomogeneousTransform * Input
void SetMatrix(const double elements[16])
Set the current matrix directly.
vtkMTimeType GetMTime() override
Override GetMTime necessary because of inverse transforms.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:270
void Pop()
Deletes the transformation on the top of the stack and sets the top to the next transformation on the...
void RotateWXYZ(double angle, double x, double y, double z)
Create a rotation matrix and concatenate it with the current transformation according to PreMultiply ...
superclass for homogeneous transformations
void Scale(const double s[3])
Create a scale matrix (i.e.
void SetMatrix(vtkMatrix4x4 *matrix)
Set the current matrix directly.
void RotateX(double angle)
Create a rotation matrix about the X, Y, or Z axis and concatenate it with the current transformation...
void Scale(const float s[3])
Create a scale matrix (i.e.
virtual void InternalUpdate()
Perform any subclass-specific Update.
virtual vtkAbstractTransform * MakeTransform()=0
Make another transform of the same type.
vtkAbstractTransform * GetInverse()
Get the inverse of this transform.
void Concatenate(vtkMatrix4x4 *matrix)
Concatenates the matrix with the current transformation according to PreMultiply or PostMultiply sema...
void Push()
Pushes the current transformation onto the transformation stack.
void PreMultiply()
Sets the internal state of the transform to PreMultiply.
void Translate(const double x[3])
Create a translation matrix and concatenate it with the current transformation according to PreMultip...
void Inverse() override
Invert the transformation.
int vtkTypeBool
Definition: vtkABI.h:64
void Identity()
Set this transformation to the identity transformation.
vtkHomogeneousTransform * GetInput()
Set the input for this transformation.
void RotateY(double angle)
Create a rotation matrix about the X, Y, or Z axis and concatenate it with the current transformation...
int GetNumberOfConcatenatedTransforms()
Get the total number of transformations that are linked into this one via Concatenate() operations or...
virtual int CircuitCheck(vtkAbstractTransform *transform)
Check for self-reference.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
a simple class to control print indentation
Definition: vtkIndent.h:28
void RotateWXYZ(double angle, const float axis[3])
Create a rotation matrix and concatenate it with the current transformation according to PreMultiply ...
vtkHomogeneousTransform * GetConcatenatedTransform(int i)
Get one of the concatenated transformations as a vtkAbstractTransform.
superclass for all geometric transformations
virtual void Modified()
Update the modification time for this object.
void Translate(const float x[3])
Create a translation matrix and concatenate it with the current transformation according to PreMultip...
void InternalDeepCopy(vtkAbstractTransform *transform) override
Perform any subclass-specific DeepCopy.
double Element[4][4]
The internal data is public for historical reasons. Do not use!
Definition: vtkMatrix4x4.h:34
void Concatenate(const double elements[16])
Concatenates the matrix with the current transformation according to PreMultiply or PostMultiply sema...
vtkTransformConcatenation * Concatenation
vtkTransformConcatenationStack * Stack
void RotateWXYZ(double angle, const double axis[3])
Create a rotation matrix and concatenate it with the current transformation according to PreMultiply ...
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
static vtkTransformConcatenationStack * New()
void Scale(double x, double y, double z)
Create a scale matrix (i.e.
void Translate(double x, double y, double z)
Create a translation matrix and concatenate it with the current transformation according to PreMultip...
describes a 4x4 matrix transformation