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 =========================================================================*/
29 #ifndef vtkGeneralTransform_h
30 #define vtkGeneralTransform_h
31 
32 #include "vtkCommonTransformsModule.h" // For export macro
33 #include "vtkAbstractTransform.h"
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) VTK_OVERRIDE;
44 
50  void Identity()
51  { this->Concatenation->Identity(); this->Modified(); };
52 
58  void Inverse() VTK_OVERRIDE
59  { this->Concatenation->Inverse(); this->Modified(); }
60 
62 
66  void Translate(double x, double y, double z) {
67  this->Concatenation->Translate(x,y,z); };
68  void Translate(const double x[3]) { this->Translate(x[0], x[1], x[2]); };
69  void Translate(const float x[3]) { this->Translate(x[0], x[1], x[2]); };
71 
73 
79  void RotateWXYZ(double angle, double x, double y, double z) {
80  this->Concatenation->Rotate(angle,x,y,z); };
81  void RotateWXYZ(double angle, const double axis[3]) {
82  this->RotateWXYZ(angle, axis[0], axis[1], axis[2]); };
83  void RotateWXYZ(double angle, const float axis[3]) {
84  this->RotateWXYZ(angle, axis[0], axis[1], axis[2]); };
86 
88 
93  void RotateX(double angle) { this->RotateWXYZ(angle, 1, 0, 0); };
94  void RotateY(double angle) { this->RotateWXYZ(angle, 0, 1, 0); };
95  void RotateZ(double angle) { this->RotateWXYZ(angle, 0, 0, 1); };
97 
99 
104  void Scale(double x, double y, double z) {
105  this->Concatenation->Scale(x,y,z); };
106  void Scale(const double s[3]) { this->Scale(s[0], s[1], s[2]); };
107  void Scale(const float s[3]) { this->Scale(s[0], s[1], s[2]); };
109 
111 
115  void Concatenate(vtkMatrix4x4 *matrix) {
116  this->Concatenate(*matrix->Element); };
117  void Concatenate(const double elements[16]) {
118  this->Concatenation->Concatenate(elements); };
120 
128  void Concatenate(vtkAbstractTransform *transform);
129 
137  void PreMultiply() {
138  if (this->Concatenation->GetPreMultiplyFlag()) { return; }
139  this->Concatenation->SetPreMultiplyFlag(1); this->Modified(); };
140 
148  void PostMultiply() {
149  if (!this->Concatenation->GetPreMultiplyFlag()) { return; }
150  this->Concatenation->SetPreMultiplyFlag(0); this->Modified(); };
151 
157  return this->Concatenation->GetNumberOfTransforms() +
158  (this->Input == NULL ? 0 : 1); };
159 
168  if (this->Input == NULL) {
169  return this->Concatenation->GetTransform(i); }
170  else if (i < this->Concatenation->GetNumberOfPreTransforms()) {
171  return this->Concatenation->GetTransform(i); }
172  else if (i > this->Concatenation->GetNumberOfPreTransforms()) {
173  return this->Concatenation->GetTransform(i-1); }
174  else if (this->GetInverseFlag()) {
175  return this->Input->GetInverse(); }
176  else {
177  return this->Input; } };
178 
180 
188  void SetInput(vtkAbstractTransform *input);
189  vtkAbstractTransform *GetInput() { return this->Input; };
191 
200  return this->Concatenation->GetInverseFlag(); };
201 
203 
206  void Push() { if (this->Stack == NULL) {
207  this->Stack = vtkTransformConcatenationStack::New(); }
208  this->Stack->Push(&this->Concatenation);
209  this->Modified(); };
211 
213 
217  void Pop() { if (this->Stack == NULL) { return; }
218  this->Stack->Pop(&this->Concatenation);
219  this->Modified(); };
221 
223 
227  void InternalTransformPoint(const float in[3], float out[3]) VTK_OVERRIDE;
228  void InternalTransformPoint(const double in[3], double out[3]) VTK_OVERRIDE;
230 
232 
237  void InternalTransformDerivative(const float in[3], float out[3],
238  float derivative[3][3]) VTK_OVERRIDE;
239  void InternalTransformDerivative(const double in[3], double out[3],
240  double derivative[3][3]) VTK_OVERRIDE;
242 
251  int CircuitCheck(vtkAbstractTransform *transform) VTK_OVERRIDE;
252 
256  vtkAbstractTransform *MakeTransform() VTK_OVERRIDE;
257 
261  vtkMTimeType GetMTime() VTK_OVERRIDE;
262 
263 protected:
265  ~vtkGeneralTransform() VTK_OVERRIDE;
266 
267  void InternalDeepCopy(vtkAbstractTransform *t) VTK_OVERRIDE;
268  void InternalUpdate() VTK_OVERRIDE;
269 
273 private:
274  vtkGeneralTransform(const vtkGeneralTransform&) VTK_DELETE_FUNCTION;
275  void operator=(const vtkGeneralTransform&) VTK_DELETE_FUNCTION;
276 };
277 
278 
279 #endif
280 
281 
282 
283 
284 
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:300
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.
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 VTK_NEWINSTANCE vtkAbstractTransform * MakeTransform()=0
Make another transform of the same type.
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.