VTK
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
52#ifndef vtkTransform_h
53#define vtkTransform_h
54
55#include "vtkCommonTransformsModule.h" // For export macro
56#include "vtkLinearTransform.h"
57
58#include "vtkMatrix4x4.h" // Needed for inline methods
59
60class VTKCOMMONTRANSFORMS_EXPORT vtkTransform : public vtkLinearTransform
61{
62 public:
63 static vtkTransform *New();
65 void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
66
72 void Identity();
73
79 void Inverse() VTK_OVERRIDE;
80
82
86 void Translate(double x, double y, double z) {
87 this->Concatenation->Translate(x,y,z); };
88 void Translate(const double x[3]) { this->Translate(x[0], x[1], x[2]); };
89 void Translate(const float x[3]) { this->Translate(x[0], x[1], x[2]); };
91
93
99 void RotateWXYZ(double angle, double x, double y, double z) {
100 this->Concatenation->Rotate(angle,x,y,z); };
101 void RotateWXYZ(double angle, const double axis[3]) {
102 this->RotateWXYZ(angle, axis[0], axis[1], axis[2]); };
103 void RotateWXYZ(double angle, const float axis[3]) {
104 this->RotateWXYZ(angle, axis[0], axis[1], axis[2]); };
106
108
113 void RotateX(double angle) { this->RotateWXYZ(angle, 1, 0, 0); };
114 void RotateY(double angle) { this->RotateWXYZ(angle, 0, 1, 0); };
115 void RotateZ(double angle) { this->RotateWXYZ(angle, 0, 0, 1); };
117
119
124 void Scale(double x, double y, double z) {
125 this->Concatenation->Scale(x,y,z); };
126 void Scale(const double s[3]) { this->Scale(s[0], s[1], s[2]); };
127 void Scale(const float s[3]) { this->Scale(s[0], s[1], s[2]); };
129
131
135 void SetMatrix(vtkMatrix4x4 *matrix) {
136 this->SetMatrix(*matrix->Element); };
137 void SetMatrix(const double elements[16]) {
138 this->Concatenation->Identity(); this->Concatenate(elements); };
140
142
146 void Concatenate(vtkMatrix4x4 *matrix) {
147 this->Concatenate(*matrix->Element); };
148 void Concatenate(const double elements[16]) {
149 this->Concatenation->Concatenate(elements); };
151
160
168 void PreMultiply() {
169 if (this->Concatenation->GetPreMultiplyFlag()) { return; }
170 this->Concatenation->SetPreMultiplyFlag(1); this->Modified(); };
171
180 if (!this->Concatenation->GetPreMultiplyFlag()) { return; }
181 this->Concatenation->SetPreMultiplyFlag(0); this->Modified(); };
182
188 return this->Concatenation->GetNumberOfTransforms() +
189 (this->Input == NULL ? 0 : 1); };
190
192
200 {
202 if (this->Input == NULL)
203 {
204 t=this->Concatenation->GetTransform(i);
205 }
206 else if (i < this->Concatenation->GetNumberOfPreTransforms())
207 {
208 t=this->Concatenation->GetTransform(i);
209 }
210 else if (i > this->Concatenation->GetNumberOfPreTransforms())
211 {
212 t=this->Concatenation->GetTransform(i-1);
213 }
214 else if (this->GetInverseFlag())
215 {
216 t=this->Input->GetInverse();
217 }
218 else
219 {
220 t=this->Input;
221 }
222 return static_cast<vtkLinearTransform *>(t);
223 }
225
227
231 void GetOrientation(double orient[3]);
232 void GetOrientation(float orient[3]) {
233 double temp[3]; this->GetOrientation(temp);
234 orient[0] = static_cast<float>(temp[0]);
235 orient[1] = static_cast<float>(temp[1]);
236 orient[2] = static_cast<float>(temp[2]); };
237 double *GetOrientation() {
238 this->GetOrientation(this->ReturnValue); return this->ReturnValue; };
240
245 static void GetOrientation(double orient[3], vtkMatrix4x4 *matrix);
246
248
252 void GetOrientationWXYZ(double wxyz[4]);
253 void GetOrientationWXYZ(float wxyz[4]) {
254 double temp[4]; this->GetOrientationWXYZ(temp);
255 wxyz[0]=static_cast<float>(temp[0]);
256 wxyz[1]=static_cast<float>(temp[1]);
257 wxyz[2]=static_cast<float>(temp[2]);
258 wxyz[3]=static_cast<float>(temp[3]);};
260 this->GetOrientationWXYZ(this->ReturnValue); return this->ReturnValue; };
262
264
269 void GetPosition(double pos[3]);
270 void GetPosition(float pos[3]) {
271 double temp[3]; this->GetPosition(temp);
272 pos[0] = static_cast<float>(temp[0]);
273 pos[1] = static_cast<float>(temp[1]);
274 pos[2] = static_cast<float>(temp[2]); };
275 double *GetPosition() {
276 this->GetPosition(this->ReturnValue); return this->ReturnValue; };
278
280
286 void GetScale(double scale[3]);
287 void GetScale(float scale[3]) {
288 double temp[3]; this->GetScale(temp);
289 scale[0] = static_cast<float>(temp[0]);
290 scale[1] = static_cast<float>(temp[1]);
291 scale[2] = static_cast<float>(temp[2]); };
292 double *GetScale() {
293 this->GetScale(this->ReturnValue); return this->ReturnValue; };
295
300 void GetInverse(vtkMatrix4x4 *inverse);
301
307 void GetTranspose(vtkMatrix4x4 *transpose);
308
310
319 vtkLinearTransform *GetInput() { return this->Input; };
321
330 return this->Concatenation->GetInverseFlag(); };
331
333
336 void Push() { if (this->Stack == NULL) {
337 this->Stack = vtkTransformConcatenationStack::New(); }
338 this->Stack->Push(&this->Concatenation);
339 this->Modified(); };
341
343
347 void Pop() { if (this->Stack == NULL) { return; }
348 this->Stack->Pop(&this->Concatenation);
349 this->Modified(); };
351
360 int CircuitCheck(vtkAbstractTransform *transform) VTK_OVERRIDE;
361
362 // Return an inverse transform which will always update itself
363 // to match this transform.
366
371
375 vtkMTimeType GetMTime() VTK_OVERRIDE;
376
378
383 void MultiplyPoint(const float in[4], float out[4]) {
384 this->GetMatrix()->MultiplyPoint(in,out);};
385 void MultiplyPoint(const double in[4], double out[4]) {
386 this->GetMatrix()->MultiplyPoint(in,out);};
388
389protected:
391 ~vtkTransform () VTK_OVERRIDE;
392
393 void InternalDeepCopy(vtkAbstractTransform *t) VTK_OVERRIDE;
394
395 void InternalUpdate() VTK_OVERRIDE;
396
400
401 // this allows us to check whether people have been fooling
402 // around with our matrix
403 vtkMTimeType MatrixUpdateMTime;
404
405 float Point[4];
406 double DoublePoint[4];
407 double ReturnValue[4];
408private:
409 vtkTransform (const vtkTransform&) VTK_DELETE_FUNCTION;
410 void operator=(const vtkTransform&) VTK_DELETE_FUNCTION;
411};
412
413#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:40
abstract superclass for linear transformations
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:42
void MultiplyPoint(const float in[4], float out[4])
Multiply a homogeneous coordinate by this matrix, i.e.
Definition: vtkMatrix4x4.h:119
double Element[4][4]
The internal data is public for historical reasons. Do not use!
Definition: vtkMatrix4x4.h:45
virtual void Modified()
Update the modification time for this object.
static vtkTransformConcatenationStack * New()
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:61
void Push()
Pushes the current transformation onto the transformation stack.
Definition: vtkTransform.h:336
void RotateZ(double angle)
Definition: vtkTransform.h:115
void GetScale(float scale[3])
Definition: vtkTransform.h:287
~vtkTransform() override
void GetOrientation(float orient[3])
Definition: vtkTransform.h:232
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:187
void Concatenate(const double elements[16])
Definition: vtkTransform.h:148
void PreMultiply()
Sets the internal state of the transform to PreMultiply.
Definition: vtkTransform.h:168
void RotateWXYZ(double angle, const float axis[3])
Definition: vtkTransform.h:103
void RotateY(double angle)
Definition: vtkTransform.h:114
vtkAbstractTransform * MakeTransform() override
Make a new transform of the same type.
int GetInverseFlag()
Get the inverse flag of the transformation.
Definition: vtkTransform.h:329
double * GetScale()
Definition: vtkTransform.h:292
void GetInverse(vtkMatrix4x4 *inverse)
Return a matrix which is the inverse of the current transformation matrix.
double * GetOrientationWXYZ()
Definition: vtkTransform.h:259
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])
Definition: vtkTransform.h:126
vtkLinearTransform * GetConcatenatedTransform(int i)
Get one of the concatenated transformations as a vtkAbstractTransform.
Definition: vtkTransform.h:199
vtkLinearTransform * GetInput()
Definition: vtkTransform.h:319
void GetPosition(float pos[3])
Definition: vtkTransform.h:270
void Scale(const float s[3])
Definition: vtkTransform.h:127
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...
void Concatenate(vtkMatrix4x4 *matrix)
Concatenates the matrix with the current transformation according to PreMultiply or PostMultiply sema...
Definition: vtkTransform.h:146
vtkAbstractTransform * GetInverse()
Definition: vtkTransform.h:364
void PostMultiply()
Sets the internal state of the transform to PostMultiply.
Definition: vtkTransform.h:179
void Pop()
Deletes the transformation on the top of the stack and sets the top to the next transformation on the...
Definition: vtkTransform.h:347
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:99
void Scale(double x, double y, double z)
Create a scale matrix (i.e.
Definition: vtkTransform.h:124
void GetOrientationWXYZ(double wxyz[4])
Return the wxyz angle+axis representing the current orientation.
double * GetPosition()
Definition: vtkTransform.h:275
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])
Definition: vtkTransform.h:89
double * GetOrientation()
Definition: vtkTransform.h:237
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])
Definition: vtkTransform.h:88
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:113
void SetMatrix(const double elements[16])
Definition: vtkTransform.h:137
void GetOrientationWXYZ(float wxyz[4])
Definition: vtkTransform.h:253
void RotateWXYZ(double angle, const double axis[3])
Definition: vtkTransform.h:101
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.
static vtkTransform * New()
void MultiplyPoint(const double in[4], double out[4])
Definition: vtkTransform.h:385
void SetMatrix(vtkMatrix4x4 *matrix)
Set the current matrix directly.
Definition: vtkTransform.h:135
@ scale
Definition: vtkX3D.h:229
vtkTypeUInt64 vtkMTimeType
Definition: vtkType.h:248