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=========================================================================*/
31
32#ifndef vtkGeneralTransform_h
33#define vtkGeneralTransform_h
34
36#include "vtkCommonTransformsModule.h" // For export macro
37
38#include "vtkMatrix4x4.h" // Needed for inline methods
39
40class VTKCOMMONTRANSFORMS_EXPORT vtkGeneralTransform : public vtkAbstractTransform
41{
42public:
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 }
99
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
140
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
227
235 int GetInverseFlag() { return this->Concatenation->GetInverseFlag(); }
236
238
241 void Push()
242 {
243 if (this->Stack == nullptr)
244 {
246 }
247 this->Stack->Push(&this->Concatenation);
248 this->Modified();
249 }
250
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 }
266
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
308
309protected:
312
314 void InternalUpdate() override;
315
319
320private:
322 void operator=(const vtkGeneralTransform&) = delete;
323};
324
325#endif
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 ...
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.
int GetInverseFlag()
Get the inverse flag of the 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:40
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()
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:287