00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00066 #ifndef __vtkTransform_h
00067 #define __vtkTransform_h
00068
00069 #include "vtkLinearTransform.h"
00070
00071 #include "vtkMatrix4x4.h"
00072
00073 class VTK_COMMON_EXPORT vtkTransform : public vtkLinearTransform
00074 {
00075 public:
00076 static vtkTransform *New();
00077 vtkTypeRevisionMacro(vtkTransform,vtkLinearTransform);
00078 void PrintSelf(ostream& os, vtkIndent indent);
00079
00083 void Identity();
00084
00088 void Inverse();
00089
00091
00093 void Translate(double x, double y, double z) {
00094 this->Concatenation->Translate(x,y,z); };
00095 void Translate(const double x[3]) { this->Translate(x[0], x[1], x[2]); };
00096 void Translate(const float x[3]) { this->Translate(x[0], x[1], x[2]); };
00098
00100
00104 void RotateWXYZ(double angle, double x, double y, double z) {
00105 this->Concatenation->Rotate(angle,x,y,z); };
00106 void RotateWXYZ(double angle, const double axis[3]) {
00107 this->RotateWXYZ(angle, axis[0], axis[1], axis[2]); };
00108 void RotateWXYZ(double angle, const float axis[3]) {
00109 this->RotateWXYZ(angle, axis[0], axis[1], axis[2]); };
00111
00113
00116 void RotateX(double angle) { this->RotateWXYZ(angle, 1, 0, 0); };
00117 void RotateY(double angle) { this->RotateWXYZ(angle, 0, 1, 0); };
00118 void RotateZ(double angle) { this->RotateWXYZ(angle, 0, 0, 1); };
00120
00122
00125 void Scale(double x, double y, double z) {
00126 this->Concatenation->Scale(x,y,z); };
00127 void Scale(const double s[3]) { this->Scale(s[0], s[1], s[2]); };
00128 void Scale(const float s[3]) { this->Scale(s[0], s[1], s[2]); };
00130
00132
00134 void SetMatrix(vtkMatrix4x4 *matrix) {
00135 this->SetMatrix(*matrix->Element); };
00136 void SetMatrix(const double elements[16]) {
00137 this->Identity(); this->Concatenate(elements); };
00139
00141
00143 void Concatenate(vtkMatrix4x4 *matrix) {
00144 this->Concatenate(*matrix->Element); };
00145 void Concatenate(const double elements[16]) {
00146 this->Concatenation->Concatenate(elements); };
00148
00154 void Concatenate(vtkLinearTransform *transform);
00155
00157
00162 void PreMultiply() {
00163 if (this->Concatenation->GetPreMultiplyFlag()) { return; }
00164 this->Concatenation->SetPreMultiplyFlag(1); this->Modified(); };
00166
00168
00173 void PostMultiply() {
00174 if (!this->Concatenation->GetPreMultiplyFlag()) { return; }
00175 this->Concatenation->SetPreMultiplyFlag(0); this->Modified(); };
00177
00179
00181 int GetNumberOfConcatenatedTransforms() {
00182 return this->Concatenation->GetNumberOfTransforms() +
00183 (this->Input == NULL ? 0 : 1); };
00185
00187
00192 vtkLinearTransform *GetConcatenatedTransform(int i) {
00193 if (this->Input == NULL) {
00194 return (vtkLinearTransform *)this->Concatenation->GetTransform(i); }
00195 else if (i < this->Concatenation->GetNumberOfPreTransforms()) {
00196 return (vtkLinearTransform *)this->Concatenation->GetTransform(i); }
00197 else if (i > this->Concatenation->GetNumberOfPreTransforms()) {
00198 return (vtkLinearTransform *)this->Concatenation->GetTransform(i-1); }
00199 else if (this->GetInverseFlag()) {
00200 return (vtkLinearTransform *)this->Input->GetInverse(); }
00201 else {
00202 return (vtkLinearTransform *)this->Input; } };
00204
00206
00208 void GetOrientation(double orient[3]);
00209 void GetOrientation(float orient[3]) {
00210 double temp[3]; this->GetOrientation(temp);
00211 orient[0] = static_cast<float>(temp[0]);
00212 orient[1] = static_cast<float>(temp[1]);
00213 orient[2] = static_cast<float>(temp[2]); };
00214 double *GetOrientation() {
00215 this->GetOrientation(this->ReturnValue); return this->ReturnValue; };
00217
00220 static void GetOrientation(double orient[3], vtkMatrix4x4 *matrix);
00221
00223
00224 void GetOrientationWXYZ(double wxyz[4]);
00225 void GetOrientationWXYZ(float wxyz[3]) {
00226 double temp[4]; this->GetOrientationWXYZ(temp);
00227 wxyz[0]=static_cast<float>(temp[0]);
00228 wxyz[1]=static_cast<float>(temp[1]);
00229 wxyz[2]=static_cast<float>(temp[2]);
00230 wxyz[3]=static_cast<float>(temp[3]);};
00231 double *GetOrientationWXYZ() {
00232 this->GetOrientationWXYZ(this->ReturnValue); return this->ReturnValue; };
00234
00236
00239 void GetPosition(double pos[3]);
00240 void GetPosition(float pos[3]) {
00241 double temp[3]; this->GetPosition(temp);
00242 pos[0] = static_cast<float>(temp[0]);
00243 pos[1] = static_cast<float>(temp[1]);
00244 pos[2] = static_cast<float>(temp[2]); };
00245 double *GetPosition() {
00246 this->GetPosition(this->ReturnValue); return this->ReturnValue; };
00248
00250
00254 void GetScale(double scale[3]);
00255 void GetScale(float scale[3]) {
00256 double temp[3]; this->GetScale(temp);
00257 scale[0] = static_cast<float>(temp[0]);
00258 scale[1] = static_cast<float>(temp[1]);
00259 scale[2] = static_cast<float>(temp[2]); };
00260 double *GetScale() {
00261 this->GetScale(this->ReturnValue); return this->ReturnValue; };
00263
00266 void GetInverse(vtkMatrix4x4 *inverse);
00267
00271 void GetTranspose(vtkMatrix4x4 *transpose);
00272
00274
00280 void SetInput(vtkLinearTransform *input);
00281 vtkLinearTransform *GetInput() { return this->Input; };
00283
00285
00289 int GetInverseFlag() {
00290 return this->Concatenation->GetInverseFlag(); };
00292
00294
00295 void Push() { if (this->Stack == NULL) {
00296 this->Stack = vtkTransformConcatenationStack::New(); }
00297 this->Stack->Push(&this->Concatenation);
00298 this->Modified(); };
00300
00302
00304 void Pop() { if (this->Stack == NULL) { return; }
00305 this->Stack->Pop(&this->Concatenation);
00306 this->Modified(); };
00308
00315 int CircuitCheck(vtkAbstractTransform *transform);
00316
00317
00318
00319 vtkAbstractTransform *GetInverse() {
00320 return vtkLinearTransform::GetInverse(); }
00321
00323 vtkAbstractTransform *MakeTransform();
00324
00326 unsigned long GetMTime();
00327
00329
00332 void MultiplyPoint(const float in[4], float out[4]) {
00333 this->GetMatrix()->MultiplyPoint(in,out);};
00334 void MultiplyPoint(const double in[4], double out[4]) {
00335 this->GetMatrix()->MultiplyPoint(in,out);};
00337
00338 protected:
00339 vtkTransform ();
00340 ~vtkTransform ();
00341
00342 void InternalDeepCopy(vtkAbstractTransform *t);
00343
00344 void InternalUpdate();
00345
00346 vtkLinearTransform *Input;
00347 vtkTransformConcatenation *Concatenation;
00348 vtkTransformConcatenationStack *Stack;
00349
00350
00351
00352 unsigned long MatrixUpdateMTime;
00353
00354 float Point[4];
00355 double DoublePoint[4];
00356 double ReturnValue[4];
00357 private:
00358 vtkTransform (const vtkTransform&);
00359 void operator=(const vtkTransform&);
00360 };
00361
00362 #endif