VTK
vtkTransform.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkTransform.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 =========================================================================*/
15 
51 #ifndef vtkTransform_h
52 #define vtkTransform_h
53 
54 #include "vtkCommonTransformsModule.h" // For export macro
55 #include "vtkLinearTransform.h"
56 
57 #include "vtkMatrix4x4.h" // Needed for inline methods
58 
60 {
61  public:
62  static vtkTransform *New();
64  void PrintSelf(ostream& os, vtkIndent indent);
65 
69  void Identity();
70 
74  void Inverse();
75 
77 
79  void Translate(double x, double y, double z) {
80  this->Concatenation->Translate(x,y,z); };
81  void Translate(const double x[3]) { this->Translate(x[0], x[1], x[2]); };
82  void Translate(const float x[3]) { this->Translate(x[0], x[1], x[2]); };
84 
86 
90  void RotateWXYZ(double angle, double x, double y, double z) {
91  this->Concatenation->Rotate(angle,x,y,z); };
92  void RotateWXYZ(double angle, const double axis[3]) {
93  this->RotateWXYZ(angle, axis[0], axis[1], axis[2]); };
94  void RotateWXYZ(double angle, const float axis[3]) {
95  this->RotateWXYZ(angle, axis[0], axis[1], axis[2]); };
97 
99 
102  void RotateX(double angle) { this->RotateWXYZ(angle, 1, 0, 0); };
103  void RotateY(double angle) { this->RotateWXYZ(angle, 0, 1, 0); };
104  void RotateZ(double angle) { this->RotateWXYZ(angle, 0, 0, 1); };
106 
108 
111  void Scale(double x, double y, double z) {
112  this->Concatenation->Scale(x,y,z); };
113  void Scale(const double s[3]) { this->Scale(s[0], s[1], s[2]); };
114  void Scale(const float s[3]) { this->Scale(s[0], s[1], s[2]); };
116 
118 
120  void SetMatrix(vtkMatrix4x4 *matrix) {
121  this->SetMatrix(*matrix->Element); };
122  void SetMatrix(const double elements[16]) {
123  this->Concatenation->Identity(); this->Concatenate(elements); };
125 
127 
129  void Concatenate(vtkMatrix4x4 *matrix) {
130  this->Concatenate(*matrix->Element); };
131  void Concatenate(const double elements[16]) {
132  this->Concatenation->Concatenate(elements); };
134 
140  void Concatenate(vtkLinearTransform *transform);
141 
143 
148  void PreMultiply() {
149  if (this->Concatenation->GetPreMultiplyFlag()) { return; }
150  this->Concatenation->SetPreMultiplyFlag(1); this->Modified(); };
152 
154 
159  void PostMultiply() {
160  if (!this->Concatenation->GetPreMultiplyFlag()) { return; }
161  this->Concatenation->SetPreMultiplyFlag(0); this->Modified(); };
163 
165 
168  return this->Concatenation->GetNumberOfTransforms() +
169  (this->Input == NULL ? 0 : 1); };
171 
173 
179  {
181  if (this->Input == NULL)
182  {
183  t=this->Concatenation->GetTransform(i);
184  }
185  else if (i < this->Concatenation->GetNumberOfPreTransforms())
186  {
187  t=this->Concatenation->GetTransform(i);
188  }
189  else if (i > this->Concatenation->GetNumberOfPreTransforms())
190  {
191  t=this->Concatenation->GetTransform(i-1);
192  }
193  else if (this->GetInverseFlag())
194  {
195  t=this->Input->GetInverse();
196  }
197  else
198  {
199  t=this->Input;
200  }
201  return static_cast<vtkLinearTransform *>(t);
202  }
204 
206 
208  void GetOrientation(double orient[3]);
209  void GetOrientation(float orient[3]) {
210  double temp[3]; this->GetOrientation(temp);
211  orient[0] = static_cast<float>(temp[0]);
212  orient[1] = static_cast<float>(temp[1]);
213  orient[2] = static_cast<float>(temp[2]); };
214  double *GetOrientation() {
215  this->GetOrientation(this->ReturnValue); return this->ReturnValue; };
217 
220  static void GetOrientation(double orient[3], vtkMatrix4x4 *matrix);
221 
223 
225  void GetOrientationWXYZ(double wxyz[4]);
226  void GetOrientationWXYZ(float wxyz[4]) {
227  double temp[4]; this->GetOrientationWXYZ(temp);
228  wxyz[0]=static_cast<float>(temp[0]);
229  wxyz[1]=static_cast<float>(temp[1]);
230  wxyz[2]=static_cast<float>(temp[2]);
231  wxyz[3]=static_cast<float>(temp[3]);};
232  double *GetOrientationWXYZ() {
233  this->GetOrientationWXYZ(this->ReturnValue); return this->ReturnValue; };
235 
237 
240  void GetPosition(double pos[3]);
241  void GetPosition(float pos[3]) {
242  double temp[3]; this->GetPosition(temp);
243  pos[0] = static_cast<float>(temp[0]);
244  pos[1] = static_cast<float>(temp[1]);
245  pos[2] = static_cast<float>(temp[2]); };
246  double *GetPosition() {
247  this->GetPosition(this->ReturnValue); return this->ReturnValue; };
249 
251 
255  void GetScale(double scale[3]);
256  void GetScale(float scale[3]) {
257  double temp[3]; this->GetScale(temp);
258  scale[0] = static_cast<float>(temp[0]);
259  scale[1] = static_cast<float>(temp[1]);
260  scale[2] = static_cast<float>(temp[2]); };
261  double *GetScale() {
262  this->GetScale(this->ReturnValue); return this->ReturnValue; };
264 
267  void GetInverse(vtkMatrix4x4 *inverse);
268 
272  void GetTranspose(vtkMatrix4x4 *transpose);
273 
275 
281  void SetInput(vtkLinearTransform *input);
282  vtkLinearTransform *GetInput() { return this->Input; };
284 
286 
291  return this->Concatenation->GetInverseFlag(); };
293 
295 
296  void Push() { if (this->Stack == NULL) {
297  this->Stack = vtkTransformConcatenationStack::New(); }
298  this->Stack->Push(&this->Concatenation);
299  this->Modified(); };
301 
303 
305  void Pop() { if (this->Stack == NULL) { return; }
306  this->Stack->Pop(&this->Concatenation);
307  this->Modified(); };
309 
316  int CircuitCheck(vtkAbstractTransform *transform);
317 
318  // Return an inverse transform which will always update itself
319  // to match this transform.
322 
325 
327  unsigned long GetMTime();
328 
330 
333  void MultiplyPoint(const float in[4], float out[4]) {
334  this->GetMatrix()->MultiplyPoint(in,out);};
335  void MultiplyPoint(const double in[4], double out[4]) {
336  this->GetMatrix()->MultiplyPoint(in,out);};
338 
339 protected:
340  vtkTransform ();
341  ~vtkTransform ();
342 
344 
345  void InternalUpdate();
346 
350 
351  // this allows us to check whether people have been fooling
352  // around with our matrix
353  unsigned long MatrixUpdateMTime;
354 
355  float Point[4];
356  double DoublePoint[4];
357  double ReturnValue[4];
358 private:
359  vtkTransform (const vtkTransform&); // Not implemented
360  void operator=(const vtkTransform&); // Not implemented
361 };
362 
363 #endif
double * GetOrientationWXYZ()
Definition: vtkTransform.h:232
void RotateWXYZ(double angle, double x, double y, double z)
Definition: vtkTransform.h:90
void PreMultiply()
Definition: vtkTransform.h:148
double * GetScale()
Definition: vtkTransform.h:261
void Concatenate(const double elements[16])
Definition: vtkTransform.h:131
unsigned long GetMTime()
void PostMultiply()
Definition: vtkTransform.h:159
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:38
double * GetPosition()
Definition: vtkTransform.h:246
void SetMatrix(vtkMatrix4x4 *matrix)
Definition: vtkTransform.h:120
unsigned long MatrixUpdateMTime
Definition: vtkTransform.h:353
double * GetOrientation()
Definition: vtkTransform.h:214
void Scale(const float s[3])
Definition: vtkTransform.h:114
virtual vtkAbstractTransform * MakeTransform()=0
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:59
vtkAbstractTransform * GetInverse()
void Scale(double x, double y, double z)
Definition: vtkTransform.h:111
void MultiplyPoint(const float in[4], float out[4])
Definition: vtkMatrix4x4.h:121
void Concatenate(vtkMatrix4x4 *matrix)
Definition: vtkTransform.h:129
void RotateWXYZ(double angle, const double axis[3])
Definition: vtkTransform.h:92
void RotateY(double angle)
Definition: vtkTransform.h:103
void GetPosition(float pos[3])
Definition: vtkTransform.h:241
virtual int CircuitCheck(vtkAbstractTransform *transform)
vtkLinearTransform * GetInput()
Definition: vtkTransform.h:282
int GetNumberOfConcatenatedTransforms()
Definition: vtkTransform.h:167
#define VTKCOMMONTRANSFORMS_EXPORT
a simple class to control print indentation
Definition: vtkIndent.h:38
void GetScale(float scale[3])
Definition: vtkTransform.h:256
void InternalDeepCopy(vtkAbstractTransform *transform)
superclass for all geometric transformations
virtual void Modified()
virtual void Inverse()=0
void RotateWXYZ(double angle, const float axis[3])
Definition: vtkTransform.h:94
void Translate(const double x[3])
Definition: vtkTransform.h:81
void MultiplyPoint(const float in[4], float out[4])
Definition: vtkTransform.h:333
void Scale(const double s[3])
Definition: vtkTransform.h:113
void SetMatrix(const double elements[16])
Definition: vtkTransform.h:122
void GetOrientation(float orient[3])
Definition: vtkTransform.h:209
void RotateX(double angle)
Definition: vtkTransform.h:102
void MultiplyPoint(const double in[4], double out[4])
Definition: vtkTransform.h:335
double Element[4][4]
Definition: vtkMatrix4x4.h:50
vtkLinearTransform * GetConcatenatedTransform(int i)
Definition: vtkTransform.h:178
vtkTransformConcatenationStack * Stack
Definition: vtkTransform.h:349
vtkTransformConcatenation * Concatenation
Definition: vtkTransform.h:348
void Translate(double x, double y, double z)
Definition: vtkTransform.h:79
int GetInverseFlag()
Definition: vtkTransform.h:290
void GetOrientationWXYZ(float wxyz[4])
Definition: vtkTransform.h:226
static vtkObject * New()
static vtkTransformConcatenationStack * New()
void Translate(const float x[3])
Definition: vtkTransform.h:82
void PrintSelf(ostream &os, vtkIndent indent)
vtkAbstractTransform * GetInverse()
Definition: vtkTransform.h:320
abstract superclass for linear transformations
void RotateZ(double angle)
Definition: vtkTransform.h:104
vtkLinearTransform * Input
Definition: vtkTransform.h:347