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 "vtkLinearTransform.h"
55 
56 #include "vtkMatrix4x4.h" // Needed for inline methods
57 
59 {
60  public:
61  static vtkTransform *New();
63  void PrintSelf(ostream& os, vtkIndent indent);
64 
68  void Identity();
69 
73  void Inverse();
74 
76 
78  void Translate(double x, double y, double z) {
79  this->Concatenation->Translate(x,y,z); };
80  void Translate(const double x[3]) { this->Translate(x[0], x[1], x[2]); };
81  void Translate(const float x[3]) { this->Translate(x[0], x[1], x[2]); };
83 
85 
89  void RotateWXYZ(double angle, double x, double y, double z) {
90  this->Concatenation->Rotate(angle,x,y,z); };
91  void RotateWXYZ(double angle, const double axis[3]) {
92  this->RotateWXYZ(angle, axis[0], axis[1], axis[2]); };
93  void RotateWXYZ(double angle, const float axis[3]) {
94  this->RotateWXYZ(angle, axis[0], axis[1], axis[2]); };
96 
98 
101  void RotateX(double angle) { this->RotateWXYZ(angle, 1, 0, 0); };
102  void RotateY(double angle) { this->RotateWXYZ(angle, 0, 1, 0); };
103  void RotateZ(double angle) { this->RotateWXYZ(angle, 0, 0, 1); };
105 
107 
110  void Scale(double x, double y, double z) {
111  this->Concatenation->Scale(x,y,z); };
112  void Scale(const double s[3]) { this->Scale(s[0], s[1], s[2]); };
113  void Scale(const float s[3]) { this->Scale(s[0], s[1], s[2]); };
115 
117 
119  void SetMatrix(vtkMatrix4x4 *matrix) {
120  this->SetMatrix(*matrix->Element); };
121  void SetMatrix(const double elements[16]) {
122  this->Identity(); this->Concatenate(elements); };
124 
126 
128  void Concatenate(vtkMatrix4x4 *matrix) {
129  this->Concatenate(*matrix->Element); };
130  void Concatenate(const double elements[16]) {
131  this->Concatenation->Concatenate(elements); };
133 
139  void Concatenate(vtkLinearTransform *transform);
140 
142 
147  void PreMultiply() {
148  if (this->Concatenation->GetPreMultiplyFlag()) { return; }
149  this->Concatenation->SetPreMultiplyFlag(1); this->Modified(); };
151 
153 
158  void PostMultiply() {
159  if (!this->Concatenation->GetPreMultiplyFlag()) { return; }
160  this->Concatenation->SetPreMultiplyFlag(0); this->Modified(); };
162 
164 
167  return this->Concatenation->GetNumberOfTransforms() +
168  (this->Input == NULL ? 0 : 1); };
170 
172 
178  {
180  if (this->Input == NULL)
181  {
182  t=this->Concatenation->GetTransform(i);
183  }
184  else if (i < this->Concatenation->GetNumberOfPreTransforms())
185  {
186  t=this->Concatenation->GetTransform(i);
187  }
188  else if (i > this->Concatenation->GetNumberOfPreTransforms())
189  {
190  t=this->Concatenation->GetTransform(i-1);
191  }
192  else if (this->GetInverseFlag())
193  {
194  t=this->Input->GetInverse();
195  }
196  else
197  {
198  t=this->Input;
199  }
200  return static_cast<vtkLinearTransform *>(t);
201  }
203 
205 
207  void GetOrientation(double orient[3]);
208  void GetOrientation(float orient[3]) {
209  double temp[3]; this->GetOrientation(temp);
210  orient[0] = static_cast<float>(temp[0]);
211  orient[1] = static_cast<float>(temp[1]);
212  orient[2] = static_cast<float>(temp[2]); };
213  double *GetOrientation() {
214  this->GetOrientation(this->ReturnValue); return this->ReturnValue; };
216 
219  static void GetOrientation(double orient[3], vtkMatrix4x4 *matrix);
220 
222 
224  void GetOrientationWXYZ(double wxyz[4]);
225  void GetOrientationWXYZ(float wxyz[4]) {
226  double temp[4]; this->GetOrientationWXYZ(temp);
227  wxyz[0]=static_cast<float>(temp[0]);
228  wxyz[1]=static_cast<float>(temp[1]);
229  wxyz[2]=static_cast<float>(temp[2]);
230  wxyz[3]=static_cast<float>(temp[3]);};
231  double *GetOrientationWXYZ() {
232  this->GetOrientationWXYZ(this->ReturnValue); return this->ReturnValue; };
234 
236 
239  void GetPosition(double pos[3]);
240  void GetPosition(float pos[3]) {
241  double temp[3]; this->GetPosition(temp);
242  pos[0] = static_cast<float>(temp[0]);
243  pos[1] = static_cast<float>(temp[1]);
244  pos[2] = static_cast<float>(temp[2]); };
245  double *GetPosition() {
246  this->GetPosition(this->ReturnValue); return this->ReturnValue; };
248 
250 
254  void GetScale(double scale[3]);
255  void GetScale(float scale[3]) {
256  double temp[3]; this->GetScale(temp);
257  scale[0] = static_cast<float>(temp[0]);
258  scale[1] = static_cast<float>(temp[1]);
259  scale[2] = static_cast<float>(temp[2]); };
260  double *GetScale() {
261  this->GetScale(this->ReturnValue); return this->ReturnValue; };
263 
266  void GetInverse(vtkMatrix4x4 *inverse);
267 
271  void GetTranspose(vtkMatrix4x4 *transpose);
272 
274 
280  void SetInput(vtkLinearTransform *input);
281  vtkLinearTransform *GetInput() { return this->Input; };
283 
285 
290  return this->Concatenation->GetInverseFlag(); };
292 
294 
295  void Push() { if (this->Stack == NULL) {
296  this->Stack = vtkTransformConcatenationStack::New(); }
297  this->Stack->Push(&this->Concatenation);
298  this->Modified(); };
300 
302 
304  void Pop() { if (this->Stack == NULL) { return; }
305  this->Stack->Pop(&this->Concatenation);
306  this->Modified(); };
308 
315  int CircuitCheck(vtkAbstractTransform *transform);
316 
317  // Return an inverse transform which will always update itself
318  // to match this transform.
321 
324 
326  unsigned long GetMTime();
327 
329 
332  void MultiplyPoint(const float in[4], float out[4]) {
333  this->GetMatrix()->MultiplyPoint(in,out);};
334  void MultiplyPoint(const double in[4], double out[4]) {
335  this->GetMatrix()->MultiplyPoint(in,out);};
337 
338 protected:
339  vtkTransform ();
340  ~vtkTransform ();
341 
343 
344  void InternalUpdate();
345 
349 
350  // this allows us to check whether people have been fooling
351  // around with our matrix
352  unsigned long MatrixUpdateMTime;
353 
354  float Point[4];
355  double DoublePoint[4];
356  double ReturnValue[4];
357 private:
358  vtkTransform (const vtkTransform&); // Not implemented
359  void operator=(const vtkTransform&); // Not implemented
360 };
361 
362 #endif
double * GetOrientationWXYZ()
Definition: vtkTransform.h:231
void RotateWXYZ(double angle, double x, double y, double z)
Definition: vtkTransform.h:89
void PreMultiply()
Definition: vtkTransform.h:147
double * GetScale()
Definition: vtkTransform.h:260
void Concatenate(const double elements[16])
Definition: vtkTransform.h:130
unsigned long GetMTime()
void PostMultiply()
Definition: vtkTransform.h:158
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:37
double * GetPosition()
Definition: vtkTransform.h:245
void SetMatrix(vtkMatrix4x4 *matrix)
Definition: vtkTransform.h:119
unsigned long MatrixUpdateMTime
Definition: vtkTransform.h:352
double * GetOrientation()
Definition: vtkTransform.h:213
void Scale(const float s[3])
Definition: vtkTransform.h:113
virtual vtkAbstractTransform * MakeTransform()=0
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:58
vtkAbstractTransform * GetInverse()
void Scale(double x, double y, double z)
Definition: vtkTransform.h:110
void MultiplyPoint(const float in[4], float out[4])
Definition: vtkMatrix4x4.h:120
void Concatenate(vtkMatrix4x4 *matrix)
Definition: vtkTransform.h:128
void RotateWXYZ(double angle, const double axis[3])
Definition: vtkTransform.h:91
void RotateY(double angle)
Definition: vtkTransform.h:102
void GetPosition(float pos[3])
Definition: vtkTransform.h:240
virtual int CircuitCheck(vtkAbstractTransform *transform)
vtkLinearTransform * GetInput()
Definition: vtkTransform.h:281
int GetNumberOfConcatenatedTransforms()
Definition: vtkTransform.h:166
a simple class to control print indentation
Definition: vtkIndent.h:37
void GetScale(float scale[3])
Definition: vtkTransform.h:255
void InternalDeepCopy(vtkAbstractTransform *transform)
superclass for all geometric transformations
#define VTK_COMMON_EXPORT
virtual void Modified()
virtual void Inverse()=0
void RotateWXYZ(double angle, const float axis[3])
Definition: vtkTransform.h:93
void Translate(const double x[3])
Definition: vtkTransform.h:80
void MultiplyPoint(const float in[4], float out[4])
Definition: vtkTransform.h:332
void Scale(const double s[3])
Definition: vtkTransform.h:112
void SetMatrix(const double elements[16])
Definition: vtkTransform.h:121
void GetOrientation(float orient[3])
Definition: vtkTransform.h:208
void RotateX(double angle)
Definition: vtkTransform.h:101
void MultiplyPoint(const double in[4], double out[4])
Definition: vtkTransform.h:334
double Element[4][4]
Definition: vtkMatrix4x4.h:49
vtkLinearTransform * GetConcatenatedTransform(int i)
Definition: vtkTransform.h:177
vtkTransformConcatenationStack * Stack
Definition: vtkTransform.h:348
vtkTransformConcatenation * Concatenation
Definition: vtkTransform.h:347
void Translate(double x, double y, double z)
Definition: vtkTransform.h:78
int GetInverseFlag()
Definition: vtkTransform.h:289
void GetOrientationWXYZ(float wxyz[4])
Definition: vtkTransform.h:225
static vtkObject * New()
static vtkTransformConcatenationStack * New()
void Translate(const float x[3])
Definition: vtkTransform.h:81
void PrintSelf(ostream &os, vtkIndent indent)
vtkAbstractTransform * GetInverse()
Definition: vtkTransform.h:319
abstract superclass for linear transformations
void RotateZ(double angle)
Definition: vtkTransform.h:103
vtkLinearTransform * Input
Definition: vtkTransform.h:346