00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00038 #ifndef __vtkAbstractTransform_h
00039 #define __vtkAbstractTransform_h
00040
00041 #include "vtkObject.h"
00042
00043 class vtkDataArray;
00044 class vtkMatrix4x4;
00045 class vtkPoints;
00046 class vtkSimpleCriticalSection;
00047
00048 class VTK_COMMON_EXPORT vtkAbstractTransform : public vtkObject
00049 {
00050 public:
00051
00052 vtkTypeRevisionMacro(vtkAbstractTransform,vtkObject);
00053 void PrintSelf(ostream& os, vtkIndent indent);
00054
00056
00058 void TransformPoint(const float in[3], float out[3]) {
00059 this->Update(); this->InternalTransformPoint(in,out); };
00061
00063
00065 void TransformPoint(const double in[3], double out[3]) {
00066 this->Update(); this->InternalTransformPoint(in,out); };
00068
00070
00072 double *TransformPoint(double x, double y, double z) {
00073 return this->TransformDoublePoint(x,y,z); }
00074 double *TransformPoint(const double point[3]) {
00075 return this->TransformPoint(point[0],point[1],point[2]); };
00077
00079
00081 float *TransformFloatPoint(float x, float y, float z) {
00082 this->InternalFloatPoint[0] = x;
00083 this->InternalFloatPoint[1] = y;
00084 this->InternalFloatPoint[2] = z;
00085 this->TransformPoint(this->InternalFloatPoint,this->InternalFloatPoint);
00086 return this->InternalFloatPoint; };
00087 float *TransformFloatPoint(const float point[3]) {
00088 return this->TransformFloatPoint(point[0],point[1],point[2]); };
00090
00092
00094 double *TransformDoublePoint(double x, double y, double z) {
00095 this->InternalDoublePoint[0] = x;
00096 this->InternalDoublePoint[1] = y;
00097 this->InternalDoublePoint[2] = z;
00098 this->TransformPoint(this->InternalDoublePoint,this->InternalDoublePoint);
00099 return this->InternalDoublePoint; };
00100 double *TransformDoublePoint(const double point[3]) {
00101 return this->TransformDoublePoint(point[0],point[1],point[2]); };
00103
00105
00108 void TransformNormalAtPoint(const float point[3], const float in[3],
00109 float out[3]);
00110 void TransformNormalAtPoint(const double point[3], const double in[3],
00111 double out[3]);
00113
00114 double *TransformNormalAtPoint(const double point[3],
00115 const double normal[3]) {
00116 this->TransformNormalAtPoint(point,normal,this->InternalDoublePoint);
00117 return this->InternalDoublePoint; };
00118
00120
00123 double *TransformDoubleNormalAtPoint(const double point[3],
00124 const double normal[3]) {
00125 this->TransformNormalAtPoint(point,normal,this->InternalDoublePoint);
00126 return this->InternalDoublePoint; };
00128
00130
00133 float *TransformFloatNormalAtPoint(const float point[3],
00134 const float normal[3]) {
00135 this->TransformNormalAtPoint(point,normal,this->InternalFloatPoint);
00136 return this->InternalFloatPoint; };
00138
00140
00143 void TransformVectorAtPoint(const float point[3], const float in[3],
00144 float out[3]);
00145 void TransformVectorAtPoint(const double point[3], const double in[3],
00146 double out[3]);
00148
00149 double *TransformVectorAtPoint(const double point[3],
00150 const double vector[3]) {
00151 this->TransformVectorAtPoint(point,vector,this->InternalDoublePoint);
00152 return this->InternalDoublePoint; };
00153
00155
00158 double *TransformDoubleVectorAtPoint(const double point[3],
00159 const double vector[3]) {
00160 this->TransformVectorAtPoint(point,vector,this->InternalDoublePoint);
00161 return this->InternalDoublePoint; };
00163
00165
00168 float *TransformFloatVectorAtPoint(const float point[3],
00169 const float vector[3]) {
00170 this->TransformVectorAtPoint(point,vector,this->InternalFloatPoint);
00171 return this->InternalFloatPoint; };
00173
00176 virtual void TransformPoints(vtkPoints *inPts, vtkPoints *outPts);
00177
00179
00181 virtual void TransformPointsNormalsVectors(vtkPoints *inPts,
00182 vtkPoints *outPts,
00183 vtkDataArray *inNms,
00184 vtkDataArray *outNms,
00185 vtkDataArray *inVrs,
00186 vtkDataArray *outVrs);
00188
00194 vtkAbstractTransform *GetInverse();
00195
00199 void SetInverse(vtkAbstractTransform *transform);
00200
00202 virtual void Inverse() = 0;
00203
00205 void DeepCopy(vtkAbstractTransform *);
00206
00210 void Update();
00211
00213
00215 virtual void InternalTransformPoint(const float in[3], float out[3]) = 0;
00216 virtual void InternalTransformPoint(const double in[3], double out[3]) = 0;
00218
00220
00224 virtual void InternalTransformDerivative(const float in[3], float out[3],
00225 float derivative[3][3]) = 0;
00226 virtual void InternalTransformDerivative(const double in[3], double out[3],
00227 double derivative[3][3]) = 0;
00229
00231 virtual vtkAbstractTransform *MakeTransform() = 0;
00232
00239 virtual int CircuitCheck(vtkAbstractTransform *transform);
00240
00242 unsigned long GetMTime();
00243
00246 virtual void UnRegister(vtkObjectBase *O);
00247
00250 VTK_LEGACY(void Identity());
00251
00252 protected:
00253 vtkAbstractTransform();
00254 ~vtkAbstractTransform();
00255
00257 virtual void InternalUpdate() {};
00258
00260 virtual void InternalDeepCopy(vtkAbstractTransform *) {};
00261
00262 float InternalFloatPoint[3];
00263 double InternalDoublePoint[3];
00264
00265 private:
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275 vtkTimeStamp UpdateTime;
00276 vtkSimpleCriticalSection *UpdateMutex;
00277 vtkSimpleCriticalSection *InverseMutex;
00278 int DependsOnInverse;
00279
00280
00281
00282
00283 vtkAbstractTransform *MyInverse;
00284
00285 int InUnRegister;
00286
00287 private:
00288 vtkAbstractTransform(const vtkAbstractTransform&);
00289 void operator=(const vtkAbstractTransform&);
00290 };
00291
00292
00293
00294
00295
00296
00297 class vtkTransformPair
00298 {
00299 public:
00300 vtkTransformPair() {};
00301
00302 vtkAbstractTransform *ForwardTransform;
00303 vtkAbstractTransform *InverseTransform;
00304
00305 void SwapForwardInverse() {
00306 vtkAbstractTransform *tmp = this->ForwardTransform;
00307 this->ForwardTransform = this->InverseTransform;
00308 this->InverseTransform = tmp; };
00309 };
00310
00311
00312
00313 class VTK_COMMON_EXPORT vtkTransformConcatenation
00314 {
00315 public:
00316 static vtkTransformConcatenation *New() {
00317 return new vtkTransformConcatenation(); };
00318 void Delete() { delete this; };
00319
00320
00321 void Concatenate(vtkAbstractTransform *transform);
00322
00323
00324 void Concatenate(const double elements[16]);
00325
00326
00327 void SetPreMultiplyFlag(int flag) { this->PreMultiplyFlag = flag; };
00328 int GetPreMultiplyFlag() { return this->PreMultiplyFlag; };
00329
00330
00331 void Translate(double x, double y, double z);
00332 void Rotate(double angle, double x, double y, double z);
00333 void Scale(double x, double y, double z);
00334
00335
00336 void Inverse();
00337
00338
00339 int GetInverseFlag() { return this->InverseFlag; };
00340
00341
00342 void Identity();
00343
00344
00345 void DeepCopy(vtkTransformConcatenation *transform);
00346
00347
00348 int GetNumberOfTransforms() { return this->NumberOfTransforms; };
00349
00350
00351
00352
00353 int GetNumberOfPreTransforms() { return this->NumberOfPreTransforms; };
00354
00355
00356 int GetNumberOfPostTransforms() {
00357 return this->NumberOfTransforms-this->NumberOfPreTransforms; };
00358
00359
00360 vtkAbstractTransform *GetTransform(int i);
00361
00362
00363 unsigned long GetMaxMTime();
00364
00365 void PrintSelf(ostream& os, vtkIndent indent);
00366
00367 protected:
00368 vtkTransformConcatenation();
00369 ~vtkTransformConcatenation();
00370
00371 int InverseFlag;
00372 int PreMultiplyFlag;
00373
00374 vtkMatrix4x4 *PreMatrix;
00375 vtkMatrix4x4 *PostMatrix;
00376 vtkAbstractTransform *PreMatrixTransform;
00377 vtkAbstractTransform *PostMatrixTransform;
00378
00379 int NumberOfTransforms;
00380 int NumberOfPreTransforms;
00381 int MaxNumberOfTransforms;
00382 vtkTransformPair *TransformList;
00383 };
00384
00385
00386
00387 class VTK_COMMON_EXPORT vtkTransformConcatenationStack
00388 {
00389 public:
00390 static vtkTransformConcatenationStack *New() {
00391 return new vtkTransformConcatenationStack(); };
00392 void Delete() { delete this; };
00393
00394
00395
00396 void Pop(vtkTransformConcatenation **concat);
00397
00398
00399
00400 void Push(vtkTransformConcatenation **concat);
00401
00402 void DeepCopy(vtkTransformConcatenationStack *stack);
00403
00404 protected:
00405 vtkTransformConcatenationStack();
00406 ~vtkTransformConcatenationStack();
00407
00408 int StackSize;
00409 vtkTransformConcatenation **Stack;
00410 vtkTransformConcatenation **StackBottom;
00411 };
00412
00413
00414
00415 #endif
00416
00417
00418
00419
00420