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 
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 
54 class VTKCOMMONTRANSFORMS_EXPORT vtkTransform : public vtkLinearTransform
55 {
56  public:
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) {
81  this->Concatenation->Translate(x,y,z); };
82  void Translate(const double x[3]) { this->Translate(x[0], x[1], x[2]); };
83  void Translate(const float x[3]) { this->Translate(x[0], x[1], x[2]); };
85 
87 
93  void RotateWXYZ(double angle, double x, double y, double z) {
94  this->Concatenation->Rotate(angle,x,y,z); };
95  void RotateWXYZ(double angle, const double axis[3]) {
96  this->RotateWXYZ(angle, axis[0], axis[1], axis[2]); };
97  void RotateWXYZ(double angle, const float axis[3]) {
98  this->RotateWXYZ(angle, axis[0], axis[1], axis[2]); };
100 
102 
107  void RotateX(double angle) { this->RotateWXYZ(angle, 1, 0, 0); };
108  void RotateY(double angle) { this->RotateWXYZ(angle, 0, 1, 0); };
109  void RotateZ(double angle) { this->RotateWXYZ(angle, 0, 0, 1); };
111 
113 
118  void Scale(double x, double y, double z) {
119  this->Concatenation->Scale(x,y,z); };
120  void Scale(const double s[3]) { this->Scale(s[0], s[1], s[2]); };
121  void Scale(const float s[3]) { this->Scale(s[0], s[1], s[2]); };
123 
125 
129  void SetMatrix(vtkMatrix4x4 *matrix) {
130  this->SetMatrix(*matrix->Element); };
131  void SetMatrix(const double elements[16]) {
132  this->Concatenation->Identity(); this->Concatenate(elements); };
134 
136 
140  void Concatenate(vtkMatrix4x4 *matrix) {
141  this->Concatenate(*matrix->Element); };
142  void Concatenate(const double elements[16]) {
143  this->Concatenation->Concatenate(elements); };
145 
153  void Concatenate(vtkLinearTransform *transform);
154 
162  void PreMultiply() {
163  if (this->Concatenation->GetPreMultiplyFlag()) { return; }
164  this->Concatenation->SetPreMultiplyFlag(1); this->Modified(); };
165 
173  void PostMultiply() {
174  if (!this->Concatenation->GetPreMultiplyFlag()) { return; }
175  this->Concatenation->SetPreMultiplyFlag(0); this->Modified(); };
176 
182  return this->Concatenation->GetNumberOfTransforms() +
183  (this->Input == nullptr ? 0 : 1); };
184 
186 
194  {
196  if (this->Input == nullptr)
197  {
198  t=this->Concatenation->GetTransform(i);
199  }
200  else if (i < this->Concatenation->GetNumberOfPreTransforms())
201  {
202  t=this->Concatenation->GetTransform(i);
203  }
204  else if (i > this->Concatenation->GetNumberOfPreTransforms())
205  {
206  t=this->Concatenation->GetTransform(i-1);
207  }
208  else if (this->GetInverseFlag())
209  {
210  t=this->Input->GetInverse();
211  }
212  else
213  {
214  t=this->Input;
215  }
216  return static_cast<vtkLinearTransform *>(t);
217  }
219 
221 
225  void GetOrientation(double orient[3]);
226  void GetOrientation(float orient[3]) {
227  double temp[3]; this->GetOrientation(temp);
228  orient[0] = static_cast<float>(temp[0]);
229  orient[1] = static_cast<float>(temp[1]);
230  orient[2] = static_cast<float>(temp[2]); };
232  this->GetOrientation(this->ReturnValue); return this->ReturnValue; };
234 
239  static void GetOrientation(double orient[3], vtkMatrix4x4 *matrix);
240 
242 
246  void GetOrientationWXYZ(double wxyz[4]);
247  void GetOrientationWXYZ(float wxyz[4]) {
248  double temp[4]; this->GetOrientationWXYZ(temp);
249  wxyz[0]=static_cast<float>(temp[0]);
250  wxyz[1]=static_cast<float>(temp[1]);
251  wxyz[2]=static_cast<float>(temp[2]);
252  wxyz[3]=static_cast<float>(temp[3]);};
254  this->GetOrientationWXYZ(this->ReturnValue); return this->ReturnValue; };
256 
258 
263  void GetPosition(double pos[3]);
264  void GetPosition(float pos[3]) {
265  double temp[3]; this->GetPosition(temp);
266  pos[0] = static_cast<float>(temp[0]);
267  pos[1] = static_cast<float>(temp[1]);
268  pos[2] = static_cast<float>(temp[2]); };
269  double *GetPosition() VTK_SIZEHINT(3) {
270  this->GetPosition(this->ReturnValue); return this->ReturnValue; };
272 
274 
280  void GetScale(double scale[3]);
281  void GetScale(float scale[3]) {
282  double temp[3]; this->GetScale(temp);
283  scale[0] = static_cast<float>(temp[0]);
284  scale[1] = static_cast<float>(temp[1]);
285  scale[2] = static_cast<float>(temp[2]); };
286  double *GetScale() VTK_SIZEHINT(3) {
287  this->GetScale(this->ReturnValue); return this->ReturnValue; };
289 
294  void GetInverse(vtkMatrix4x4 *inverse);
295 
301  void GetTranspose(vtkMatrix4x4 *transpose);
302 
304 
312  void SetInput(vtkLinearTransform *input);
313  vtkLinearTransform *GetInput() { return this->Input; };
315 
324  return this->Concatenation->GetInverseFlag(); };
325 
327 
330  void Push() { if (this->Stack == nullptr) {
331  this->Stack = vtkTransformConcatenationStack::New(); }
332  this->Stack->Push(&this->Concatenation);
333  this->Modified(); };
335 
337 
341  void Pop() { if (this->Stack == nullptr) { return; }
342  this->Stack->Pop(&this->Concatenation);
343  this->Modified(); };
345 
354  int CircuitCheck(vtkAbstractTransform *transform) override;
355 
356  // Return an inverse transform which will always update itself
357  // to match this transform.
360 
365 
369  vtkMTimeType GetMTime() override;
370 
372 
377  void MultiplyPoint(const float in[4], float out[4]) {
378  this->GetMatrix()->MultiplyPoint(in,out);};
379  void MultiplyPoint(const double in[4], double out[4]) {
380  this->GetMatrix()->MultiplyPoint(in,out);};
382 
383 protected:
384  vtkTransform ();
385  ~vtkTransform () override;
386 
387  void InternalDeepCopy(vtkAbstractTransform *t) override;
388 
389  void InternalUpdate() override;
390 
394 
395  // this allows us to check whether people have been fooling
396  // around with our matrix
398 
399  float Point[4];
400  double DoublePoint[4];
401  double ReturnValue[4];
402 private:
403  vtkTransform (const vtkTransform&) = delete;
404  void operator=(const vtkTransform&) = delete;
405 };
406 
407 #endif
double * GetOrientationWXYZ()
Return the wxyz angle+axis representing the current orientation.
Definition: vtkTransform.h:253
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:93
void PreMultiply()
Sets the internal state of the transform to PreMultiply.
Definition: vtkTransform.h:162
double * GetScale()
Return the scale factors of the current transformation matrix as an array of three float numbers.
Definition: vtkTransform.h:286
void Concatenate(const double elements[16])
Concatenates the matrix with the current transformation according to PreMultiply or PostMultiply sema...
Definition: vtkTransform.h:142
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:173
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:35
void Push()
Pushes the current transformation onto the transformation stack.
Definition: vtkTransform.h:330
vtkMTimeType GetMTime() override
Override GetMTime necessary because of inverse transforms.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:300
double * GetPosition()
Return the position from the current transformation matrix as an array of three floating point number...
Definition: vtkTransform.h:269
void SetMatrix(vtkMatrix4x4 *matrix)
Set the current matrix directly.
Definition: vtkTransform.h:129
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:231
void Scale(const float s[3])
Create a scale matrix (i.e.
Definition: vtkTransform.h:121
virtual vtkAbstractTransform * MakeTransform()=0
Make another transform of the same type.
vtkMTimeType MatrixUpdateMTime
Definition: vtkTransform.h:397
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:54
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:118
void MultiplyPoint(const float in[4], float out[4])
Multiply a homogeneous coordinate by this matrix, i.e.
Definition: vtkMatrix4x4.h:113
void Concatenate(vtkMatrix4x4 *matrix)
Concatenates the matrix with the current transformation according to PreMultiply or PostMultiply sema...
Definition: vtkTransform.h:140
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:95
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:108
void GetPosition(float pos[3])
Return the position from the current transformation matrix as an array of three floating point number...
Definition: vtkTransform.h:264
virtual int CircuitCheck(vtkAbstractTransform *transform)
Check for self-reference.
vtkLinearTransform * GetInput()
Set the input for this transformation.
Definition: vtkTransform.h:313
int GetNumberOfConcatenatedTransforms()
Get the total number of transformations that are linked into this one via Concatenate() operations or...
Definition: vtkTransform.h:181
a simple class to control print indentation
Definition: vtkIndent.h:33
void GetScale(float scale[3])
Return the scale factors of the current transformation matrix as an array of three float numbers.
Definition: vtkTransform.h:281
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:97
#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:82
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:377
void Scale(const double s[3])
Create a scale matrix (i.e.
Definition: vtkTransform.h:120
void SetMatrix(const double elements[16])
Set the current matrix directly.
Definition: vtkTransform.h:131
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:226
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:107
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:379
double Element[4][4]
The internal data is public for historical reasons. Do not use!
Definition: vtkMatrix4x4.h:39
vtkLinearTransform * GetConcatenatedTransform(int i)
Get one of the concatenated transformations as a vtkAbstractTransform.
Definition: vtkTransform.h:193
vtkTransformConcatenationStack * Stack
Definition: vtkTransform.h:393
vtkTransformConcatenation * Concatenation
Definition: vtkTransform.h:392
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:80
int GetInverseFlag()
Get the inverse flag of the transformation.
Definition: vtkTransform.h:323
void GetOrientationWXYZ(float wxyz[4])
Return the wxyz angle+axis representing the current orientation.
Definition: vtkTransform.h:247
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:83
vtkAbstractTransform * GetInverse()
Definition: vtkTransform.h:358
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:109
void Pop()
Deletes the transformation on the top of the stack and sets the top to the next transformation on the...
Definition: vtkTransform.h:341
vtkLinearTransform * Input
Definition: vtkTransform.h:391