VTK  9.1.20211016
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:
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 
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 
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:
309 
311  void InternalUpdate() override;
312 
316 
317 private:
318  vtkGeneralTransform(const vtkGeneralTransform&) = delete;
319  void operator=(const vtkGeneralTransform&) = delete;
320 };
321 
322 #endif
superclass for all geometric transformations
vtkAbstractTransform * GetInverse()
Get the inverse of this transform.
allows operations on any transforms
void Concatenate(vtkMatrix4x4 *matrix)
Concatenates the matrix with the current transformation according to PreMultiply or PostMultiply sema...
void Scale(const float s[3])
Create a scale matrix (i.e.
void Identity()
Set this transformation to the identity transformation.
void Scale(double x, double y, double z)
Create a scale matrix (i.e.
void RotateWXYZ(double angle, const double axis[3])
Create a rotation matrix and concatenate it with the current transformation according to PreMultiply ...
void SetInput(vtkAbstractTransform *input)
Set the input for this transformation.
void Push()
Pushes the current transformation onto the transformation stack.
int CircuitCheck(vtkAbstractTransform *transform) override
Check for self-reference.
vtkTransformConcatenationStack * Stack
void Pop()
Deletes the transformation on the top of the stack and sets the top to the next transformation on the...
void InternalDeepCopy(vtkAbstractTransform *t) override
Perform any subclass-specific DeepCopy.
static vtkGeneralTransform * New()
void Translate(const double x[3])
Create a translation matrix and concatenate it with the current transformation according to PreMultip...
void InternalTransformDerivative(const double in[3], double out[3], double derivative[3][3]) override
This will calculate the transformation as well as its derivative without calling Update.
vtkAbstractTransform * GetConcatenatedTransform(int i)
Get one of the concatenated transformations as a vtkAbstractTransform.
vtkAbstractTransform * Input
void InternalUpdate() override
Perform any subclass-specific Update.
void Concatenate(vtkAbstractTransform *transform)
Concatenate the specified transform with the current transformation according to PreMultiply or PostM...
void RotateZ(double angle)
Create a rotation matrix about the X, Y, or Z axis and concatenate it with the current transformation...
~vtkGeneralTransform() override
int GetInverseFlag()
Get the inverse flag of the transformation.
void PostMultiply()
Sets the internal state of the transform to PostMultiply.
void Scale(const double s[3])
Create a scale matrix (i.e.
vtkAbstractTransform * GetInput()
Set the input for this transformation.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void InternalTransformDerivative(const float in[3], float out[3], float derivative[3][3]) override
This will calculate the transformation as well as its derivative without calling Update.
void PreMultiply()
Sets the internal state of the transform to PreMultiply.
void InternalTransformPoint(const float in[3], float out[3]) override
This will calculate the transformation without calling Update.
int GetNumberOfConcatenatedTransforms()
Get the total number of transformations that are linked into this one via Concatenate() operations or...
void Concatenate(const double elements[16])
Concatenates the matrix with the current transformation according to PreMultiply or PostMultiply sema...
void RotateWXYZ(double angle, const float axis[3])
Create a rotation matrix and concatenate it with the current transformation according to PreMultiply ...
void Translate(const float x[3])
Create a translation matrix and concatenate it with the current transformation according to PreMultip...
vtkTransformConcatenation * Concatenation
void RotateWXYZ(double angle, double x, double y, double z)
Create a rotation matrix and concatenate it with the current transformation according to PreMultiply ...
void Inverse() override
Invert the transformation.
vtkMTimeType GetMTime() override
Override GetMTime to account for input and concatenation.
vtkAbstractTransform * MakeTransform() override
Make another transform of the same type.
void Translate(double x, double y, double z)
Create a translation matrix and concatenate it with the current transformation according to PreMultip...
void InternalTransformPoint(const double in[3], double out[3]) override
This will calculate the transformation without calling Update.
void RotateX(double angle)
Create a rotation matrix about the X, Y, or Z axis and concatenate it with the current transformation...
void RotateY(double angle)
Create a rotation matrix about the X, Y, or Z axis and concatenate it with the current transformation...
a simple class to control print indentation
Definition: vtkIndent.h:113
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:145
double Element[4][4]
The internal data is public for historical reasons. Do not use!
Definition: vtkMatrix4x4.h:148
virtual void Modified()
Update the modification time for this object.
static vtkTransformConcatenationStack * New()
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:287