VTK  9.3.20240425
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
55#ifndef vtkPerspectiveTransform_h
56#define vtkPerspectiveTransform_h
57
58#include "vtkCommonTransformsModule.h" // For export macro
60
61#include "vtkMatrix4x4.h" // Needed for inline methods
62
63VTK_ABI_NAMESPACE_BEGIN
64class VTKCOMMONTRANSFORMS_EXPORT vtkPerspectiveTransform : public vtkHomogeneousTransform
65{
66public:
69 void PrintSelf(ostream& os, vtkIndent indent) override;
70
76 void Identity()
77 {
78 this->Concatenation->Identity();
79 this->Modified();
80 }
81
87 void Inverse() override
88 {
89 this->Concatenation->Inverse();
90 this->Modified();
91 }
92
101 void AdjustViewport(double oldXMin, double oldXMax, double oldYMin, double oldYMax,
102 double newXMin, double newXMax, double newYMin, double newYMax);
103
111 void AdjustZBuffer(double oldNearZ, double oldFarZ, double newNearZ, double newFarZ);
112
118 void Ortho(double xmin, double xmax, double ymin, double ymax, double znear, double zfar);
119
126 void Frustum(double xmin, double xmax, double ymin, double ymax, double znear, double zfar);
127
134 void Perspective(double angle, double aspect, double znear, double zfar);
135
149 void Shear(double dxdz, double dydz, double zplane);
150
161 void Stereo(double angle, double focaldistance);
162
168 void SetupCamera(const double position[3], const double focalpoint[3], const double viewup[3]);
169
170 void SetupCamera(double p0, double p1, double p2, double fp0, double fp1, double fp2, double vup0,
171 double vup1, double vup2);
172
174
178 void Translate(double x, double y, double z) { this->Concatenation->Translate(x, y, z); }
179 void Translate(const double x[3]) { this->Translate(x[0], x[1], x[2]); }
180 void Translate(const float x[3]) { this->Translate(x[0], x[1], x[2]); }
182
184
190 void RotateWXYZ(double angle, double x, double y, double z)
191 {
192 this->Concatenation->Rotate(angle, x, y, z);
193 }
194 void RotateWXYZ(double angle, const double axis[3])
195 {
196 this->RotateWXYZ(angle, axis[0], axis[1], axis[2]);
197 }
198 void RotateWXYZ(double angle, const float axis[3])
199 {
200 this->RotateWXYZ(angle, axis[0], axis[1], axis[2]);
201 }
203
205
210 void RotateX(double angle) { this->RotateWXYZ(angle, 1, 0, 0); }
211 void RotateY(double angle) { this->RotateWXYZ(angle, 0, 1, 0); }
212 void RotateZ(double angle) { this->RotateWXYZ(angle, 0, 0, 1); }
214
216
221 void Scale(double x, double y, double z) { this->Concatenation->Scale(x, y, z); }
222 void Scale(const double s[3]) { this->Scale(s[0], s[1], s[2]); }
223 void Scale(const float s[3]) { this->Scale(s[0], s[1], s[2]); }
225
227
231 void SetMatrix(vtkMatrix4x4* matrix) { this->SetMatrix(*matrix->Element); }
232 void SetMatrix(const double elements[16])
233 {
234 this->Identity();
235 this->Concatenate(elements);
236 }
238
240
244 void Concatenate(vtkMatrix4x4* matrix) { this->Concatenate(*matrix->Element); }
245 void Concatenate(const double elements[16]) { this->Concatenation->Concatenate(elements); }
247
256
265 {
266 if (this->Concatenation->GetPreMultiplyFlag())
267 {
268 return;
269 }
270 this->Concatenation->SetPreMultiplyFlag(1);
271 this->Modified();
272 }
273
282 {
283 if (!this->Concatenation->GetPreMultiplyFlag())
284 {
285 return;
286 }
287 this->Concatenation->SetPreMultiplyFlag(0);
288 this->Modified();
289 }
290
296 {
297 return this->Concatenation->GetNumberOfTransforms() + (this->Input == nullptr ? 0 : 1);
298 }
299
301
309 {
311 if (this->Input == nullptr)
312 {
313 t = this->Concatenation->GetTransform(i);
314 }
315 else if (i < this->Concatenation->GetNumberOfPreTransforms())
316 {
317 t = this->Concatenation->GetTransform(i);
318 }
319 else if (i > this->Concatenation->GetNumberOfPreTransforms())
320 {
321 t = this->Concatenation->GetTransform(i - 1);
322 }
323 else if (this->GetInverseFlag())
324 {
325 t = this->Input->GetInverse();
326 }
327 else
328 {
329 t = this->Input;
330 }
331 return static_cast<vtkHomogeneousTransform*>(t);
332 }
334
336
345 vtkHomogeneousTransform* GetInput() { return this->Input; }
347
355 vtkTypeBool GetInverseFlag() { return this->Concatenation->GetInverseFlag(); }
356
358
361 void Push()
362 {
363 if (this->Stack == nullptr)
364 {
366 }
367 this->Stack->Push(&this->Concatenation);
368 this->Modified();
369 }
371
373
377 void Pop()
378 {
379 if (this->Stack == nullptr)
380 {
381 return;
382 }
383 this->Stack->Pop(&this->Concatenation);
384 this->Modified();
385 }
387
393
402 int CircuitCheck(vtkAbstractTransform* transform) override;
403
408
409protected:
412
414 void InternalUpdate() override;
415
419
420private:
422 void operator=(const vtkPerspectiveTransform&) = delete;
423};
424
425VTK_ABI_NAMESPACE_END
426#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:108
represent and manipulate 4x4 transformation matrices
double Element[4][4]
The internal data is public for historical reasons. Do not use!
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.
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()
int vtkTypeBool
Definition vtkABI.h:64
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:270