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 
60 class VTKCOMMONTRANSFORMS_EXPORT vtkTransform : public vtkLinearTransform
61 {
62  public:
63  static vtkTransform *New();
65  void PrintSelf(ostream& os, vtkIndent indent) override;
66 
72  void Identity();
73 
79  void Inverse() 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 
159  void Concatenate(vtkLinearTransform *transform);
160 
168  void PreMultiply() {
169  if (this->Concatenation->GetPreMultiplyFlag()) { return; }
170  this->Concatenation->SetPreMultiplyFlag(1); this->Modified(); };
171 
179  void PostMultiply() {
180  if (!this->Concatenation->GetPreMultiplyFlag()) { return; }
181  this->Concatenation->SetPreMultiplyFlag(0); this->Modified(); };
182 
188  return this->Concatenation->GetNumberOfTransforms() +
189  (this->Input == nullptr ? 0 : 1); };
190 
192 
200  {
202  if (this->Input == nullptr)
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]); };
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() VTK_SIZEHINT(3) {
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() VTK_SIZEHINT(3) {
293  this->GetScale(this->ReturnValue); return this->ReturnValue; };
295 
300  void GetInverse(vtkMatrix4x4 *inverse);
301 
307  void GetTranspose(vtkMatrix4x4 *transpose);
308 
310 
318  void SetInput(vtkLinearTransform *input);
319  vtkLinearTransform *GetInput() { return this->Input; };
321 
330  return this->Concatenation->GetInverseFlag(); };
331 
333 
336  void Push() { if (this->Stack == nullptr) {
337  this->Stack = vtkTransformConcatenationStack::New(); }
338  this->Stack->Push(&this->Concatenation);
339  this->Modified(); };
341 
343 
347  void Pop() { if (this->Stack == nullptr) { return; }
348  this->Stack->Pop(&this->Concatenation);
349  this->Modified(); };
351 
360  int CircuitCheck(vtkAbstractTransform *transform) override;
361 
362  // Return an inverse transform which will always update itself
363  // to match this transform.
366 
371 
375  vtkMTimeType GetMTime() 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 
389 protected:
390  vtkTransform ();
391  ~vtkTransform () override;
392 
393  void InternalDeepCopy(vtkAbstractTransform *t) override;
394 
395  void InternalUpdate() override;
396 
400 
401  // this allows us to check whether people have been fooling
402  // around with our matrix
404 
405  float Point[4];
406  double DoublePoint[4];
407  double ReturnValue[4];
408 private:
409  vtkTransform (const vtkTransform&) = delete;
410  void operator=(const vtkTransform&) = delete;
411 };
412 
413 #endif
double * GetOrientationWXYZ()
Return the wxyz angle+axis representing the current orientation.
Definition: vtkTransform.h:259
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 PreMultiply()
Sets the internal state of the transform to PreMultiply.
Definition: vtkTransform.h:168
double * GetScale()
Return the scale factors of the current transformation matrix as an array of three float numbers...
Definition: vtkTransform.h:292
void Concatenate(const double elements[16])
Concatenates the matrix with the current transformation according to PreMultiply or PostMultiply sema...
Definition: vtkTransform.h:148
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void PostMultiply()
Sets the internal state of the transform to PostMultiply.
Definition: vtkTransform.h:179
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:41
void Push()
Pushes the current transformation onto the transformation stack.
Definition: vtkTransform.h:336
vtkMTimeType GetMTime() override
Override GetMTime necessary because of inverse transforms.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:302
double * GetPosition()
Return the position from the current transformation matrix as an array of three floating point number...
Definition: vtkTransform.h:275
void SetMatrix(vtkMatrix4x4 *matrix)
Set the current matrix directly.
Definition: vtkTransform.h:135
virtual void InternalUpdate()
Perform any subclass-specific Update.
double * GetOrientation()
Get the x, y, z orientation angles from the transformation matrix as an array of three floating point...
Definition: vtkTransform.h:237
void Scale(const float s[3])
Create a scale matrix (i.e.
Definition: vtkTransform.h:127
virtual vtkAbstractTransform * MakeTransform()=0
Make another transform of the same type.
vtkMTimeType MatrixUpdateMTime
Definition: vtkTransform.h:403
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:60
vtkAbstractTransform * GetInverse()
Get the inverse of this transform.
void Scale(double x, double y, double z)
Create a scale matrix (i.e.
Definition: vtkTransform.h:124
void MultiplyPoint(const float in[4], float out[4])
Multiply a homogeneous coordinate by this matrix, i.e.
Definition: vtkMatrix4x4.h:119
void Concatenate(vtkMatrix4x4 *matrix)
Concatenates the matrix with the current transformation according to PreMultiply or PostMultiply sema...
Definition: vtkTransform.h:146
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:101
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:114
void GetPosition(float pos[3])
Return the position from the current transformation matrix as an array of three floating point number...
Definition: vtkTransform.h:270
virtual int CircuitCheck(vtkAbstractTransform *transform)
Check for self-reference.
vtkLinearTransform * GetInput()
Set the input for this transformation.
Definition: vtkTransform.h:319
int GetNumberOfConcatenatedTransforms()
Get the total number of transformations that are linked into this one via Concatenate() operations or...
Definition: vtkTransform.h:187
a simple class to control print indentation
Definition: vtkIndent.h:39
void GetScale(float scale[3])
Return the scale factors of the current transformation matrix as an array of three float numbers...
Definition: vtkTransform.h:287
superclass for all geometric transformations
virtual void Modified()
Update the modification time for this object.
virtual void Inverse()=0
Invert the transformation.
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:103
#define VTK_SIZEHINT(...)
void Translate(const double x[3])
Create a translation matrix and concatenate it with the current transformation according to PreMultip...
Definition: vtkTransform.h:88
void MultiplyPoint(const float in[4], float out[4])
Use this method only if you wish to compute the transformation in homogeneous (x,y,z,w) coordinates, otherwise use TransformPoint().
Definition: vtkTransform.h:383
void Scale(const double s[3])
Create a scale matrix (i.e.
Definition: vtkTransform.h:126
void SetMatrix(const double elements[16])
Set the current matrix directly.
Definition: vtkTransform.h:137
void InternalDeepCopy(vtkAbstractTransform *transform) override
Perform any subclass-specific DeepCopy.
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:232
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 MultiplyPoint(const double in[4], double out[4])
Use this method only if you wish to compute the transformation in homogeneous (x,y,z,w) coordinates, otherwise use TransformPoint().
Definition: vtkTransform.h:385
double Element[4][4]
The internal data is public for historical reasons. Do not use!
Definition: vtkMatrix4x4.h:45
vtkLinearTransform * GetConcatenatedTransform(int i)
Get one of the concatenated transformations as a vtkAbstractTransform.
Definition: vtkTransform.h:199
vtkTransformConcatenationStack * Stack
Definition: vtkTransform.h:399
vtkTransformConcatenation * Concatenation
Definition: vtkTransform.h:398
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:86
int GetInverseFlag()
Get the inverse flag of the transformation.
Definition: vtkTransform.h:329
void GetOrientationWXYZ(float wxyz[4])
Return the wxyz angle+axis representing the current orientation.
Definition: vtkTransform.h:253
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
static vtkTransformConcatenationStack * New()
vtkMatrix4x4 * GetMatrix()
Get a pointer to an internal vtkMatrix4x4 that represents the transformation.
void Translate(const float x[3])
Create a translation matrix and concatenate it with the current transformation according to PreMultip...
Definition: vtkTransform.h:89
vtkAbstractTransform * GetInverse()
Definition: vtkTransform.h:364
abstract superclass for linear transformations
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:115
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
vtkLinearTransform * Input
Definition: vtkTransform.h:397