VTK
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 "vtkCommonTransformsModule.h" // For export macro
36 #include "vtkAbstractTransform.h"
37 
38 #include "vtkMatrix4x4.h" // Needed for inline methods
39 
40 class VTKCOMMONTRANSFORMS_EXPORT vtkGeneralTransform : public vtkAbstractTransform
41 {
42 public:
44 
46  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
47 
53  void Identity()
54  { this->Concatenation->Identity(); this->Modified(); };
55 
61  void Inverse() VTK_OVERRIDE
62  { this->Concatenation->Inverse(); this->Modified(); }
63 
65 
69  void Translate(double x, double y, double z) {
70  this->Concatenation->Translate(x,y,z); };
71  void Translate(const double x[3]) { this->Translate(x[0], x[1], x[2]); };
72  void Translate(const float x[3]) { this->Translate(x[0], x[1], x[2]); };
74 
76 
82  void RotateWXYZ(double angle, double x, double y, double z) {
83  this->Concatenation->Rotate(angle,x,y,z); };
84  void RotateWXYZ(double angle, const double axis[3]) {
85  this->RotateWXYZ(angle, axis[0], axis[1], axis[2]); };
86  void RotateWXYZ(double angle, const float axis[3]) {
87  this->RotateWXYZ(angle, axis[0], axis[1], axis[2]); };
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) {
108  this->Concatenation->Scale(x,y,z); };
109  void Scale(const double s[3]) { this->Scale(s[0], s[1], s[2]); };
110  void Scale(const float s[3]) { this->Scale(s[0], s[1], s[2]); };
112 
114 
118  void Concatenate(vtkMatrix4x4 *matrix) {
119  this->Concatenate(*matrix->Element); };
120  void Concatenate(const double elements[16]) {
121  this->Concatenation->Concatenate(elements); };
123 
132 
140  void PreMultiply() {
141  if (this->Concatenation->GetPreMultiplyFlag()) { return; }
142  this->Concatenation->SetPreMultiplyFlag(1); this->Modified(); };
143 
151  void PostMultiply() {
152  if (!this->Concatenation->GetPreMultiplyFlag()) { return; }
153  this->Concatenation->SetPreMultiplyFlag(0); this->Modified(); };
154 
160  return this->Concatenation->GetNumberOfTransforms() +
161  (this->Input == NULL ? 0 : 1); };
162 
171  if (this->Input == NULL) {
172  return this->Concatenation->GetTransform(i); }
173  else if (i < this->Concatenation->GetNumberOfPreTransforms()) {
174  return this->Concatenation->GetTransform(i); }
175  else if (i > this->Concatenation->GetNumberOfPreTransforms()) {
176  return this->Concatenation->GetTransform(i-1); }
177  else if (this->GetInverseFlag()) {
178  return this->Input->GetInverse(); }
179  else {
180  return this->Input; } };
181 
183 
192  vtkAbstractTransform *GetInput() { return this->Input; };
194 
203  return this->Concatenation->GetInverseFlag(); };
204 
206 
209  void Push() { if (this->Stack == NULL) {
210  this->Stack = vtkTransformConcatenationStack::New(); }
211  this->Stack->Push(&this->Concatenation);
212  this->Modified(); };
214 
216 
220  void Pop() { if (this->Stack == NULL) { return; }
221  this->Stack->Pop(&this->Concatenation);
222  this->Modified(); };
224 
226 
230  void InternalTransformPoint(const float in[3], float out[3]) VTK_OVERRIDE;
231  void InternalTransformPoint(const double in[3], double out[3]) VTK_OVERRIDE;
233 
235 
240  void InternalTransformDerivative(const float in[3], float out[3],
241  float derivative[3][3]) VTK_OVERRIDE;
242  void InternalTransformDerivative(const double in[3], double out[3],
243  double derivative[3][3]) VTK_OVERRIDE;
245 
254  int CircuitCheck(vtkAbstractTransform *transform) VTK_OVERRIDE;
255 
260 
264  vtkMTimeType GetMTime() VTK_OVERRIDE;
265 
266 protected:
268  ~vtkGeneralTransform() VTK_OVERRIDE;
269 
270  void InternalDeepCopy(vtkAbstractTransform *t) VTK_OVERRIDE;
271  void InternalUpdate() VTK_OVERRIDE;
272 
276 private:
277  vtkGeneralTransform(const vtkGeneralTransform&) VTK_DELETE_FUNCTION;
278  void operator=(const vtkGeneralTransform&) VTK_DELETE_FUNCTION;
279 };
280 
281 
282 #endif
283 
284 
285 
286 
287 
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])
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])
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.
void Pop()
Deletes the transformation on the top of the stack and sets the top to the next transformation on the...
static vtkGeneralTransform * New()
void Translate(const double x[3])
void InternalTransformDerivative(const double in[3], double out[3], double derivative[3][3]) override
vtkAbstractTransform * GetConcatenatedTransform(int i)
Get one of the concatenated transformations as a vtkAbstractTransform.
void Concatenate(vtkAbstractTransform *transform)
Concatenate the specified transform with the current transformation according to PreMultiply or PostM...
void RotateZ(double angle)
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])
vtkAbstractTransform * GetInput()
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])
void RotateWXYZ(double angle, const float axis[3])
void Translate(const float x[3])
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.
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
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)
a simple class to control print indentation
Definition: vtkIndent.h:40
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:42
double Element[4][4]
The internal data is public for historical reasons. Do not use!
Definition: vtkMatrix4x4.h:45
virtual void Modified()
Update the modification time for this object.
static vtkTransformConcatenationStack * New()
vtkTypeUInt64 vtkMTimeType
Definition: vtkType.h:248