VTK: Common/Transforms/vtkPerspectiveTransform.h Source File

| 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
45 #ifndef vtkPerspectiveTransform_h
46 #define vtkPerspectiveTransform_h
47
48 #include "vtkCommonTransformsModule.h" // For export macro
49 #include "vtkHomogeneousTransform.h"
50
51 #include "vtkMatrix4x4.h" // Needed for inline methods
52
53 VTK_ABI_NAMESPACE_BEGIN
54 class VTKCOMMONTRANSFORMS_EXPORT vtkPerspectiveTransform : public vtkHomogeneousTransform
55 {
56 public:
57 static vtkPerspectiveTransform* New();
58 vtkTypeMacro(vtkPerspectiveTransform, vtkHomogeneousTransform);
59 void PrintSelf(ostream& os, vtkIndent indent) override;
60
66 void Identity()
67 {
68 this->Concatenation->Identity();
69 this->Modified();
70 }
71
77 void Inverse() override
78 {
79 this->Concatenation->Inverse();
80 this->Modified();
81 }
82
91 void AdjustViewport(double oldXMin, double oldXMax, double oldYMin, double oldYMax,
92 double newXMin, double newXMax, double newYMin, double newYMax);
93
101 void AdjustZBuffer(double oldNearZ, double oldFarZ, double newNearZ, double newFarZ);
102
108 void Ortho(double xmin, double xmax, double ymin, double ymax, double znear, double zfar);
109
116 void Frustum(double xmin, double xmax, double ymin, double ymax, double znear, double zfar);
117
124 void Perspective(double angle, double aspect, double znear, double zfar);
125
139 void Shear(double dxdz, double dydz, double zplane);
140
151 void Stereo(double angle, double focaldistance);
152
158 void SetupCamera(const double position[3], const double focalpoint[3], const double viewup[3]);
159
160 void SetupCamera(double p0, double p1, double p2, double fp0, double fp1, double fp2, double vup0,
161 double vup1, double vup2);
162
164
168 void Translate(double x, double y, double z) { this->Concatenation->Translate(x, y, z); }
169 void Translate(const double x[3]) { this->Translate(x[0], x[1], x[2]); }
170 void Translate(const float x[3]) { this->Translate(x[0], x[1], x[2]); }
172
174
180 void RotateWXYZ(double angle, double x, double y, double z)
181 {
182 this->Concatenation->Rotate(angle, x, y, z);
183 }
184 void RotateWXYZ(double angle, const double axis[3])
185 {
186 this->RotateWXYZ(angle, axis[0], axis[1], axis[2]);
187 }
188 void RotateWXYZ(double angle, const float axis[3])
189 {
190 this->RotateWXYZ(angle, axis[0], axis[1], axis[2]);
191 }
193
195
200 void RotateX(double angle) { this->RotateWXYZ(angle, 1, 0, 0); }
201 void RotateY(double angle) { this->RotateWXYZ(angle, 0, 1, 0); }
202 void RotateZ(double angle) { this->RotateWXYZ(angle, 0, 0, 1); }
204
206
211 void Scale(double x, double y, double z) { this->Concatenation->Scale(x, y, z); }
212 void Scale(const double s[3]) { this->Scale(s[0], s[1], s[2]); }
213 void Scale(const float s[3]) { this->Scale(s[0], s[1], s[2]); }
215
217
221 void SetMatrix(vtkMatrix4x4* matrix) { this->SetMatrix(*matrix->Element); }
222 void SetMatrix(const double elements[16])
223 {
224 this->Identity();
225 this->Concatenate(elements);
226 }
228
230
234 void Concatenate(vtkMatrix4x4* matrix) { this->Concatenate(*matrix->Element); }
235 void Concatenate(const double elements[16]) { this->Concatenation->Concatenate(elements); }
237
245 void Concatenate(vtkHomogeneousTransform* transform);
246
254 void PreMultiply()
255 {
256 if (this->Concatenation->GetPreMultiplyFlag())
257 {
258 return;
259 }
260 this->Concatenation->SetPreMultiplyFlag(1);
261 this->Modified();
262 }
263
271 void PostMultiply()
272 {
273 if (!this->Concatenation->GetPreMultiplyFlag())
274 {
275 return;
276 }
277 this->Concatenation->SetPreMultiplyFlag(0);
278 this->Modified();
279 }
280
285 int GetNumberOfConcatenatedTransforms()
286 {
287 return this->Concatenation->GetNumberOfTransforms() + (this->Input == nullptr ? 0 : 1);
288 }
289
291
298 vtkHomogeneousTransform* GetConcatenatedTransform(int i)
299 {
300 vtkAbstractTransform* t;
301 if (this->Input == nullptr)
302 {
303 t = this->Concatenation->GetTransform(i);
304 }
305 else if (i < this->Concatenation->GetNumberOfPreTransforms())
306 {
307 t = this->Concatenation->GetTransform(i);
308 }
309 else if (i > this->Concatenation->GetNumberOfPreTransforms())
310 {
311 t = this->Concatenation->GetTransform(i - 1);
312 }
313 else if (this->GetInverseFlag())
314 {
315 t = this->Input->GetInverse();
316 }
317 else
318 {
319 t = this->Input;
320 }
321 return static_cast<vtkHomogeneousTransform*>(t);
322 }
324
326
334 void SetInput(vtkHomogeneousTransform* input);
335 vtkHomogeneousTransform* GetInput() { return this->Input; }
337
345 vtkTypeBool GetInverseFlag() { return this->Concatenation->GetInverseFlag(); }
346
348
351 void Push()
352 {
353 if (this->Stack == nullptr)
354 {
355 this->Stack = vtkTransformConcatenationStack::New();
356 }
357 this->Stack->Push(&this->Concatenation);
358 this->Modified();
359 }
361
363
367 void Pop()
368 {
369 if (this->Stack == nullptr)
370 {
371 return;
372 }
373 this->Stack->Pop(&this->Concatenation);
374 this->Modified();
375 }
377
382 vtkAbstractTransform* MakeTransform() override;
383
392 int CircuitCheck(vtkAbstractTransform* transform) override;
393
397 vtkMTimeType GetMTime() override;
398
399 protected:
400 vtkPerspectiveTransform();
401 ~vtkPerspectiveTransform() override;
402
403 void InternalDeepCopy(vtkAbstractTransform* t) override;
404 void InternalUpdate() override;
405
406 vtkHomogeneousTransform* Input;
407 vtkTransformConcatenation* Concatenation;
408 vtkTransformConcatenationStack* Stack;
409
410 private:
411 vtkPerspectiveTransform(const vtkPerspectiveTransform&) = delete;
412 void operator=(const vtkPerspectiveTransform&) = delete;
413 };
414
415 VTK_ABI_NAMESPACE_END
416 #endif
vtkAbstractTransform
superclass for all geometric transformations
Definition: vtkAbstractTransform.h:39
vtkAbstractTransform::GetInverse
vtkAbstractTransform * GetInverse()
Get the inverse of this transform.
vtkHomogeneousTransform
superclass for homogeneous transformations
Definition: vtkHomogeneousTransform.h:24
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:38
vtkMatrix4x4
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:40
vtkMatrix4x4::Element
double Element[4][4]
The internal data is public for historical reasons. Do not use!
Definition: vtkMatrix4x4.h:43
vtkObject::Modified
virtual void Modified()
Update the modification time for this object.
vtkPerspectiveTransform
describes a 4x4 matrix transformation
Definition: vtkPerspectiveTransform.h:55
vtkPerspectiveTransform::Perspective
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...
vtkPerspectiveTransform::GetMTime
vtkMTimeType GetMTime() override
Override GetMTime to account for input and concatenation.
vtkPerspectiveTransform::PreMultiply
void PreMultiply()
Sets the internal state of the transform to PreMultiply.
Definition: vtkPerspectiveTransform.h:254
vtkPerspectiveTransform::CircuitCheck
int CircuitCheck(vtkAbstractTransform *transform) override
Check for self-reference.
vtkPerspectiveTransform::Scale
void Scale(const float s[3])
Create a scale matrix (i.e.
Definition: vtkPerspectiveTransform.h:213
vtkPerspectiveTransform::SetInput
void SetInput(vtkHomogeneousTransform *input)
Set the input for this transformation.
vtkPerspectiveTransform::Frustum
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.
vtkPerspectiveTransform::Scale
void Scale(double x, double y, double z)
Create a scale matrix (i.e.
Definition: vtkPerspectiveTransform.h:211
vtkPerspectiveTransform::GetConcatenatedTransform
vtkHomogeneousTransform * GetConcatenatedTransform(int i)
Get one of the concatenated transformations as a vtkAbstractTransform.
Definition: vtkPerspectiveTransform.h:298
vtkPerspectiveTransform::SetMatrix
void SetMatrix(vtkMatrix4x4 *matrix)
Set the current matrix directly.
Definition: vtkPerspectiveTransform.h:221
vtkPerspectiveTransform::RotateWXYZ
void RotateWXYZ(double angle, double x, double y, double z)
Create a rotation matrix and concatenate it with the current transformation according to PreMultiply ...
Definition: vtkPerspectiveTransform.h:180
vtkPerspectiveTransform::MakeTransform
vtkAbstractTransform * MakeTransform() override
Make a new transform of the same type – you are responsible for deleting the transform when you are d...
vtkPerspectiveTransform::Concatenate
void Concatenate(vtkMatrix4x4 *matrix)
Concatenates the matrix with the current transformation according to PreMultiply or PostMultiply sema...
Definition: vtkPerspectiveTransform.h:234
vtkPerspectiveTransform::New
static vtkPerspectiveTransform * New()
vtkPerspectiveTransform::Stereo
void Stereo(double angle, double focaldistance)
Create a stereo shear matrix and concatenate it with the current transformation.
vtkPerspectiveTransform::Ortho
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.
vtkPerspectiveTransform::Translate
void Translate(const float x[3])
Create a translation matrix and concatenate it with the current transformation according to PreMultip...
Definition: vtkPerspectiveTransform.h:170
vtkPerspectiveTransform::GetInput
vtkHomogeneousTransform * GetInput()
Set the input for this transformation.
Definition: vtkPerspectiveTransform.h:335
vtkPerspectiveTransform::PostMultiply
void PostMultiply()
Sets the internal state of the transform to PostMultiply.
Definition: vtkPerspectiveTransform.h:271
vtkPerspectiveTransform::RotateZ
void RotateZ(double angle)
Create a rotation matrix about the X, Y, or Z axis and concatenate it with the current transformation...
Definition: vtkPerspectiveTransform.h:202
vtkPerspectiveTransform::Stack
vtkTransformConcatenationStack * Stack
Definition: vtkPerspectiveTransform.h:408
vtkPerspectiveTransform::GetNumberOfConcatenatedTransforms
int GetNumberOfConcatenatedTransforms()
Get the total number of transformations that are linked into this one via Concatenate() operations or...
Definition: vtkPerspectiveTransform.h:285
vtkPerspectiveTransform::Identity
void Identity()
Set this transformation to the identity transformation.
Definition: vtkPerspectiveTransform.h:66
vtkPerspectiveTransform::Pop
void Pop()
Deletes the transformation on the top of the stack and sets the top to the next transformation on the...
Definition: vtkPerspectiveTransform.h:367
vtkPerspectiveTransform::Translate
void Translate(double x, double y, double z)
Create a translation matrix and concatenate it with the current transformation according to PreMultip...
Definition: vtkPerspectiveTransform.h:168
vtkPerspectiveTransform::Inverse
void Inverse() override
Invert the transformation.
Definition: vtkPerspectiveTransform.h:77
vtkPerspectiveTransform::RotateX
void RotateX(double angle)
Create a rotation matrix about the X, Y, or Z axis and concatenate it with the current transformation...
Definition: vtkPerspectiveTransform.h:200
vtkPerspectiveTransform::RotateY
void RotateY(double angle)
Create a rotation matrix about the X, Y, or Z axis and concatenate it with the current transformation...
Definition: vtkPerspectiveTransform.h:201
vtkPerspectiveTransform::AdjustViewport
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.
vtkPerspectiveTransform::Concatenate
void Concatenate(const double elements[16])
Concatenates the matrix with the current transformation according to PreMultiply or PostMultiply sema...
Definition: vtkPerspectiveTransform.h:235
vtkPerspectiveTransform::Scale
void Scale(const double s[3])
Create a scale matrix (i.e.
Definition: vtkPerspectiveTransform.h:212
vtkPerspectiveTransform::Push
void Push()
Pushes the current transformation onto the transformation stack.
Definition: vtkPerspectiveTransform.h:351
vtkPerspectiveTransform::SetupCamera
void SetupCamera(double p0, double p1, double p2, double fp0, double fp1, double fp2, double vup0, double vup1, double vup2)
vtkPerspectiveTransform::Translate
void Translate(const double x[3])
Create a translation matrix and concatenate it with the current transformation according to PreMultip...
Definition: vtkPerspectiveTransform.h:169
vtkPerspectiveTransform::SetupCamera
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...
vtkPerspectiveTransform::vtkPerspectiveTransform
vtkPerspectiveTransform()
vtkPerspectiveTransform::InternalDeepCopy
void InternalDeepCopy(vtkAbstractTransform *t) override
Perform any subclass-specific DeepCopy.
vtkPerspectiveTransform::~vtkPerspectiveTransform
~vtkPerspectiveTransform() override
vtkPerspectiveTransform::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkPerspectiveTransform::RotateWXYZ
void RotateWXYZ(double angle, const double axis[3])
Create a rotation matrix and concatenate it with the current transformation according to PreMultiply ...
Definition: vtkPerspectiveTransform.h:184
vtkPerspectiveTransform::Concatenate
void Concatenate(vtkHomogeneousTransform *transform)
Concatenate the specified transform with the current transformation according to PreMultiply or PostM...
vtkPerspectiveTransform::Shear
void Shear(double dxdz, double dydz, double zplane)
Create a shear transformation about a plane at distance z from the camera.
vtkPerspectiveTransform::AdjustZBuffer
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.
vtkPerspectiveTransform::InternalUpdate
void InternalUpdate() override
Perform any subclass-specific Update.
vtkPerspectiveTransform::GetInverseFlag
vtkTypeBool GetInverseFlag()
Get the inverse flag of the transformation.
Definition: vtkPerspectiveTransform.h:345
vtkPerspectiveTransform::RotateWXYZ
void RotateWXYZ(double angle, const float axis[3])
Create a rotation matrix and concatenate it with the current transformation according to PreMultiply ...
Definition: vtkPerspectiveTransform.h:188
vtkPerspectiveTransform::Input
vtkHomogeneousTransform * Input
Definition: vtkPerspectiveTransform.h:406
vtkPerspectiveTransform::Concatenation
vtkTransformConcatenation * Concatenation
Definition: vtkPerspectiveTransform.h:407
vtkPerspectiveTransform::SetMatrix
void SetMatrix(const double elements[16])
Set the current matrix directly.
Definition: vtkPerspectiveTransform.h:222
vtkTransformConcatenationStack
Definition: vtkAbstractTransform.h:455
vtkTransformConcatenationStack::New
static vtkTransformConcatenationStack * New()
Definition: vtkAbstractTransform.h:457
vtkTransformConcatenation
Definition: vtkAbstractTransform.h:349
vtkX3D::position
@ position
Definition: vtkX3D.h:261
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:64
vtkHomogeneousTransform.h
vtkMatrix4x4.h
vtkMTimeType
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:270