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:
43  static vtkGeneralTransform *New();
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 
131  void Concatenate(vtkAbstractTransform *transform);
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 
191  void SetInput(vtkAbstractTransform *input);
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 
259  vtkAbstractTransform *MakeTransform() VTK_OVERRIDE;
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 
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.
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...
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.
vtkTypeUInt64 vtkMTimeType
Definition: vtkType.h:248
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
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.
void Scale(const float s[3])
Create a scale matrix (i.e.
void PostMultiply()
Sets the internal state of the transform to PostMultiply.