VTK  9.0.20201019
vtkGeneralTransform.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkGeneralTransform.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 =========================================================================*/
29 #ifndef vtkGeneralTransform_h
30 #define vtkGeneralTransform_h
31 
32 #include "vtkAbstractTransform.h"
33 #include "vtkCommonTransformsModule.h" // For export macro
34 
35 #include "vtkMatrix4x4.h" // Needed for inline methods
36 
37 class VTKCOMMONTRANSFORMS_EXPORT vtkGeneralTransform : public vtkAbstractTransform
38 {
39 public:
40  static vtkGeneralTransform* New();
41 
43  void PrintSelf(ostream& os, vtkIndent indent) override;
44 
50  void Identity()
51  {
52  this->Concatenation->Identity();
53  this->Modified();
54  }
55 
61  void Inverse() override
62  {
63  this->Concatenation->Inverse();
64  this->Modified();
65  }
66 
68 
72  void Translate(double x, double y, double z) { this->Concatenation->Translate(x, y, z); }
73  void Translate(const double x[3]) { this->Translate(x[0], x[1], x[2]); }
74  void Translate(const float x[3]) { this->Translate(x[0], x[1], x[2]); }
76 
78 
84  void RotateWXYZ(double angle, double x, double y, double z)
85  {
86  this->Concatenation->Rotate(angle, x, y, z);
87  }
88  void RotateWXYZ(double angle, const double axis[3])
89  {
90  this->RotateWXYZ(angle, axis[0], axis[1], axis[2]);
91  }
92  void RotateWXYZ(double angle, const float axis[3])
93  {
94  this->RotateWXYZ(angle, axis[0], axis[1], axis[2]);
95  }
97 
99 
104  void RotateX(double angle) { this->RotateWXYZ(angle, 1, 0, 0); }
105  void RotateY(double angle) { this->RotateWXYZ(angle, 0, 1, 0); }
106  void RotateZ(double angle) { this->RotateWXYZ(angle, 0, 0, 1); }
108 
110 
115  void Scale(double x, double y, double z) { this->Concatenation->Scale(x, y, z); }
116  void Scale(const double s[3]) { this->Scale(s[0], s[1], s[2]); }
117  void Scale(const float s[3]) { this->Scale(s[0], s[1], s[2]); }
119 
121 
125  void Concatenate(vtkMatrix4x4* matrix) { this->Concatenate(*matrix->Element); }
126  void Concatenate(const double elements[16]) { this->Concatenation->Concatenate(elements); }
128 
136  void Concatenate(vtkAbstractTransform* transform);
137 
145  void PreMultiply()
146  {
147  if (this->Concatenation->GetPreMultiplyFlag())
148  {
149  return;
150  }
151  this->Concatenation->SetPreMultiplyFlag(1);
152  this->Modified();
153  }
154 
163  {
164  if (!this->Concatenation->GetPreMultiplyFlag())
165  {
166  return;
167  }
168  this->Concatenation->SetPreMultiplyFlag(0);
169  this->Modified();
170  }
171 
177  {
178  return this->Concatenation->GetNumberOfTransforms() + (this->Input == nullptr ? 0 : 1);
179  }
180 
189  {
190  if (this->Input == nullptr)
191  {
192  return this->Concatenation->GetTransform(i);
193  }
194  else if (i < this->Concatenation->GetNumberOfPreTransforms())
195  {
196  return this->Concatenation->GetTransform(i);
197  }
198  else if (i > this->Concatenation->GetNumberOfPreTransforms())
199  {
200  return this->Concatenation->GetTransform(i - 1);
201  }
202  else if (this->GetInverseFlag())
203  {
204  return this->Input->GetInverse();
205  }
206  else
207  {
208  return this->Input;
209  }
210  }
211 
213 
221  void SetInput(vtkAbstractTransform* input);
222  vtkAbstractTransform* GetInput() { return this->Input; }
224 
232  int GetInverseFlag() { return this->Concatenation->GetInverseFlag(); }
233 
235 
238  void Push()
239  {
240  if (this->Stack == nullptr)
241  {
242  this->Stack = vtkTransformConcatenationStack::New();
243  }
244  this->Stack->Push(&this->Concatenation);
245  this->Modified();
246  }
248 
250 
254  void Pop()
255  {
256  if (this->Stack == nullptr)
257  {
258  return;
259  }
260  this->Stack->Pop(&this->Concatenation);
261  this->Modified();
262  }
264 
266 
270  void InternalTransformPoint(const float in[3], float out[3]) override;
271  void InternalTransformPoint(const double in[3], double out[3]) override;
273 
275 
281  const float in[3], float out[3], float derivative[3][3]) override;
283  const double in[3], double out[3], double derivative[3][3]) override;
285 
294  int CircuitCheck(vtkAbstractTransform* transform) override;
295 
300 
304  vtkMTimeType GetMTime() override;
305 
306 protected:
308  ~vtkGeneralTransform() override;
309 
310  void InternalDeepCopy(vtkAbstractTransform* t) override;
311  void InternalUpdate() override;
312 
316 
317 private:
318  vtkGeneralTransform(const vtkGeneralTransform&) = delete;
319  void operator=(const vtkGeneralTransform&) = delete;
320 };
321 
322 #endif
vtkGeneralTransform::Scale
void Scale(double x, double y, double z)
Create a scale matrix (i.e.
Definition: vtkGeneralTransform.h:115
vtkGeneralTransform::Inverse
void Inverse() override
Invert the transformation.
Definition: vtkGeneralTransform.h:61
vtkGeneralTransform::RotateWXYZ
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: vtkGeneralTransform.h:84
vtkAbstractTransform::CircuitCheck
virtual int CircuitCheck(vtkAbstractTransform *transform)
Check for self-reference.
vtkAbstractTransform
superclass for all geometric transformations
Definition: vtkAbstractTransform.h:50
vtkAbstractTransform::InternalTransformPoint
virtual void InternalTransformPoint(const float in[3], float out[3])=0
This will calculate the transformation without calling Update.
vtkMatrix4x4::Element
double Element[4][4]
The internal data is public for historical reasons. Do not use!
Definition: vtkMatrix4x4.h:39
vtkGeneralTransform::Identity
void Identity()
Set this transformation to the identity transformation.
Definition: vtkGeneralTransform.h:50
vtkTransformConcatenationStack
Definition: vtkAbstractTransform.h:481
vtkAbstractTransform.h
vtkObject::New
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
vtkAbstractTransform::InternalUpdate
virtual void InternalUpdate()
Perform any subclass-specific Update.
Definition: vtkAbstractTransform.h:317
vtkGeneralTransform::Translate
void Translate(const double x[3])
Definition: vtkGeneralTransform.h:73
vtkObject::Modified
virtual void Modified()
Update the modification time for this object.
vtkGeneralTransform::Translate
void Translate(const float x[3])
Definition: vtkGeneralTransform.h:74
vtkGeneralTransform::GetConcatenatedTransform
vtkAbstractTransform * GetConcatenatedTransform(int i)
Get one of the concatenated transformations as a vtkAbstractTransform.
Definition: vtkGeneralTransform.h:188
vtkGeneralTransform::Input
vtkAbstractTransform * Input
Definition: vtkGeneralTransform.h:313
vtkAbstractTransform::GetInverse
vtkAbstractTransform * GetInverse()
Get the inverse of this transform.
vtkAbstractTransform::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkGeneralTransform::GetInput
vtkAbstractTransform * GetInput()
Definition: vtkGeneralTransform.h:222
vtkGeneralTransform::RotateX
void RotateX(double angle)
Create a rotation matrix about the X, Y, or Z axis and concatenate it with the current transformation...
Definition: vtkGeneralTransform.h:104
vtkGeneralTransform::PreMultiply
void PreMultiply()
Sets the internal state of the transform to PreMultiply.
Definition: vtkGeneralTransform.h:145
vtkGeneralTransform::Stack
vtkTransformConcatenationStack * Stack
Definition: vtkGeneralTransform.h:315
vtkGeneralTransform::Translate
void Translate(double x, double y, double z)
Create a translation matrix and concatenate it with the current transformation according to PreMultip...
Definition: vtkGeneralTransform.h:72
vtkMatrix4x4.h
vtkAbstractTransform::InternalTransformDerivative
virtual void InternalTransformDerivative(const float in[3], float out[3], float derivative[3][3])=0
This will transform a point and, at the same time, calculate a 3x3 Jacobian matrix that provides the ...
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkMatrix4x4
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:35
vtkGeneralTransform::Pop
void Pop()
Deletes the transformation on the top of the stack and sets the top to the next transformation on the...
Definition: vtkGeneralTransform.h:254
vtkAbstractTransform::GetMTime
vtkMTimeType GetMTime() override
Override GetMTime necessary because of inverse transforms.
vtkGeneralTransform
allows operations on any transforms
Definition: vtkGeneralTransform.h:37
vtkGeneralTransform::RotateY
void RotateY(double angle)
Definition: vtkGeneralTransform.h:105
vtkTransformConcatenationStack::New
static vtkTransformConcatenationStack * New()
Definition: vtkAbstractTransform.h:484
vtkGeneralTransform::RotateWXYZ
void RotateWXYZ(double angle, const double axis[3])
Definition: vtkGeneralTransform.h:88
vtkGeneralTransform::RotateZ
void RotateZ(double angle)
Definition: vtkGeneralTransform.h:106
vtkGeneralTransform::Concatenate
void Concatenate(const double elements[16])
Definition: vtkGeneralTransform.h:126
vtkGeneralTransform::Scale
void Scale(const double s[3])
Definition: vtkGeneralTransform.h:116
vtkGeneralTransform::GetInverseFlag
int GetInverseFlag()
Get the inverse flag of the transformation.
Definition: vtkGeneralTransform.h:232
vtkGeneralTransform::Concatenate
void Concatenate(vtkMatrix4x4 *matrix)
Concatenates the matrix with the current transformation according to PreMultiply or PostMultiply sema...
Definition: vtkGeneralTransform.h:125
vtkGeneralTransform::Scale
void Scale(const float s[3])
Definition: vtkGeneralTransform.h:117
vtkGeneralTransform::Concatenation
vtkTransformConcatenation * Concatenation
Definition: vtkGeneralTransform.h:314
vtkGeneralTransform::Push
void Push()
Pushes the current transformation onto the transformation stack.
Definition: vtkGeneralTransform.h:238
vtkGeneralTransform::PostMultiply
void PostMultiply()
Sets the internal state of the transform to PostMultiply.
Definition: vtkGeneralTransform.h:162
vtkTransformConcatenation
Definition: vtkAbstractTransform.h:375
vtkAbstractTransform::MakeTransform
virtual vtkAbstractTransform * MakeTransform()=0
Make another transform of the same type.
vtkGeneralTransform::GetNumberOfConcatenatedTransforms
int GetNumberOfConcatenatedTransforms()
Get the total number of transformations that are linked into this one via Concatenate() operations or...
Definition: vtkGeneralTransform.h:176
vtkMTimeType
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:285
vtkGeneralTransform::RotateWXYZ
void RotateWXYZ(double angle, const float axis[3])
Definition: vtkGeneralTransform.h:92
vtkAbstractTransform::InternalDeepCopy
virtual void InternalDeepCopy(vtkAbstractTransform *)
Perform any subclass-specific DeepCopy.
Definition: vtkAbstractTransform.h:322