VTK  9.0.1
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
void Pop()
Deletes the transformation on the top of the stack and sets the top to the next transformation on the...
void RotateWXYZ(double angle, const float axis[3])
Create a rotation matrix and concatenate it with the current transformation according to PreMultiply ...
int GetInverseFlag()
Get the inverse flag of the transformation.
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:35
void Inverse() override
Invert the transformation.
vtkMTimeType GetMTime() override
Override GetMTime necessary because of inverse transforms.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:293
vtkTransformConcatenationStack * Stack
void PreMultiply()
Sets the internal state of the transform to PreMultiply.
allows operations on any transforms
void Concatenate(const double elements[16])
Concatenates the matrix with the current transformation according to PreMultiply or PostMultiply sema...
virtual void InternalUpdate()
Perform any subclass-specific Update.
virtual vtkAbstractTransform * MakeTransform()=0
Make another transform of the same type.
vtkAbstractTransform * GetInverse()
Get the inverse of this transform.
vtkAbstractTransform * GetConcatenatedTransform(int i)
Get one of the concatenated transformations as a vtkAbstractTransform.
void RotateX(double angle)
Create a rotation matrix about the X, Y, or Z axis and concatenate it with the current transformation...
virtual void InternalDeepCopy(vtkAbstractTransform *)
Perform any subclass-specific DeepCopy.
void Identity()
Set this transformation to the identity transformation.
void Translate(const float x[3])
Create a translation matrix and concatenate it with the current transformation according to PreMultip...
virtual int CircuitCheck(vtkAbstractTransform *transform)
Check for self-reference.
a simple class to control print indentation
Definition: vtkIndent.h:33
void Push()
Pushes the current transformation onto the transformation stack.
vtkAbstractTransform * GetInput()
Set the input for this transformation.
void Translate(const double x[3])
Create a translation matrix and concatenate it with the current transformation according to PreMultip...
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 PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void Translate(double x, double y, double z)
Create a translation matrix and concatenate it with the current transformation according to PreMultip...
superclass for all geometric transformations
int GetNumberOfConcatenatedTransforms()
Get the total number of transformations that are linked into this one via Concatenate() operations or...
void RotateY(double angle)
Create a rotation matrix about the X, Y, or Z axis and concatenate it with the current transformation...
virtual void Modified()
Update the modification time for this object.
void RotateWXYZ(double angle, const double axis[3])
Create a rotation matrix and concatenate it with the current transformation according to PreMultiply ...
void RotateZ(double angle)
Create a rotation matrix about the X, Y, or Z axis and concatenate it with the current transformation...
virtual void InternalTransformPoint(const float in[3], float out[3])=0
This will calculate the transformation without calling Update.
double Element[4][4]
The internal data is public for historical reasons. Do not use!
Definition: vtkMatrix4x4.h:39
vtkTransformConcatenation * Concatenation
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 ...
void Scale(const double s[3])
Create a scale matrix (i.e.
void Concatenate(vtkMatrix4x4 *matrix)
Concatenates the matrix with the current transformation according to PreMultiply or PostMultiply sema...
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
static vtkTransformConcatenationStack * New()
void Scale(double x, double y, double z)
Create a scale matrix (i.e.
vtkAbstractTransform * Input
void Scale(const float s[3])
Create a scale matrix (i.e.
void PostMultiply()
Sets the internal state of the transform to PostMultiply.