00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00055
#ifndef __vtkTransform_h
00056
#define __vtkTransform_h
00057
00058
#include "vtkLinearTransform.h"
00059
00060
#include "vtkMatrix4x4.h"
00061
00062 class VTK_COMMON_EXPORT vtkTransform :
public vtkLinearTransform
00063 {
00064
public:
00065
static vtkTransform *
New();
00066 vtkTypeRevisionMacro(vtkTransform,
vtkLinearTransform);
00067
void PrintSelf(ostream& os,
vtkIndent indent);
00068
00072
void Identity();
00073
00077
void Inverse();
00078
00080
00082 void Translate(
double x,
double y,
double z) {
00083 this->Concatenation->Translate(x,y,z); };
00084 void Translate(
const double x[3]) { this->Translate(x[0], x[1], x[2]); };
00085 void Translate(
const float x[3]) { this->Translate(x[0], x[1], x[2]); };
00087
00089
00093 void RotateWXYZ(
double angle,
double x,
double y,
double z) {
00094 this->Concatenation->Rotate(angle,x,y,z); };
00095 void RotateWXYZ(
double angle,
const double axis[3]) {
00096 this->RotateWXYZ(angle, axis[0], axis[1], axis[2]); };
00097 void RotateWXYZ(
double angle,
const float axis[3]) {
00098 this->RotateWXYZ(angle, axis[0], axis[1], axis[2]); };
00100
00102
00105 void RotateX(
double angle) { this->RotateWXYZ(angle, 1, 0, 0); };
00106 void RotateY(
double angle) { this->RotateWXYZ(angle, 0, 1, 0); };
00107 void RotateZ(
double angle) { this->RotateWXYZ(angle, 0, 0, 1); };
00109
00111
00114 void Scale(
double x,
double y,
double z) {
00115 this->Concatenation->Scale(x,y,z); };
00116 void Scale(
const double s[3]) { this->Scale(s[0], s[1], s[2]); };
00117 void Scale(
const float s[3]) { this->Scale(s[0], s[1], s[2]); };
00119
00121
00123 void SetMatrix(
vtkMatrix4x4 *matrix) {
00124 this->SetMatrix(*matrix->
Element); };
00125 void SetMatrix(
const double elements[16]) {
00126 this->
Identity(); this->Concatenate(elements); };
00128
00130
00132 void Concatenate(
vtkMatrix4x4 *matrix) {
00133 this->Concatenate(*matrix->
Element); };
00134 void Concatenate(
const double elements[16]) {
00135 this->Concatenation->Concatenate(elements); };
00137
00143
void Concatenate(
vtkLinearTransform *transform);
00144
00146
00151 void PreMultiply() {
00152
if (this->Concatenation->GetPreMultiplyFlag()) {
return; }
00153 this->Concatenation->SetPreMultiplyFlag(1); this->
Modified(); };
00155
00157
00162 void PostMultiply() {
00163
if (!this->Concatenation->GetPreMultiplyFlag()) {
return; }
00164 this->Concatenation->SetPreMultiplyFlag(0); this->
Modified(); };
00166
00168
00170 int GetNumberOfConcatenatedTransforms() {
00171
return this->Concatenation->GetNumberOfTransforms() +
00172 (this->Input == NULL ? 0 : 1); };
00174
00176
00181 vtkLinearTransform *GetConcatenatedTransform(
int i) {
00182
if (this->Input == NULL) {
00183
return (
vtkLinearTransform *)this->Concatenation->GetTransform(i); }
00184
else if (i < this->Concatenation->GetNumberOfPreTransforms()) {
00185
return (
vtkLinearTransform *)this->Concatenation->GetTransform(i); }
00186
else if (i > this->Concatenation->GetNumberOfPreTransforms()) {
00187
return (
vtkLinearTransform *)this->Concatenation->GetTransform(i-1); }
00188
else if (this->GetInverseFlag()) {
00189
return (
vtkLinearTransform *)this->Input->GetInverse(); }
00190
else {
00191
return (
vtkLinearTransform *)this->Input; } };
00193
00195
00197
void GetOrientation(
double orient[3]);
00198 void GetOrientation(
float orient[3]) {
00199
double temp[3]; this->GetOrientation(temp);
00200 orient[0] = static_cast<float>(temp[0]);
00201 orient[1] = static_cast<float>(temp[1]);
00202 orient[2] = static_cast<float>(temp[2]); };
00203 float *GetOrientation() {
00204 this->GetOrientation(this->ReturnValue);
return this->ReturnValue; };
00206
00208
00209
void GetOrientationWXYZ(
double wxyz[4]);
00210 void GetOrientationWXYZ(
float wxyz[3]) {
00211
double temp[4]; this->GetOrientationWXYZ(temp);
00212 wxyz[0]=static_cast<float>(temp[0]);
00213 wxyz[1]=static_cast<float>(temp[1]);
00214 wxyz[2]=static_cast<float>(temp[2]);
00215 wxyz[3]=static_cast<float>(temp[3]);};
00216 float *GetOrientationWXYZ() {
00217 this->GetOrientationWXYZ(this->ReturnValue);
return this->ReturnValue; };
00219
00221
00224
void GetPosition(
double pos[3]);
00225 void GetPosition(
float pos[3]) {
00226
double temp[3]; this->GetPosition(temp);
00227 pos[0] = static_cast<float>(temp[0]);
00228 pos[1] = static_cast<float>(temp[1]);
00229 pos[2] = static_cast<float>(temp[2]); };
00230 float *GetPosition() {
00231 this->GetPosition(this->ReturnValue);
return this->ReturnValue; };
00233
00235
00239
void GetScale(
double scale[3]);
00240 void GetScale(
float scale[3]) {
00241
double temp[3]; this->GetScale(temp);
00242 scale[0] = static_cast<float>(temp[0]);
00243 scale[1] = static_cast<float>(temp[1]);
00244 scale[2] = static_cast<float>(temp[2]); };
00245 float *GetScale() {
00246 this->GetScale(this->ReturnValue);
return this->ReturnValue; };
00248
00251
void GetInverse(
vtkMatrix4x4 *inverse);
00252
00256
void GetTranspose(
vtkMatrix4x4 *transpose);
00257
00259
00265
void SetInput(
vtkLinearTransform *input);
00266 vtkLinearTransform *GetInput() {
return this->Input; };
00268
00270
00274 int GetInverseFlag() {
00275
return this->Concatenation->GetInverseFlag(); };
00277
00279
00280 void Push() {
if (this->Stack == NULL) {
00281 this->Stack =
vtkTransformConcatenationStack::New(); }
00282 this->Stack->Push(&this->Concatenation);
00283 this->
Modified(); };
00285
00287
00289 void Pop() {
if (this->Stack == NULL) {
return; }
00290 this->Stack->Pop(&this->Concatenation);
00291 this->
Modified(); };
00293
00300
int CircuitCheck(
vtkAbstractTransform *transform);
00301
00302
00303
00304 vtkAbstractTransform *
GetInverse() {
00305
return vtkLinearTransform::GetInverse(); }
00306
00308
vtkAbstractTransform *
MakeTransform();
00309
00311
unsigned long GetMTime();
00312
00314
00317 void MultiplyPoint(
const float in[4],
float out[4]) {
00318 this->
GetMatrix()->
MultiplyPoint(in,out);};
00319 void MultiplyPoint(
const double in[4],
double out[4]) {
00320 this->
GetMatrix()->
MultiplyPoint(in,out);};
00322
00323
protected:
00324 vtkTransform ();
00325 ~vtkTransform ();
00326
00327
void InternalDeepCopy(
vtkAbstractTransform *t);
00328
00329
void InternalUpdate();
00330
00331 vtkLinearTransform *Input;
00332 vtkTransformConcatenation *Concatenation;
00333 vtkTransformConcatenationStack *Stack;
00334
00335
00336
00337 unsigned long MatrixUpdateMTime;
00338
00339 float Point[4];
00340 double DoublePoint[4];
00341 float ReturnValue[4];
00342
private:
00343 vtkTransform (
const vtkTransform&);
00344
void operator=(
const vtkTransform&);
00345 };
00346
00347
#endif