VTK  9.2.6
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 =========================================================================*/
32 #ifndef vtkGeneralTransform_h
33 #define vtkGeneralTransform_h
34 
35 #include "vtkAbstractTransform.h"
36 #include "vtkCommonTransformsModule.h" // For export macro
37 
38 #include "vtkMatrix4x4.h" // Needed for inline methods
39 
40 class VTKCOMMONTRANSFORMS_EXPORT vtkGeneralTransform : public vtkAbstractTransform
41 {
42 public:
43  static vtkGeneralTransform* New();
44 
46  void PrintSelf(ostream& os, vtkIndent indent) override;
47 
53  void Identity()
54  {
55  this->Concatenation->Identity();
56  this->Modified();
57  }
58 
64  void Inverse() override
65  {
66  this->Concatenation->Inverse();
67  this->Modified();
68  }
69 
71 
75  void Translate(double x, double y, double z) { this->Concatenation->Translate(x, y, z); }
76  void Translate(const double x[3]) { this->Translate(x[0], x[1], x[2]); }
77  void Translate(const float x[3]) { this->Translate(x[0], x[1], x[2]); }
79 
81 
87  void RotateWXYZ(double angle, double x, double y, double z)
88  {
89  this->Concatenation->Rotate(angle, x, y, z);
90  }
91  void RotateWXYZ(double angle, const double axis[3])
92  {
93  this->RotateWXYZ(angle, axis[0], axis[1], axis[2]);
94  }
95  void RotateWXYZ(double angle, const float axis[3])
96  {
97  this->RotateWXYZ(angle, axis[0], axis[1], axis[2]);
98  }
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) { this->Concatenation->Scale(x, y, z); }
119  void Scale(const double s[3]) { this->Scale(s[0], s[1], s[2]); }
120  void Scale(const float s[3]) { this->Scale(s[0], s[1], s[2]); }
122 
124 
128  void Concatenate(vtkMatrix4x4* matrix) { this->Concatenate(*matrix->Element); }
129  void Concatenate(const double elements[16]) { this->Concatenation->Concatenate(elements); }
131 
139  void Concatenate(vtkAbstractTransform* transform);
140 
148  void PreMultiply()
149  {
150  if (this->Concatenation->GetPreMultiplyFlag())
151  {
152  return;
153  }
154  this->Concatenation->SetPreMultiplyFlag(1);
155  this->Modified();
156  }
157 
166  {
167  if (!this->Concatenation->GetPreMultiplyFlag())
168  {
169  return;
170  }
171  this->Concatenation->SetPreMultiplyFlag(0);
172  this->Modified();
173  }
174 
180  {
181  return this->Concatenation->GetNumberOfTransforms() + (this->Input == nullptr ? 0 : 1);
182  }
183 
192  {
193  if (this->Input == nullptr)
194  {
195  return this->Concatenation->GetTransform(i);
196  }
197  else if (i < this->Concatenation->GetNumberOfPreTransforms())
198  {
199  return this->Concatenation->GetTransform(i);
200  }
201  else if (i > this->Concatenation->GetNumberOfPreTransforms())
202  {
203  return this->Concatenation->GetTransform(i - 1);
204  }
205  else if (this->GetInverseFlag())
206  {
207  return this->Input->GetInverse();
208  }
209  else
210  {
211  return this->Input;
212  }
213  }
214 
216 
224  void SetInput(vtkAbstractTransform* input);
225  vtkAbstractTransform* GetInput() { return this->Input; }
227 
235  int GetInverseFlag() { return this->Concatenation->GetInverseFlag(); }
236 
238 
241  void Push()
242  {
243  if (this->Stack == nullptr)
244  {
245  this->Stack = vtkTransformConcatenationStack::New();
246  }
247  this->Stack->Push(&this->Concatenation);
248  this->Modified();
249  }
251 
253 
257  void Pop()
258  {
259  if (this->Stack == nullptr)
260  {
261  return;
262  }
263  this->Stack->Pop(&this->Concatenation);
264  this->Modified();
265  }
267 
269 
273  void InternalTransformPoint(const float in[3], float out[3]) override;
274  void InternalTransformPoint(const double in[3], double out[3]) override;
276 
278 
284  const float in[3], float out[3], float derivative[3][3]) override;
286  const double in[3], double out[3], double derivative[3][3]) override;
288 
297  int CircuitCheck(vtkAbstractTransform* transform) override;
298 
303 
307  vtkMTimeType GetMTime() override;
308 
309 protected:
311  ~vtkGeneralTransform() override;
312 
313  void InternalDeepCopy(vtkAbstractTransform* t) override;
314  void InternalUpdate() override;
315 
319 
320 private:
321  vtkGeneralTransform(const vtkGeneralTransform&) = delete;
322  void operator=(const vtkGeneralTransform&) = delete;
323 };
324 
325 #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:41
void Inverse() override
Invert the transformation.
vtkMTimeType GetMTime() override
Override GetMTime necessary because of inverse transforms.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:287
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:39
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:45
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.