VTK  9.2.6
vtkTransform.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkTransform.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
61#ifndef vtkTransform_h
62#define vtkTransform_h
63
64#include "vtkCommonTransformsModule.h" // For export macro
65#include "vtkLinearTransform.h"
66
67#include "vtkMatrix4x4.h" // Needed for inline methods
68
69class VTKCOMMONTRANSFORMS_EXPORT vtkTransform : public vtkLinearTransform
70{
71public:
72 static vtkTransform* New();
74 void PrintSelf(ostream& os, vtkIndent indent) override;
75
81 void Identity();
82
88 void Inverse() override;
89
91
95 void Translate(double x, double y, double z) { this->Concatenation->Translate(x, y, z); }
96 void Translate(const double x[3]) { this->Translate(x[0], x[1], x[2]); }
97 void Translate(const float x[3]) { this->Translate(x[0], x[1], x[2]); }
99
101
107 void RotateWXYZ(double angle, double x, double y, double z)
108 {
109 this->Concatenation->Rotate(angle, x, y, z);
110 }
111 void RotateWXYZ(double angle, const double axis[3])
112 {
113 this->RotateWXYZ(angle, axis[0], axis[1], axis[2]);
114 }
115 void RotateWXYZ(double angle, const float axis[3])
116 {
117 this->RotateWXYZ(angle, axis[0], axis[1], axis[2]);
118 }
120
122
127 void RotateX(double angle) { this->RotateWXYZ(angle, 1, 0, 0); }
128 void RotateY(double angle) { this->RotateWXYZ(angle, 0, 1, 0); }
129 void RotateZ(double angle) { this->RotateWXYZ(angle, 0, 0, 1); }
131
133
138 void Scale(double x, double y, double z) { this->Concatenation->Scale(x, y, z); }
139 void Scale(const double s[3]) { this->Scale(s[0], s[1], s[2]); }
140 void Scale(const float s[3]) { this->Scale(s[0], s[1], s[2]); }
142
144
148 void SetMatrix(vtkMatrix4x4* matrix) { this->SetMatrix(*matrix->Element); }
149 void SetMatrix(const double elements[16])
150 {
151 this->Concatenation->Identity();
152 this->Concatenate(elements);
153 }
155
157
161 void Concatenate(vtkMatrix4x4* matrix) { this->Concatenate(*matrix->Element); }
162 void Concatenate(const double elements[16]) { this->Concatenation->Concatenate(elements); }
164
173
182 {
183 if (this->Concatenation->GetPreMultiplyFlag())
184 {
185 return;
186 }
187 this->Concatenation->SetPreMultiplyFlag(1);
188 this->Modified();
189 }
190
199 {
200 if (!this->Concatenation->GetPreMultiplyFlag())
201 {
202 return;
203 }
204 this->Concatenation->SetPreMultiplyFlag(0);
205 this->Modified();
206 }
207
213 {
214 return this->Concatenation->GetNumberOfTransforms() + (this->Input == nullptr ? 0 : 1);
215 }
216
218
226 {
228 if (this->Input == nullptr)
229 {
230 t = this->Concatenation->GetTransform(i);
231 }
232 else if (i < this->Concatenation->GetNumberOfPreTransforms())
233 {
234 t = this->Concatenation->GetTransform(i);
235 }
236 else if (i > this->Concatenation->GetNumberOfPreTransforms())
237 {
238 t = this->Concatenation->GetTransform(i - 1);
239 }
240 else if (this->GetInverseFlag())
241 {
242 t = this->Input->GetInverse();
243 }
244 else
245 {
246 t = this->Input;
247 }
248 return static_cast<vtkLinearTransform*>(t);
249 }
251
253
257 void GetOrientation(double orient[3]);
258 void GetOrientation(float orient[3])
259 {
260 double temp[3];
261 this->GetOrientation(temp);
262 orient[0] = static_cast<float>(temp[0]);
263 orient[1] = static_cast<float>(temp[1]);
264 orient[2] = static_cast<float>(temp[2]);
265 }
267 {
268 this->GetOrientation(this->ReturnValue);
269 return this->ReturnValue;
270 }
272
277 static void GetOrientation(double orient[3], vtkMatrix4x4* matrix);
278
280
284 void GetOrientationWXYZ(double wxyz[4]);
285 void GetOrientationWXYZ(float wxyz[4])
286 {
287 double temp[4];
288 this->GetOrientationWXYZ(temp);
289 wxyz[0] = static_cast<float>(temp[0]);
290 wxyz[1] = static_cast<float>(temp[1]);
291 wxyz[2] = static_cast<float>(temp[2]);
292 wxyz[3] = static_cast<float>(temp[3]);
293 }
295 {
296 this->GetOrientationWXYZ(this->ReturnValue);
297 return this->ReturnValue;
298 }
300
302
307 void GetPosition(double pos[3]);
308 void GetPosition(float pos[3])
309 {
310 double temp[3];
311 this->GetPosition(temp);
312 pos[0] = static_cast<float>(temp[0]);
313 pos[1] = static_cast<float>(temp[1]);
314 pos[2] = static_cast<float>(temp[2]);
315 }
317 {
318 this->GetPosition(this->ReturnValue);
319 return this->ReturnValue;
320 }
322
324
330 void GetScale(double scale[3]);
331 void GetScale(float scale[3])
332 {
333 double temp[3];
334 this->GetScale(temp);
335 scale[0] = static_cast<float>(temp[0]);
336 scale[1] = static_cast<float>(temp[1]);
337 scale[2] = static_cast<float>(temp[2]);
338 }
340 {
341 this->GetScale(this->ReturnValue);
342 return this->ReturnValue;
343 }
345
350 void GetInverse(vtkMatrix4x4* inverse);
351
357 void GetTranspose(vtkMatrix4x4* transpose);
358
360
369 vtkLinearTransform* GetInput() { return this->Input; }
371
379 int GetInverseFlag() { return this->Concatenation->GetInverseFlag(); }
380
382
385 void Push()
386 {
387 if (this->Stack == nullptr)
388 {
390 }
391 this->Stack->Push(&this->Concatenation);
392 this->Modified();
393 }
395
397
401 void Pop()
402 {
403 if (this->Stack == nullptr)
404 {
405 return;
406 }
407 this->Stack->Pop(&this->Concatenation);
408 this->Modified();
409 }
411
420 int CircuitCheck(vtkAbstractTransform* transform) override;
421
422 // Return an inverse transform which will always update itself
423 // to match this transform.
425
430
435
437
442 void MultiplyPoint(const float in[4], float out[4]) { this->GetMatrix()->MultiplyPoint(in, out); }
443 void MultiplyPoint(const double in[4], double out[4])
444 {
445 this->GetMatrix()->MultiplyPoint(in, out);
446 }
448
449protected:
451 ~vtkTransform() override;
452
454
455 void InternalUpdate() override;
456
460
461 // this allows us to check whether people have been fooling
462 // around with our matrix
464
465 float Point[4];
466 double DoublePoint[4];
467 double ReturnValue[4];
468
469private:
470 vtkTransform(const vtkTransform&) = delete;
471 void operator=(const vtkTransform&) = delete;
472};
473
474#endif
superclass for all geometric transformations
vtkAbstractTransform * GetInverse()
Get the inverse of this transform.
vtkMatrix4x4 * GetMatrix()
Get a pointer to an internal vtkMatrix4x4 that represents the transformation.
a simple class to control print indentation
Definition vtkIndent.h:49
abstract superclass for linear transformations
represent and manipulate 4x4 transformation matrices
void MultiplyPoint(const float in[4], float out[4])
Multiply a homogeneous coordinate by this matrix, i.e.
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.
static vtkTransformConcatenationStack * New()
describes linear transformations via a 4x4 matrix
void Push()
Pushes the current transformation onto the transformation stack.
vtkTransformConcatenation * Concatenation
void RotateZ(double angle)
Create a rotation matrix about the X, Y, or Z axis and concatenate it with the current transformation...
vtkLinearTransform * Input
void GetScale(float scale[3])
Return the scale factors of the current transformation matrix as an array of three float numbers.
~vtkTransform() override
vtkMTimeType MatrixUpdateMTime
void MultiplyPoint(const float in[4], float out[4])
Use this method only if you wish to compute the transformation in homogeneous (x,y,...
void GetOrientation(float orient[3])
Get the x, y, z orientation angles from the transformation matrix as an array of three floating point...
void GetTranspose(vtkMatrix4x4 *transpose)
Return a matrix which is the transpose of the current transformation matrix.
int GetNumberOfConcatenatedTransforms()
Get the total number of transformations that are linked into this one via Concatenate() operations or...
void Concatenate(const double elements[16])
Concatenates the matrix with the current transformation according to PreMultiply or PostMultiply sema...
void PreMultiply()
Sets the internal state of the transform to PreMultiply.
void RotateWXYZ(double angle, const float axis[3])
Create a rotation matrix and concatenate it with the current transformation according to PreMultiply ...
void RotateY(double angle)
Create a rotation matrix about the X, Y, or Z axis and concatenate it with the current transformation...
vtkAbstractTransform * MakeTransform() override
Make a new transform of the same type.
int GetInverseFlag()
Get the inverse flag of the transformation.
double * GetScale()
Return the scale factors of the current transformation matrix as an array of three float numbers.
void GetInverse(vtkMatrix4x4 *inverse)
Return a matrix which is the inverse of the current transformation matrix.
double * GetOrientationWXYZ()
Return the wxyz angle+axis representing the current orientation.
void GetScale(double scale[3])
Return the scale factors of the current transformation matrix as an array of three float numbers.
void Scale(const double s[3])
Create a scale matrix (i.e.
vtkLinearTransform * GetConcatenatedTransform(int i)
Get one of the concatenated transformations as a vtkAbstractTransform.
vtkTransformConcatenationStack * Stack
vtkLinearTransform * GetInput()
Set the input for this transformation.
void GetPosition(float pos[3])
Return the position from the current transformation matrix as an array of three floating point number...
void Scale(const float s[3])
Create a scale matrix (i.e.
int CircuitCheck(vtkAbstractTransform *transform) override
Check for self-reference.
void Inverse() override
Invert the transformation.
void Concatenate(vtkLinearTransform *transform)
Concatenate the specified transform with the current transformation according to PreMultiply or PostM...
static void GetOrientation(double orient[3], vtkMatrix4x4 *matrix)
Convenience function to get the x, y, z orientation angles from a transformation matrix as an array o...
vtkMTimeType GetMTime() override
Override GetMTime to account for input and concatenation.
void Concatenate(vtkMatrix4x4 *matrix)
Concatenates the matrix with the current transformation according to PreMultiply or PostMultiply sema...
vtkAbstractTransform * GetInverse()
void PostMultiply()
Sets the internal state of the transform to PostMultiply.
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 ...
void Scale(double x, double y, double z)
Create a scale matrix (i.e.
void GetOrientationWXYZ(double wxyz[4])
Return the wxyz angle+axis representing the current orientation.
double * GetPosition()
Return the position from the current transformation matrix as an array of three floating point number...
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void Translate(const float x[3])
Create a translation matrix and concatenate it with the current transformation according to PreMultip...
double * GetOrientation()
Get the x, y, z orientation angles from the transformation matrix as an array of three floating point...
void GetPosition(double pos[3])
Return the position from the current transformation matrix as an array of three floating point number...
void Identity()
Set the transformation to the identity transformation.
void Translate(const double x[3])
Create a translation matrix and concatenate it with the current transformation according to PreMultip...
void RotateX(double angle)
Create a rotation matrix about the X, Y, or Z axis and concatenate it with the current transformation...
void SetMatrix(const double elements[16])
Set the current matrix directly.
void GetOrientationWXYZ(float wxyz[4])
Return the wxyz angle+axis representing the current orientation.
void Translate(double x, double y, double z)
Create a translation matrix and concatenate it with the current transformation according to PreMultip...
void RotateWXYZ(double angle, const double axis[3])
Create a rotation matrix and concatenate it with the current transformation according to PreMultiply ...
void GetOrientation(double orient[3])
Get the x, y, z orientation angles from the transformation matrix as an array of three floating point...
void SetInput(vtkLinearTransform *input)
Set the input for this transformation.
void InternalUpdate() override
Perform any subclass-specific Update.
static vtkTransform * New()
void MultiplyPoint(const double in[4], double out[4])
Use this method only if you wish to compute the transformation in homogeneous (x,y,...
void InternalDeepCopy(vtkAbstractTransform *t) override
Perform any subclass-specific DeepCopy.
void SetMatrix(vtkMatrix4x4 *matrix)
Set the current matrix directly.
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:287
#define VTK_SIZEHINT(...)