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
46#ifndef vtkTransform_h
47#define vtkTransform_h
48
49#include "vtkCommonTransformsModule.h" // For export macro
50#include "vtkLinearTransform.h"
51
52#include "vtkMatrix4x4.h" // Needed for inline methods
53
54class VTKCOMMONTRANSFORMS_EXPORT vtkTransform : public vtkLinearTransform
55{
56public:
57 static vtkTransform* New();
59 void PrintSelf(ostream& os, vtkIndent indent) override;
60
66 void Identity();
67
73 void Inverse() override;
74
76
80 void Translate(double x, double y, double z) { this->Concatenation->Translate(x, y, z); }
81 void Translate(const double x[3]) { this->Translate(x[0], x[1], x[2]); }
82 void Translate(const float x[3]) { this->Translate(x[0], x[1], x[2]); }
84
86
92 void RotateWXYZ(double angle, double x, double y, double z)
93 {
94 this->Concatenation->Rotate(angle, x, y, z);
95 }
96 void RotateWXYZ(double angle, const double axis[3])
97 {
98 this->RotateWXYZ(angle, axis[0], axis[1], axis[2]);
99 }
100 void RotateWXYZ(double angle, const float axis[3])
101 {
102 this->RotateWXYZ(angle, axis[0], axis[1], axis[2]);
103 }
105
107
112 void RotateX(double angle) { this->RotateWXYZ(angle, 1, 0, 0); }
113 void RotateY(double angle) { this->RotateWXYZ(angle, 0, 1, 0); }
114 void RotateZ(double angle) { this->RotateWXYZ(angle, 0, 0, 1); }
116
118
123 void Scale(double x, double y, double z) { this->Concatenation->Scale(x, y, z); }
124 void Scale(const double s[3]) { this->Scale(s[0], s[1], s[2]); }
125 void Scale(const float s[3]) { this->Scale(s[0], s[1], s[2]); }
127
129
133 void SetMatrix(vtkMatrix4x4* matrix) { this->SetMatrix(*matrix->Element); }
134 void SetMatrix(const double elements[16])
135 {
136 this->Concatenation->Identity();
137 this->Concatenate(elements);
138 }
140
142
146 void Concatenate(vtkMatrix4x4* matrix) { this->Concatenate(*matrix->Element); }
147 void Concatenate(const double elements[16]) { this->Concatenation->Concatenate(elements); }
149
158
167 {
168 if (this->Concatenation->GetPreMultiplyFlag())
169 {
170 return;
171 }
172 this->Concatenation->SetPreMultiplyFlag(1);
173 this->Modified();
174 }
175
184 {
185 if (!this->Concatenation->GetPreMultiplyFlag())
186 {
187 return;
188 }
189 this->Concatenation->SetPreMultiplyFlag(0);
190 this->Modified();
191 }
192
198 {
199 return this->Concatenation->GetNumberOfTransforms() + (this->Input == nullptr ? 0 : 1);
200 }
201
203
211 {
213 if (this->Input == nullptr)
214 {
215 t = this->Concatenation->GetTransform(i);
216 }
217 else if (i < this->Concatenation->GetNumberOfPreTransforms())
218 {
219 t = this->Concatenation->GetTransform(i);
220 }
221 else if (i > this->Concatenation->GetNumberOfPreTransforms())
222 {
223 t = this->Concatenation->GetTransform(i - 1);
224 }
225 else if (this->GetInverseFlag())
226 {
227 t = this->Input->GetInverse();
228 }
229 else
230 {
231 t = this->Input;
232 }
233 return static_cast<vtkLinearTransform*>(t);
234 }
236
238
242 void GetOrientation(double orient[3]);
243 void GetOrientation(float orient[3])
244 {
245 double temp[3];
246 this->GetOrientation(temp);
247 orient[0] = static_cast<float>(temp[0]);
248 orient[1] = static_cast<float>(temp[1]);
249 orient[2] = static_cast<float>(temp[2]);
250 }
252 {
253 this->GetOrientation(this->ReturnValue);
254 return this->ReturnValue;
255 }
257
262 static void GetOrientation(double orient[3], vtkMatrix4x4* matrix);
263
265
269 void GetOrientationWXYZ(double wxyz[4]);
270 void GetOrientationWXYZ(float wxyz[4])
271 {
272 double temp[4];
273 this->GetOrientationWXYZ(temp);
274 wxyz[0] = static_cast<float>(temp[0]);
275 wxyz[1] = static_cast<float>(temp[1]);
276 wxyz[2] = static_cast<float>(temp[2]);
277 wxyz[3] = static_cast<float>(temp[3]);
278 }
280 {
281 this->GetOrientationWXYZ(this->ReturnValue);
282 return this->ReturnValue;
283 }
285
287
292 void GetPosition(double pos[3]);
293 void GetPosition(float pos[3])
294 {
295 double temp[3];
296 this->GetPosition(temp);
297 pos[0] = static_cast<float>(temp[0]);
298 pos[1] = static_cast<float>(temp[1]);
299 pos[2] = static_cast<float>(temp[2]);
300 }
302 {
303 this->GetPosition(this->ReturnValue);
304 return this->ReturnValue;
305 }
307
309
315 void GetScale(double scale[3]);
316 void GetScale(float scale[3])
317 {
318 double temp[3];
319 this->GetScale(temp);
320 scale[0] = static_cast<float>(temp[0]);
321 scale[1] = static_cast<float>(temp[1]);
322 scale[2] = static_cast<float>(temp[2]);
323 }
325 {
326 this->GetScale(this->ReturnValue);
327 return this->ReturnValue;
328 }
330
335 void GetInverse(vtkMatrix4x4* inverse);
336
342 void GetTranspose(vtkMatrix4x4* transpose);
343
345
354 vtkLinearTransform* GetInput() { return this->Input; }
356
364 int GetInverseFlag() { return this->Concatenation->GetInverseFlag(); }
365
367
370 void Push()
371 {
372 if (this->Stack == nullptr)
373 {
375 }
376 this->Stack->Push(&this->Concatenation);
377 this->Modified();
378 }
380
382
386 void Pop()
387 {
388 if (this->Stack == nullptr)
389 {
390 return;
391 }
392 this->Stack->Pop(&this->Concatenation);
393 this->Modified();
394 }
396
405 int CircuitCheck(vtkAbstractTransform* transform) override;
406
407 // Return an inverse transform which will always update itself
408 // to match this transform.
410
415
420
422
427 void MultiplyPoint(const float in[4], float out[4]) { this->GetMatrix()->MultiplyPoint(in, out); }
428 void MultiplyPoint(const double in[4], double out[4])
429 {
430 this->GetMatrix()->MultiplyPoint(in, out);
431 }
433
434protected:
436 ~vtkTransform() override;
437
439
440 void InternalUpdate() override;
441
445
446 // this allows us to check whether people have been fooling
447 // around with our matrix
449
450 float Point[4];
451 double DoublePoint[4];
452 double ReturnValue[4];
453
454private:
455 vtkTransform(const vtkTransform&) = delete;
456 void operator=(const vtkTransform&) = delete;
457};
458
459#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:34
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(...)