VTK  9.1.0
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
55#ifndef vtkTransform_h
56#define vtkTransform_h
57
58#include "vtkCommonTransformsModule.h" // For export macro
59#include "vtkLinearTransform.h"
60
61#include "vtkMatrix4x4.h" // Needed for inline methods
62
63class VTKCOMMONTRANSFORMS_EXPORT vtkTransform : public vtkLinearTransform
64{
65public:
66 static vtkTransform* New();
68 void PrintSelf(ostream& os, vtkIndent indent) override;
69
75 void Identity();
76
82 void Inverse() override;
83
85
89 void Translate(double x, double y, double z) { this->Concatenation->Translate(x, y, z); }
90 void Translate(const double x[3]) { this->Translate(x[0], x[1], x[2]); }
91 void Translate(const float x[3]) { this->Translate(x[0], x[1], x[2]); }
93
95
101 void RotateWXYZ(double angle, double x, double y, double z)
102 {
103 this->Concatenation->Rotate(angle, x, y, z);
104 }
105 void RotateWXYZ(double angle, const double axis[3])
106 {
107 this->RotateWXYZ(angle, axis[0], axis[1], axis[2]);
108 }
109 void RotateWXYZ(double angle, const float axis[3])
110 {
111 this->RotateWXYZ(angle, axis[0], axis[1], axis[2]);
112 }
114
116
121 void RotateX(double angle) { this->RotateWXYZ(angle, 1, 0, 0); }
122 void RotateY(double angle) { this->RotateWXYZ(angle, 0, 1, 0); }
123 void RotateZ(double angle) { this->RotateWXYZ(angle, 0, 0, 1); }
125
127
132 void Scale(double x, double y, double z) { this->Concatenation->Scale(x, y, z); }
133 void Scale(const double s[3]) { this->Scale(s[0], s[1], s[2]); }
134 void Scale(const float s[3]) { this->Scale(s[0], s[1], s[2]); }
136
138
142 void SetMatrix(vtkMatrix4x4* matrix) { this->SetMatrix(*matrix->Element); }
143 void SetMatrix(const double elements[16])
144 {
145 this->Concatenation->Identity();
146 this->Concatenate(elements);
147 }
149
151
155 void Concatenate(vtkMatrix4x4* matrix) { this->Concatenate(*matrix->Element); }
156 void Concatenate(const double elements[16]) { this->Concatenation->Concatenate(elements); }
158
167
176 {
177 if (this->Concatenation->GetPreMultiplyFlag())
178 {
179 return;
180 }
181 this->Concatenation->SetPreMultiplyFlag(1);
182 this->Modified();
183 }
184
193 {
194 if (!this->Concatenation->GetPreMultiplyFlag())
195 {
196 return;
197 }
198 this->Concatenation->SetPreMultiplyFlag(0);
199 this->Modified();
200 }
201
207 {
208 return this->Concatenation->GetNumberOfTransforms() + (this->Input == nullptr ? 0 : 1);
209 }
210
212
220 {
222 if (this->Input == nullptr)
223 {
224 t = this->Concatenation->GetTransform(i);
225 }
226 else if (i < this->Concatenation->GetNumberOfPreTransforms())
227 {
228 t = this->Concatenation->GetTransform(i);
229 }
230 else if (i > this->Concatenation->GetNumberOfPreTransforms())
231 {
232 t = this->Concatenation->GetTransform(i - 1);
233 }
234 else if (this->GetInverseFlag())
235 {
236 t = this->Input->GetInverse();
237 }
238 else
239 {
240 t = this->Input;
241 }
242 return static_cast<vtkLinearTransform*>(t);
243 }
245
247
251 void GetOrientation(double orient[3]);
252 void GetOrientation(float orient[3])
253 {
254 double temp[3];
255 this->GetOrientation(temp);
256 orient[0] = static_cast<float>(temp[0]);
257 orient[1] = static_cast<float>(temp[1]);
258 orient[2] = static_cast<float>(temp[2]);
259 }
261 {
262 this->GetOrientation(this->ReturnValue);
263 return this->ReturnValue;
264 }
266
271 static void GetOrientation(double orient[3], vtkMatrix4x4* matrix);
272
274
278 void GetOrientationWXYZ(double wxyz[4]);
279 void GetOrientationWXYZ(float wxyz[4])
280 {
281 double temp[4];
282 this->GetOrientationWXYZ(temp);
283 wxyz[0] = static_cast<float>(temp[0]);
284 wxyz[1] = static_cast<float>(temp[1]);
285 wxyz[2] = static_cast<float>(temp[2]);
286 wxyz[3] = static_cast<float>(temp[3]);
287 }
289 {
290 this->GetOrientationWXYZ(this->ReturnValue);
291 return this->ReturnValue;
292 }
294
296
301 void GetPosition(double pos[3]);
302 void GetPosition(float pos[3])
303 {
304 double temp[3];
305 this->GetPosition(temp);
306 pos[0] = static_cast<float>(temp[0]);
307 pos[1] = static_cast<float>(temp[1]);
308 pos[2] = static_cast<float>(temp[2]);
309 }
311 {
312 this->GetPosition(this->ReturnValue);
313 return this->ReturnValue;
314 }
316
318
324 void GetScale(double scale[3]);
325 void GetScale(float scale[3])
326 {
327 double temp[3];
328 this->GetScale(temp);
329 scale[0] = static_cast<float>(temp[0]);
330 scale[1] = static_cast<float>(temp[1]);
331 scale[2] = static_cast<float>(temp[2]);
332 }
334 {
335 this->GetScale(this->ReturnValue);
336 return this->ReturnValue;
337 }
339
344 void GetInverse(vtkMatrix4x4* inverse);
345
351 void GetTranspose(vtkMatrix4x4* transpose);
352
354
363 vtkLinearTransform* GetInput() { return this->Input; }
365
373 int GetInverseFlag() { return this->Concatenation->GetInverseFlag(); }
374
376
379 void Push()
380 {
381 if (this->Stack == nullptr)
382 {
384 }
385 this->Stack->Push(&this->Concatenation);
386 this->Modified();
387 }
389
391
395 void Pop()
396 {
397 if (this->Stack == nullptr)
398 {
399 return;
400 }
401 this->Stack->Pop(&this->Concatenation);
402 this->Modified();
403 }
405
414 int CircuitCheck(vtkAbstractTransform* transform) override;
415
416 // Return an inverse transform which will always update itself
417 // to match this transform.
419
424
429
431
436 void MultiplyPoint(const float in[4], float out[4]) { this->GetMatrix()->MultiplyPoint(in, out); }
437 void MultiplyPoint(const double in[4], double out[4])
438 {
439 this->GetMatrix()->MultiplyPoint(in, out);
440 }
442
443protected:
445 ~vtkTransform() override;
446
448
449 void InternalUpdate() override;
450
454
455 // this allows us to check whether people have been fooling
456 // around with our matrix
458
459 float Point[4];
460 double DoublePoint[4];
461 double ReturnValue[4];
462
463private:
464 vtkTransform(const vtkTransform&) = delete;
465 void operator=(const vtkTransform&) = delete;
466};
467
468#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:43
abstract superclass for linear transformations
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:45
void MultiplyPoint(const float in[4], float out[4])
Multiply a homogeneous coordinate by this matrix, i.e.
Definition: vtkMatrix4x4.h:145
double Element[4][4]
The internal data is public for historical reasons. Do not use!
Definition: vtkMatrix4x4.h:48
virtual void Modified()
Update the modification time for this object.
static vtkTransformConcatenationStack * New()
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:64
void Push()
Pushes the current transformation onto the transformation stack.
Definition: vtkTransform.h:379
vtkTransformConcatenation * Concatenation
Definition: vtkTransform.h:452
void RotateZ(double angle)
Create a rotation matrix about the X, Y, or Z axis and concatenate it with the current transformation...
Definition: vtkTransform.h:123
vtkLinearTransform * Input
Definition: vtkTransform.h:451
void GetScale(float scale[3])
Return the scale factors of the current transformation matrix as an array of three float numbers.
Definition: vtkTransform.h:325
~vtkTransform() override
vtkMTimeType MatrixUpdateMTime
Definition: vtkTransform.h:457
void MultiplyPoint(const float in[4], float out[4])
Use this method only if you wish to compute the transformation in homogeneous (x,y,...
Definition: vtkTransform.h:436
void GetOrientation(float orient[3])
Get the x, y, z orientation angles from the transformation matrix as an array of three floating point...
Definition: vtkTransform.h:252
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...
Definition: vtkTransform.h:206
void Concatenate(const double elements[16])
Concatenates the matrix with the current transformation according to PreMultiply or PostMultiply sema...
Definition: vtkTransform.h:156
void PreMultiply()
Sets the internal state of the transform to PreMultiply.
Definition: vtkTransform.h:175
void RotateWXYZ(double angle, const float axis[3])
Create a rotation matrix and concatenate it with the current transformation according to PreMultiply ...
Definition: vtkTransform.h:109
void RotateY(double angle)
Create a rotation matrix about the X, Y, or Z axis and concatenate it with the current transformation...
Definition: vtkTransform.h:122
vtkAbstractTransform * MakeTransform() override
Make a new transform of the same type.
int GetInverseFlag()
Get the inverse flag of the transformation.
Definition: vtkTransform.h:373
double * GetScale()
Return the scale factors of the current transformation matrix as an array of three float numbers.
Definition: vtkTransform.h:333
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.
Definition: vtkTransform.h:288
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.
Definition: vtkTransform.h:133
vtkLinearTransform * GetConcatenatedTransform(int i)
Get one of the concatenated transformations as a vtkAbstractTransform.
Definition: vtkTransform.h:219
vtkTransformConcatenationStack * Stack
Definition: vtkTransform.h:453
vtkLinearTransform * GetInput()
Set the input for this transformation.
Definition: vtkTransform.h:363
void GetPosition(float pos[3])
Return the position from the current transformation matrix as an array of three floating point number...
Definition: vtkTransform.h:302
void Scale(const float s[3])
Create a scale matrix (i.e.
Definition: vtkTransform.h:134
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...
Definition: vtkTransform.h:155
vtkAbstractTransform * GetInverse()
Definition: vtkTransform.h:418
void PostMultiply()
Sets the internal state of the transform to PostMultiply.
Definition: vtkTransform.h:192
void Pop()
Deletes the transformation on the top of the stack and sets the top to the next transformation on the...
Definition: vtkTransform.h:395
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: vtkTransform.h:101
void Scale(double x, double y, double z)
Create a scale matrix (i.e.
Definition: vtkTransform.h:132
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...
Definition: vtkTransform.h:310
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...
Definition: vtkTransform.h:91
double * GetOrientation()
Get the x, y, z orientation angles from the transformation matrix as an array of three floating point...
Definition: vtkTransform.h:260
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...
Definition: vtkTransform.h:90
void RotateX(double angle)
Create a rotation matrix about the X, Y, or Z axis and concatenate it with the current transformation...
Definition: vtkTransform.h:121
void SetMatrix(const double elements[16])
Set the current matrix directly.
Definition: vtkTransform.h:143
void GetOrientationWXYZ(float wxyz[4])
Return the wxyz angle+axis representing the current orientation.
Definition: vtkTransform.h:279
void Translate(double x, double y, double z)
Create a translation matrix and concatenate it with the current transformation according to PreMultip...
Definition: vtkTransform.h:89
void RotateWXYZ(double angle, const double axis[3])
Create a rotation matrix and concatenate it with the current transformation according to PreMultiply ...
Definition: vtkTransform.h:105
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,...
Definition: vtkTransform.h:437
void InternalDeepCopy(vtkAbstractTransform *t) override
Perform any subclass-specific DeepCopy.
void SetMatrix(vtkMatrix4x4 *matrix)
Set the current matrix directly.
Definition: vtkTransform.h:142
@ scale
Definition: vtkX3D.h:235
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:287
#define VTK_SIZEHINT(...)