VTK  9.2.6
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 
48 #ifndef vtkPerspectiveTransform_h
49 #define vtkPerspectiveTransform_h
50 
51 #include "vtkCommonTransformsModule.h" // For export macro
53 
54 #include "vtkMatrix4x4.h" // Needed for inline methods
55 
56 class VTKCOMMONTRANSFORMS_EXPORT vtkPerspectiveTransform : public vtkHomogeneousTransform
57 {
58 public:
59  static vtkPerspectiveTransform* New();
61  void PrintSelf(ostream& os, vtkIndent indent) override;
62 
68  void Identity()
69  {
70  this->Concatenation->Identity();
71  this->Modified();
72  }
73 
79  void Inverse() override
80  {
81  this->Concatenation->Inverse();
82  this->Modified();
83  }
84 
93  void AdjustViewport(double oldXMin, double oldXMax, double oldYMin, double oldYMax,
94  double newXMin, double newXMax, double newYMin, double newYMax);
95 
103  void AdjustZBuffer(double oldNearZ, double oldFarZ, double newNearZ, double newFarZ);
104 
110  void Ortho(double xmin, double xmax, double ymin, double ymax, double znear, double zfar);
111 
118  void Frustum(double xmin, double xmax, double ymin, double ymax, double znear, double zfar);
119 
126  void Perspective(double angle, double aspect, double znear, double zfar);
127 
141  void Shear(double dxdz, double dydz, double zplane);
142 
153  void Stereo(double angle, double focaldistance);
154 
160  void SetupCamera(const double position[3], const double focalpoint[3], const double viewup[3]);
161 
162  void SetupCamera(double p0, double p1, double p2, double fp0, double fp1, double fp2, double vup0,
163  double vup1, double vup2);
164 
166 
170  void Translate(double x, double y, double z) { this->Concatenation->Translate(x, y, z); }
171  void Translate(const double x[3]) { this->Translate(x[0], x[1], x[2]); }
172  void Translate(const float x[3]) { this->Translate(x[0], x[1], x[2]); }
174 
176 
182  void RotateWXYZ(double angle, double x, double y, double z)
183  {
184  this->Concatenation->Rotate(angle, x, y, z);
185  }
186  void RotateWXYZ(double angle, const double axis[3])
187  {
188  this->RotateWXYZ(angle, axis[0], axis[1], axis[2]);
189  }
190  void RotateWXYZ(double angle, const float axis[3])
191  {
192  this->RotateWXYZ(angle, axis[0], axis[1], axis[2]);
193  }
195 
197 
202  void RotateX(double angle) { this->RotateWXYZ(angle, 1, 0, 0); }
203  void RotateY(double angle) { this->RotateWXYZ(angle, 0, 1, 0); }
204  void RotateZ(double angle) { this->RotateWXYZ(angle, 0, 0, 1); }
206 
208 
213  void Scale(double x, double y, double z) { this->Concatenation->Scale(x, y, z); }
214  void Scale(const double s[3]) { this->Scale(s[0], s[1], s[2]); }
215  void Scale(const float s[3]) { this->Scale(s[0], s[1], s[2]); }
217 
219 
223  void SetMatrix(vtkMatrix4x4* matrix) { this->SetMatrix(*matrix->Element); }
224  void SetMatrix(const double elements[16])
225  {
226  this->Identity();
227  this->Concatenate(elements);
228  }
230 
232 
236  void Concatenate(vtkMatrix4x4* matrix) { this->Concatenate(*matrix->Element); }
237  void Concatenate(const double elements[16]) { this->Concatenation->Concatenate(elements); }
239 
247  void Concatenate(vtkHomogeneousTransform* transform);
248 
256  void PreMultiply()
257  {
258  if (this->Concatenation->GetPreMultiplyFlag())
259  {
260  return;
261  }
262  this->Concatenation->SetPreMultiplyFlag(1);
263  this->Modified();
264  }
265 
274  {
275  if (!this->Concatenation->GetPreMultiplyFlag())
276  {
277  return;
278  }
279  this->Concatenation->SetPreMultiplyFlag(0);
280  this->Modified();
281  }
282 
288  {
289  return this->Concatenation->GetNumberOfTransforms() + (this->Input == nullptr ? 0 : 1);
290  }
291 
293 
301  {
303  if (this->Input == nullptr)
304  {
305  t = this->Concatenation->GetTransform(i);
306  }
307  else if (i < this->Concatenation->GetNumberOfPreTransforms())
308  {
309  t = this->Concatenation->GetTransform(i);
310  }
311  else if (i > this->Concatenation->GetNumberOfPreTransforms())
312  {
313  t = this->Concatenation->GetTransform(i - 1);
314  }
315  else if (this->GetInverseFlag())
316  {
317  t = this->Input->GetInverse();
318  }
319  else
320  {
321  t = this->Input;
322  }
323  return static_cast<vtkHomogeneousTransform*>(t);
324  }
326 
328 
336  void SetInput(vtkHomogeneousTransform* input);
337  vtkHomogeneousTransform* GetInput() { return this->Input; }
339 
347  int GetInverseFlag() { return this->Concatenation->GetInverseFlag(); }
348 
350 
353  void Push()
354  {
355  if (this->Stack == nullptr)
356  {
357  this->Stack = vtkTransformConcatenationStack::New();
358  }
359  this->Stack->Push(&this->Concatenation);
360  this->Modified();
361  }
363 
365 
369  void Pop()
370  {
371  if (this->Stack == nullptr)
372  {
373  return;
374  }
375  this->Stack->Pop(&this->Concatenation);
376  this->Modified();
377  }
379 
385 
394  int CircuitCheck(vtkAbstractTransform* transform) override;
395 
399  vtkMTimeType GetMTime() override;
400 
401 protected:
403  ~vtkPerspectiveTransform() override;
404 
405  void InternalDeepCopy(vtkAbstractTransform* t) override;
406  void InternalUpdate() override;
407 
411 
412 private:
414  void operator=(const vtkPerspectiveTransform&) = delete;
415 };
416 
417 #endif
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...
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:41
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:287
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.
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:39
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:45
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 ...
int GetInverseFlag()
Get the inverse flag of the transformation.
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