VTK  9.3.20240612
vtkGeneralTransform.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
20#ifndef vtkGeneralTransform_h
21#define vtkGeneralTransform_h
22
24#include "vtkCommonTransformsModule.h" // For export macro
25
26#include "vtkMatrix4x4.h" // Needed for inline methods
27
28VTK_ABI_NAMESPACE_BEGIN
29class VTKCOMMONTRANSFORMS_EXPORT vtkGeneralTransform : public vtkAbstractTransform
30{
31public:
33
35 void PrintSelf(ostream& os, vtkIndent indent) override;
36
42 void Identity()
43 {
44 this->Concatenation->Identity();
45 this->Modified();
46 }
47
53 void Inverse() override
54 {
55 this->Concatenation->Inverse();
56 this->Modified();
57 }
58
60
64 void Translate(double x, double y, double z) { this->Concatenation->Translate(x, y, z); }
65 void Translate(const double x[3]) { this->Translate(x[0], x[1], x[2]); }
66 void Translate(const float x[3]) { this->Translate(x[0], x[1], x[2]); }
68
70
76 void RotateWXYZ(double angle, double x, double y, double z)
77 {
78 this->Concatenation->Rotate(angle, x, y, z);
79 }
80 void RotateWXYZ(double angle, const double axis[3])
81 {
82 this->RotateWXYZ(angle, axis[0], axis[1], axis[2]);
83 }
84 void RotateWXYZ(double angle, const float axis[3])
85 {
86 this->RotateWXYZ(angle, axis[0], axis[1], axis[2]);
87 }
89
91
96 void RotateX(double angle) { this->RotateWXYZ(angle, 1, 0, 0); }
97 void RotateY(double angle) { this->RotateWXYZ(angle, 0, 1, 0); }
98 void RotateZ(double angle) { this->RotateWXYZ(angle, 0, 0, 1); }
100
102
107 void Scale(double x, double y, double z) { this->Concatenation->Scale(x, y, z); }
108 void Scale(const double s[3]) { this->Scale(s[0], s[1], s[2]); }
109 void Scale(const float s[3]) { this->Scale(s[0], s[1], s[2]); }
111
113
117 void Concatenate(vtkMatrix4x4* matrix) { this->Concatenate(*matrix->Element); }
118 void Concatenate(const double elements[16]) { this->Concatenation->Concatenate(elements); }
120
129
138 {
139 if (this->Concatenation->GetPreMultiplyFlag())
140 {
141 return;
142 }
143 this->Concatenation->SetPreMultiplyFlag(1);
144 this->Modified();
145 }
146
155 {
156 if (!this->Concatenation->GetPreMultiplyFlag())
157 {
158 return;
159 }
160 this->Concatenation->SetPreMultiplyFlag(0);
161 this->Modified();
162 }
163
169 {
170 return this->Concatenation->GetNumberOfTransforms() + (this->Input == nullptr ? 0 : 1);
171 }
172
181 {
182 if (this->Input == nullptr)
183 {
184 return this->Concatenation->GetTransform(i);
185 }
186 else if (i < this->Concatenation->GetNumberOfPreTransforms())
187 {
188 return this->Concatenation->GetTransform(i);
189 }
190 else if (i > this->Concatenation->GetNumberOfPreTransforms())
191 {
192 return this->Concatenation->GetTransform(i - 1);
193 }
194 else if (this->GetInverseFlag())
195 {
196 return this->Input->GetInverse();
197 }
198 else
199 {
200 return this->Input;
201 }
202 }
203
205
214 vtkAbstractTransform* GetInput() { return this->Input; }
216
224 vtkTypeBool GetInverseFlag() { return this->Concatenation->GetInverseFlag(); }
225
227
230 void Push()
231 {
232 if (this->Stack == nullptr)
233 {
235 }
236 this->Stack->Push(&this->Concatenation);
237 this->Modified();
238 }
240
242
246 void Pop()
247 {
248 if (this->Stack == nullptr)
249 {
250 return;
251 }
252 this->Stack->Pop(&this->Concatenation);
253 this->Modified();
254 }
256
258
262 void InternalTransformPoint(const float in[3], float out[3]) override;
263 void InternalTransformPoint(const double in[3], double out[3]) override;
265
267
273 const float in[3], float out[3], float derivative[3][3]) override;
275 const double in[3], double out[3], double derivative[3][3]) override;
277
286 int CircuitCheck(vtkAbstractTransform* transform) override;
287
292
297
298protected:
301
303 void InternalUpdate() override;
304
308
309private:
311 void operator=(const vtkGeneralTransform&) = delete;
312};
313
314VTK_ABI_NAMESPACE_END
315#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.
vtkTypeBool GetInverseFlag()
Get the inverse flag of the transformation.
void RotateWXYZ(double angle, const double axis[3])
Create a rotation matrix and concatenate it with the current transformation according to PreMultiply ...
vtkAbstractTransform * GetConcatenatedTransform(int i)
Get one of the concatenated transformations as a vtkAbstractTransform.
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.
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 * 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
vtkAbstractTransform * GetInput()
Set the input for this transformation.
static vtkGeneralTransform * New()
void PostMultiply()
Sets the internal state of the transform to PostMultiply.
void Scale(const double s[3])
Create a scale matrix (i.e.
vtkAbstractTransform * MakeTransform() override
Make another transform of the same type.
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.
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:108
represent and manipulate 4x4 transformation matrices
double Element[4][4]
The internal data is public for historical reasons. Do not use!
virtual void Modified()
Update the modification time for this object.
static vtkTransformConcatenationStack * New()
int vtkTypeBool
Definition vtkABI.h:64
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:270