VTK  9.0.1
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 
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 class VTKCOMMONTRANSFORMS_EXPORT vtkPerspectiveTransform : public vtkHomogeneousTransform
54 {
55 public:
58  void PrintSelf(ostream& os, vtkIndent indent) override;
59 
65  void Identity()
66  {
67  this->Concatenation->Identity();
68  this->Modified();
69  }
70 
76  void Inverse() override
77  {
78  this->Concatenation->Inverse();
79  this->Modified();
80  }
81 
90  void AdjustViewport(double oldXMin, double oldXMax, double oldYMin, double oldYMax,
91  double newXMin, double newXMax, double newYMin, double newYMax);
92 
100  void AdjustZBuffer(double oldNearZ, double oldFarZ, double newNearZ, double newFarZ);
101 
107  void Ortho(double xmin, double xmax, double ymin, double ymax, double znear, double zfar);
108 
115  void Frustum(double xmin, double xmax, double ymin, double ymax, double znear, double zfar);
116 
123  void Perspective(double angle, double aspect, double znear, double zfar);
124 
138  void Shear(double dxdz, double dydz, double zplane);
139 
150  void Stereo(double angle, double focaldistance);
151 
157  void SetupCamera(const double position[3], const double focalpoint[3], const double viewup[3]);
158 
159  void SetupCamera(double p0, double p1, double p2, double fp0, double fp1, double fp2, double vup0,
160  double vup1, double vup2);
161 
163 
167  void Translate(double x, double y, double z) { this->Concatenation->Translate(x, y, z); }
168  void Translate(const double x[3]) { this->Translate(x[0], x[1], x[2]); }
169  void Translate(const float x[3]) { this->Translate(x[0], x[1], x[2]); }
171 
173 
179  void RotateWXYZ(double angle, double x, double y, double z)
180  {
181  this->Concatenation->Rotate(angle, x, y, z);
182  }
183  void RotateWXYZ(double angle, const double axis[3])
184  {
185  this->RotateWXYZ(angle, axis[0], axis[1], axis[2]);
186  }
187  void RotateWXYZ(double angle, const float axis[3])
188  {
189  this->RotateWXYZ(angle, axis[0], axis[1], axis[2]);
190  }
192 
194 
199  void RotateX(double angle) { this->RotateWXYZ(angle, 1, 0, 0); }
200  void RotateY(double angle) { this->RotateWXYZ(angle, 0, 1, 0); }
201  void RotateZ(double angle) { this->RotateWXYZ(angle, 0, 0, 1); }
203 
205 
210  void Scale(double x, double y, double z) { this->Concatenation->Scale(x, y, z); }
211  void Scale(const double s[3]) { this->Scale(s[0], s[1], s[2]); }
212  void Scale(const float s[3]) { this->Scale(s[0], s[1], s[2]); }
214 
216 
220  void SetMatrix(vtkMatrix4x4* matrix) { this->SetMatrix(*matrix->Element); }
221  void SetMatrix(const double elements[16])
222  {
223  this->Identity();
224  this->Concatenate(elements);
225  }
227 
229 
233  void Concatenate(vtkMatrix4x4* matrix) { this->Concatenate(*matrix->Element); }
234  void Concatenate(const double elements[16]) { this->Concatenation->Concatenate(elements); }
236 
245 
253  void PreMultiply()
254  {
255  if (this->Concatenation->GetPreMultiplyFlag())
256  {
257  return;
258  }
259  this->Concatenation->SetPreMultiplyFlag(1);
260  this->Modified();
261  }
262 
271  {
272  if (!this->Concatenation->GetPreMultiplyFlag())
273  {
274  return;
275  }
276  this->Concatenation->SetPreMultiplyFlag(0);
277  this->Modified();
278  }
279 
285  {
286  return this->Concatenation->GetNumberOfTransforms() + (this->Input == nullptr ? 0 : 1);
287  }
288 
290 
298  {
300  if (this->Input == nullptr)
301  {
302  t = this->Concatenation->GetTransform(i);
303  }
304  else if (i < this->Concatenation->GetNumberOfPreTransforms())
305  {
306  t = this->Concatenation->GetTransform(i);
307  }
308  else if (i > this->Concatenation->GetNumberOfPreTransforms())
309  {
310  t = this->Concatenation->GetTransform(i - 1);
311  }
312  else if (this->GetInverseFlag())
313  {
314  t = this->Input->GetInverse();
315  }
316  else
317  {
318  t = this->Input;
319  }
320  return static_cast<vtkHomogeneousTransform*>(t);
321  }
323 
325 
334  vtkHomogeneousTransform* GetInput() { return this->Input; }
336 
344  int GetInverseFlag() { return this->Concatenation->GetInverseFlag(); }
345 
347 
350  void Push()
351  {
352  if (this->Stack == nullptr)
353  {
354  this->Stack = vtkTransformConcatenationStack::New();
355  }
356  this->Stack->Push(&this->Concatenation);
357  this->Modified();
358  }
360 
362 
366  void Pop()
367  {
368  if (this->Stack == nullptr)
369  {
370  return;
371  }
372  this->Stack->Pop(&this->Concatenation);
373  this->Modified();
374  }
376 
382 
391  int CircuitCheck(vtkAbstractTransform* transform) override;
392 
396  vtkMTimeType GetMTime() override;
397 
398 protected:
401 
403  void InternalUpdate() override;
404 
408 
409 private:
411  void operator=(const vtkPerspectiveTransform&) = delete;
412 };
413 
414 #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:34
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:36
double Element[4][4]
The internal data is public for historical reasons. Do not use!
Definition: vtkMatrix4x4.h:39
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])
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])
vtkHomogeneousTransform * GetInput()
void PostMultiply()
Sets the internal state of the transform to PostMultiply.
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 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])
void Scale(const double s[3])
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])
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.
int GetInverseFlag()
Get the inverse flag of the transformation.
void RotateWXYZ(double angle, const double axis[3])
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.
void RotateWXYZ(double angle, const float axis[3])
vtkHomogeneousTransform * Input
vtkTransformConcatenation * Concatenation
void SetMatrix(const double elements[16])
static vtkTransformConcatenationStack * New()
@ position
Definition: vtkX3D.h:267
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:293