00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00048 #ifndef __vtkTransform_h
00049 #define __vtkTransform_h
00050
00051 #include "vtkLinearTransform.h"
00052
00053 #include "vtkMatrix4x4.h"
00054
00055 class VTK_COMMON_EXPORT vtkTransform : public vtkLinearTransform
00056 {
00057 public:
00058 static vtkTransform *New();
00059 vtkTypeRevisionMacro(vtkTransform,vtkLinearTransform);
00060 void PrintSelf(ostream& os, vtkIndent indent);
00061
00065 void Identity();
00066
00070 void Inverse();
00071
00073
00075 void Translate(double x, double y, double z) {
00076 this->Concatenation->Translate(x,y,z); };
00077 void Translate(const double x[3]) { this->Translate(x[0], x[1], x[2]); };
00078 void Translate(const float x[3]) { this->Translate(x[0], x[1], x[2]); };
00080
00082
00086 void RotateWXYZ(double angle, double x, double y, double z) {
00087 this->Concatenation->Rotate(angle,x,y,z); };
00088 void RotateWXYZ(double angle, const double axis[3]) {
00089 this->RotateWXYZ(angle, axis[0], axis[1], axis[2]); };
00090 void RotateWXYZ(double angle, const float axis[3]) {
00091 this->RotateWXYZ(angle, axis[0], axis[1], axis[2]); };
00093
00095
00098 void RotateX(double angle) { this->RotateWXYZ(angle, 1, 0, 0); };
00099 void RotateY(double angle) { this->RotateWXYZ(angle, 0, 1, 0); };
00100 void RotateZ(double angle) { this->RotateWXYZ(angle, 0, 0, 1); };
00102
00104
00107 void Scale(double x, double y, double z) {
00108 this->Concatenation->Scale(x,y,z); };
00109 void Scale(const double s[3]) { this->Scale(s[0], s[1], s[2]); };
00110 void Scale(const float s[3]) { this->Scale(s[0], s[1], s[2]); };
00112
00114
00116 void SetMatrix(vtkMatrix4x4 *matrix) {
00117 this->SetMatrix(*matrix->Element); };
00118 void SetMatrix(const double elements[16]) {
00119 this->Identity(); this->Concatenate(elements); };
00121
00123
00125 void Concatenate(vtkMatrix4x4 *matrix) {
00126 this->Concatenate(*matrix->Element); };
00127 void Concatenate(const double elements[16]) {
00128 this->Concatenation->Concatenate(elements); };
00130
00136 void Concatenate(vtkLinearTransform *transform);
00137
00139
00144 void PreMultiply() {
00145 if (this->Concatenation->GetPreMultiplyFlag()) { return; }
00146 this->Concatenation->SetPreMultiplyFlag(1); this->Modified(); };
00148
00150
00155 void PostMultiply() {
00156 if (!this->Concatenation->GetPreMultiplyFlag()) { return; }
00157 this->Concatenation->SetPreMultiplyFlag(0); this->Modified(); };
00159
00161
00163 int GetNumberOfConcatenatedTransforms() {
00164 return this->Concatenation->GetNumberOfTransforms() +
00165 (this->Input == NULL ? 0 : 1); };
00167
00169
00174 vtkLinearTransform *GetConcatenatedTransform(int i)
00175 {
00176 vtkAbstractTransform *t;
00177 if (this->Input == NULL)
00178 {
00179 t=this->Concatenation->GetTransform(i);
00180 }
00181 else if (i < this->Concatenation->GetNumberOfPreTransforms())
00182 {
00183 t=this->Concatenation->GetTransform(i);
00184 }
00185 else if (i > this->Concatenation->GetNumberOfPreTransforms())
00186 {
00187 t=this->Concatenation->GetTransform(i-1);
00188 }
00189 else if (this->GetInverseFlag())
00190 {
00191 t=this->Input->GetInverse();
00192 }
00193 else
00194 {
00195 t=this->Input;
00196 }
00197 return static_cast<vtkLinearTransform *>(t);
00198 }
00200
00202
00204 void GetOrientation(double orient[3]);
00205 void GetOrientation(float orient[3]) {
00206 double temp[3]; this->GetOrientation(temp);
00207 orient[0] = static_cast<float>(temp[0]);
00208 orient[1] = static_cast<float>(temp[1]);
00209 orient[2] = static_cast<float>(temp[2]); };
00210 double *GetOrientation() {
00211 this->GetOrientation(this->ReturnValue); return this->ReturnValue; };
00213
00216 static void GetOrientation(double orient[3], vtkMatrix4x4 *matrix);
00217
00219
00221 void GetOrientationWXYZ(double wxyz[4]);
00222 void GetOrientationWXYZ(float wxyz[4]) {
00223 double temp[4]; this->GetOrientationWXYZ(temp);
00224 wxyz[0]=static_cast<float>(temp[0]);
00225 wxyz[1]=static_cast<float>(temp[1]);
00226 wxyz[2]=static_cast<float>(temp[2]);
00227 wxyz[3]=static_cast<float>(temp[3]);};
00228 double *GetOrientationWXYZ() {
00229 this->GetOrientationWXYZ(this->ReturnValue); return this->ReturnValue; };
00231
00233
00236 void GetPosition(double pos[3]);
00237 void GetPosition(float pos[3]) {
00238 double temp[3]; this->GetPosition(temp);
00239 pos[0] = static_cast<float>(temp[0]);
00240 pos[1] = static_cast<float>(temp[1]);
00241 pos[2] = static_cast<float>(temp[2]); };
00242 double *GetPosition() {
00243 this->GetPosition(this->ReturnValue); return this->ReturnValue; };
00245
00247
00251 void GetScale(double scale[3]);
00252 void GetScale(float scale[3]) {
00253 double temp[3]; this->GetScale(temp);
00254 scale[0] = static_cast<float>(temp[0]);
00255 scale[1] = static_cast<float>(temp[1]);
00256 scale[2] = static_cast<float>(temp[2]); };
00257 double *GetScale() {
00258 this->GetScale(this->ReturnValue); return this->ReturnValue; };
00260
00263 void GetInverse(vtkMatrix4x4 *inverse);
00264
00268 void GetTranspose(vtkMatrix4x4 *transpose);
00269
00271
00277 void SetInput(vtkLinearTransform *input);
00278 vtkLinearTransform *GetInput() { return this->Input; };
00280
00282
00286 int GetInverseFlag() {
00287 return this->Concatenation->GetInverseFlag(); };
00289
00291
00292 void Push() { if (this->Stack == NULL) {
00293 this->Stack = vtkTransformConcatenationStack::New(); }
00294 this->Stack->Push(&this->Concatenation);
00295 this->Modified(); };
00297
00299
00301 void Pop() { if (this->Stack == NULL) { return; }
00302 this->Stack->Pop(&this->Concatenation);
00303 this->Modified(); };
00305
00312 int CircuitCheck(vtkAbstractTransform *transform);
00313
00314
00315
00316 vtkAbstractTransform *GetInverse() {
00317 return vtkLinearTransform::GetInverse(); }
00318
00320 vtkAbstractTransform *MakeTransform();
00321
00323 unsigned long GetMTime();
00324
00326
00329 void MultiplyPoint(const float in[4], float out[4]) {
00330 this->GetMatrix()->MultiplyPoint(in,out);};
00331 void MultiplyPoint(const double in[4], double out[4]) {
00332 this->GetMatrix()->MultiplyPoint(in,out);};
00334
00335 protected:
00336 vtkTransform ();
00337 ~vtkTransform ();
00338
00339 void InternalDeepCopy(vtkAbstractTransform *t);
00340
00341 void InternalUpdate();
00342
00343 vtkLinearTransform *Input;
00344 vtkTransformConcatenation *Concatenation;
00345 vtkTransformConcatenationStack *Stack;
00346
00347
00348
00349 unsigned long MatrixUpdateMTime;
00350
00351 float Point[4];
00352 double DoublePoint[4];
00353 double ReturnValue[4];
00354 private:
00355 vtkTransform (const vtkTransform&);
00356 void operator=(const vtkTransform&);
00357 };
00358
00359 #endif