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
67#ifndef vtkPerspectiveTransform_h
68#define vtkPerspectiveTransform_h
69
70#include "vtkCommonTransformsModule.h" // For export macro
72
73#include "vtkMatrix4x4.h" // Needed for inline methods
74
75class VTKCOMMONTRANSFORMS_EXPORT vtkPerspectiveTransform : public vtkHomogeneousTransform
76{
77public:
80 void PrintSelf(ostream& os, vtkIndent indent) override;
81
87 void Identity()
88 {
89 this->Concatenation->Identity();
90 this->Modified();
91 }
92
98 void Inverse() override
99 {
100 this->Concatenation->Inverse();
101 this->Modified();
102 }
103
112 void AdjustViewport(double oldXMin, double oldXMax, double oldYMin, double oldYMax,
113 double newXMin, double newXMax, double newYMin, double newYMax);
114
122 void AdjustZBuffer(double oldNearZ, double oldFarZ, double newNearZ, double newFarZ);
123
129 void Ortho(double xmin, double xmax, double ymin, double ymax, double znear, double zfar);
130
137 void Frustum(double xmin, double xmax, double ymin, double ymax, double znear, double zfar);
138
145 void Perspective(double angle, double aspect, double znear, double zfar);
146
160 void Shear(double dxdz, double dydz, double zplane);
161
172 void Stereo(double angle, double focaldistance);
173
179 void SetupCamera(const double position[3], const double focalpoint[3], const double viewup[3]);
180
181 void SetupCamera(double p0, double p1, double p2, double fp0, double fp1, double fp2, double vup0,
182 double vup1, double vup2);
183
185
189 void Translate(double x, double y, double z) { this->Concatenation->Translate(x, y, z); }
190 void Translate(const double x[3]) { this->Translate(x[0], x[1], x[2]); }
191 void Translate(const float x[3]) { this->Translate(x[0], x[1], x[2]); }
193
195
201 void RotateWXYZ(double angle, double x, double y, double z)
202 {
203 this->Concatenation->Rotate(angle, x, y, z);
204 }
205 void RotateWXYZ(double angle, const double axis[3])
206 {
207 this->RotateWXYZ(angle, axis[0], axis[1], axis[2]);
208 }
209 void RotateWXYZ(double angle, const float axis[3])
210 {
211 this->RotateWXYZ(angle, axis[0], axis[1], axis[2]);
212 }
214
216
221 void RotateX(double angle) { this->RotateWXYZ(angle, 1, 0, 0); }
222 void RotateY(double angle) { this->RotateWXYZ(angle, 0, 1, 0); }
223 void RotateZ(double angle) { this->RotateWXYZ(angle, 0, 0, 1); }
225
227
232 void Scale(double x, double y, double z) { this->Concatenation->Scale(x, y, z); }
233 void Scale(const double s[3]) { this->Scale(s[0], s[1], s[2]); }
234 void Scale(const float s[3]) { this->Scale(s[0], s[1], s[2]); }
236
238
242 void SetMatrix(vtkMatrix4x4* matrix) { this->SetMatrix(*matrix->Element); }
243 void SetMatrix(const double elements[16])
244 {
245 this->Identity();
246 this->Concatenate(elements);
247 }
249
251
255 void Concatenate(vtkMatrix4x4* matrix) { this->Concatenate(*matrix->Element); }
256 void Concatenate(const double elements[16]) { this->Concatenation->Concatenate(elements); }
258
267
276 {
277 if (this->Concatenation->GetPreMultiplyFlag())
278 {
279 return;
280 }
281 this->Concatenation->SetPreMultiplyFlag(1);
282 this->Modified();
283 }
284
293 {
294 if (!this->Concatenation->GetPreMultiplyFlag())
295 {
296 return;
297 }
298 this->Concatenation->SetPreMultiplyFlag(0);
299 this->Modified();
300 }
301
307 {
308 return this->Concatenation->GetNumberOfTransforms() + (this->Input == nullptr ? 0 : 1);
309 }
310
312
320 {
322 if (this->Input == nullptr)
323 {
324 t = this->Concatenation->GetTransform(i);
325 }
326 else if (i < this->Concatenation->GetNumberOfPreTransforms())
327 {
328 t = this->Concatenation->GetTransform(i);
329 }
330 else if (i > this->Concatenation->GetNumberOfPreTransforms())
331 {
332 t = this->Concatenation->GetTransform(i - 1);
333 }
334 else if (this->GetInverseFlag())
335 {
336 t = this->Input->GetInverse();
337 }
338 else
339 {
340 t = this->Input;
341 }
342 return static_cast<vtkHomogeneousTransform*>(t);
343 }
345
347
356 vtkHomogeneousTransform* GetInput() { return this->Input; }
358
366 int GetInverseFlag() { return this->Concatenation->GetInverseFlag(); }
367
369
372 void Push()
373 {
374 if (this->Stack == nullptr)
375 {
377 }
378 this->Stack->Push(&this->Concatenation);
379 this->Modified();
380 }
382
384
388 void Pop()
389 {
390 if (this->Stack == nullptr)
391 {
392 return;
393 }
394 this->Stack->Pop(&this->Concatenation);
395 this->Modified();
396 }
398
404
413 int CircuitCheck(vtkAbstractTransform* transform) override;
414
419
420protected:
423
425 void InternalUpdate() override;
426
430
431private:
433 void operator=(const vtkPerspectiveTransform&) = delete;
434};
435
436#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:119
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:151
double Element[4][4]
The internal data is public for historical reasons. Do not use!
Definition: vtkMatrix4x4.h:154
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.
static vtkPerspectiveTransform * New()
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.
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 ...
void Concatenate(vtkMatrix4x4 *matrix)
Concatenates the matrix with the current transformation according to PreMultiply or PostMultiply sema...
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...
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.
vtkHomogeneousTransform * GetInput()
Set the input for this transformation.
void Push()
Pushes the current transformation onto the transformation stack.
vtkAbstractTransform * MakeTransform() override
Make a new transform of the same type – you are responsible for deleting the transform when you are d...
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.
vtkHomogeneousTransform * GetConcatenatedTransform(int i)
Get one of the concatenated transformations as a vtkAbstractTransform.
~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])
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.
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:267
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:287