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 vtkAbstractTransform *ForwardTransform;
00301 vtkAbstractTransform *InverseTransform;
00302
00303 void SwapForwardInverse() {
00304 vtkAbstractTransform *tmp = this->ForwardTransform;
00305 this->ForwardTransform = this->InverseTransform;
00306 this->InverseTransform = tmp; };
00307 };
00308
00309
00310
00311 class VTK_COMMON_EXPORT vtkTransformConcatenation
00312 {
00313 public:
00314 static vtkTransformConcatenation *New() {
00315 return new vtkTransformConcatenation(); };
00316 void Delete() { delete this; };
00317
00318
00319 void Concatenate(vtkAbstractTransform *transform);
00320
00321
00322 void Concatenate(const double elements[16]);
00323
00324
00325 void SetPreMultiplyFlag(int flag) { this->PreMultiplyFlag = flag; };
00326 int GetPreMultiplyFlag() { return this->PreMultiplyFlag; };
00327
00328
00329 void Translate(double x, double y, double z);
00330 void Rotate(double angle, double x, double y, double z);
00331 void Scale(double x, double y, double z);
00332
00333
00334 void Inverse();
00335
00336
00337 int GetInverseFlag() { return this->InverseFlag; };
00338
00339
00340 void Identity();
00341
00342
00343 void DeepCopy(vtkTransformConcatenation *transform);
00344
00345
00346 int GetNumberOfTransforms() { return this->NumberOfTransforms; };
00347
00348
00349
00350
00351 int GetNumberOfPreTransforms() { return this->NumberOfPreTransforms; };
00352
00353
00354 int GetNumberOfPostTransforms() {
00355 return this->NumberOfTransforms-this->NumberOfPreTransforms; };
00356
00357
00358 vtkAbstractTransform *GetTransform(int i);
00359
00360
00361 unsigned long GetMaxMTime();
00362
00363 void PrintSelf(ostream& os, vtkIndent indent);
00364
00365 protected:
00366 vtkTransformConcatenation();
00367 ~vtkTransformConcatenation();
00368
00369 int InverseFlag;
00370 int PreMultiplyFlag;
00371
00372 vtkMatrix4x4 *PreMatrix;
00373 vtkMatrix4x4 *PostMatrix;
00374 vtkAbstractTransform *PreMatrixTransform;
00375 vtkAbstractTransform *PostMatrixTransform;
00376
00377 int NumberOfTransforms;
00378 int NumberOfPreTransforms;
00379 int MaxNumberOfTransforms;
00380 vtkTransformPair *TransformList;
00381 };
00382
00383
00384
00385 class VTK_COMMON_EXPORT vtkTransformConcatenationStack
00386 {
00387 public:
00388 static vtkTransformConcatenationStack *New() {
00389 return new vtkTransformConcatenationStack(); };
00390 void Delete() { delete this; };
00391
00392
00393
00394 void Pop(vtkTransformConcatenation **concat);
00395
00396
00397
00398 void Push(vtkTransformConcatenation **concat);
00399
00400 void DeepCopy(vtkTransformConcatenationStack *stack);
00401
00402 protected:
00403 vtkTransformConcatenationStack();
00404 ~vtkTransformConcatenationStack();
00405
00406 int StackSize;
00407 vtkTransformConcatenation **Stack;
00408 vtkTransformConcatenation **StackBottom;
00409 };
00410
00411
00412
00413 #endif
00414
00415
00416
00417
00418