00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00052 #ifndef __vtkAbstractTransform_h
00053 #define __vtkAbstractTransform_h
00054
00055 #include "vtkObject.h"
00056
00057
00058
00059
00060 class vtkDataArray;
00061 class vtkMatrix4x4;
00062 class vtkPoints;
00063 class vtkSimpleCriticalSection;
00064
00065
00066 class VTK_COMMON_EXPORT vtkAbstractTransform : public vtkObject
00067 {
00068 public:
00069
00070 vtkTypeRevisionMacro(vtkAbstractTransform,vtkObject);
00071 void PrintSelf(ostream& os, vtkIndent indent);
00072
00074
00076 void TransformPoint(const float in[3], float out[3]) {
00077 this->Update(); this->InternalTransformPoint(in,out); };
00079
00081
00083 void TransformPoint(const double in[3], double out[3]) {
00084 this->Update(); this->InternalTransformPoint(in,out); };
00086
00088
00090 double *TransformPoint(double x, double y, double z) {
00091 return this->TransformDoublePoint(x,y,z); }
00092 double *TransformPoint(const double point[3]) {
00093 return this->TransformPoint(point[0],point[1],point[2]); };
00095
00097
00099 float *TransformFloatPoint(float x, float y, float z) {
00100 this->InternalFloatPoint[0] = x;
00101 this->InternalFloatPoint[1] = y;
00102 this->InternalFloatPoint[2] = z;
00103 this->TransformPoint(this->InternalFloatPoint,this->InternalFloatPoint);
00104 return this->InternalFloatPoint; };
00105 float *TransformFloatPoint(const float point[3]) {
00106 return this->TransformFloatPoint(point[0],point[1],point[2]); };
00108
00110
00112 double *TransformDoublePoint(double x, double y, double z) {
00113 this->InternalDoublePoint[0] = x;
00114 this->InternalDoublePoint[1] = y;
00115 this->InternalDoublePoint[2] = z;
00116 this->TransformPoint(this->InternalDoublePoint,this->InternalDoublePoint);
00117 return this->InternalDoublePoint; };
00118 double *TransformDoublePoint(const double point[3]) {
00119 return this->TransformDoublePoint(point[0],point[1],point[2]); };
00121
00123
00126 void TransformNormalAtPoint(const float point[3], const float in[3],
00127 float out[3]);
00128 void TransformNormalAtPoint(const double point[3], const double in[3],
00129 double out[3]);
00131
00132 double *TransformNormalAtPoint(const double point[3],
00133 const double normal[3]) {
00134 this->TransformNormalAtPoint(point,normal,this->InternalDoublePoint);
00135 return this->InternalDoublePoint; };
00136
00138
00141 double *TransformDoubleNormalAtPoint(const double point[3],
00142 const double normal[3]) {
00143 this->TransformNormalAtPoint(point,normal,this->InternalDoublePoint);
00144 return this->InternalDoublePoint; };
00146
00148
00151 float *TransformFloatNormalAtPoint(const float point[3],
00152 const float normal[3]) {
00153 this->TransformNormalAtPoint(point,normal,this->InternalFloatPoint);
00154 return this->InternalFloatPoint; };
00156
00158
00161 void TransformVectorAtPoint(const float point[3], const float in[3],
00162 float out[3]);
00163 void TransformVectorAtPoint(const double point[3], const double in[3],
00164 double out[3]);
00166
00167 double *TransformVectorAtPoint(const double point[3],
00168 const double vector[3]) {
00169 this->TransformVectorAtPoint(point,vector,this->InternalDoublePoint);
00170 return this->InternalDoublePoint; };
00171
00173
00176 double *TransformDoubleVectorAtPoint(const double point[3],
00177 const double vector[3]) {
00178 this->TransformVectorAtPoint(point,vector,this->InternalDoublePoint);
00179 return this->InternalDoublePoint; };
00181
00183
00186 float *TransformFloatVectorAtPoint(const float point[3],
00187 const float vector[3]) {
00188 this->TransformVectorAtPoint(point,vector,this->InternalFloatPoint);
00189 return this->InternalFloatPoint; };
00191
00194 virtual void TransformPoints(vtkPoints *inPts, vtkPoints *outPts);
00195
00197
00199 virtual void TransformPointsNormalsVectors(vtkPoints *inPts,
00200 vtkPoints *outPts,
00201 vtkDataArray *inNms,
00202 vtkDataArray *outNms,
00203 vtkDataArray *inVrs,
00204 vtkDataArray *outVrs);
00206
00212 vtkAbstractTransform *GetInverse();
00213
00217 void SetInverse(vtkAbstractTransform *transform);
00218
00220 virtual void Inverse() = 0;
00221
00223 void DeepCopy(vtkAbstractTransform *);
00224
00228 void Update();
00229
00231
00233 virtual void InternalTransformPoint(const float in[3], float out[3]) = 0;
00234 virtual void InternalTransformPoint(const double in[3], double out[3]) = 0;
00236
00238
00242 virtual void InternalTransformDerivative(const float in[3], float out[3],
00243 float derivative[3][3]) = 0;
00244 virtual void InternalTransformDerivative(const double in[3], double out[3],
00245 double derivative[3][3]) = 0;
00247
00249 virtual vtkAbstractTransform *MakeTransform() = 0;
00250
00257 virtual int CircuitCheck(vtkAbstractTransform *transform);
00258
00260 unsigned long GetMTime();
00261
00264 virtual void UnRegister(vtkObjectBase *O);
00265
00267
00269 void Identity() {
00270 vtkWarningMacro("vtkAbstractTransform::Identity() is deprecated"); };
00272
00273 protected:
00274 vtkAbstractTransform();
00275 ~vtkAbstractTransform();
00276
00278 virtual void InternalUpdate() {};
00279
00281 virtual void InternalDeepCopy(vtkAbstractTransform *) {};
00282
00283 float InternalFloatPoint[3];
00284 double InternalDoublePoint[3];
00285
00286 private:
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296 vtkTimeStamp UpdateTime;
00297 vtkSimpleCriticalSection *UpdateMutex;
00298 vtkSimpleCriticalSection *InverseMutex;
00299 int DependsOnInverse;
00300
00301
00302
00303
00304 vtkAbstractTransform *MyInverse;
00305
00306 int InUnRegister;
00307
00308 private:
00309 vtkAbstractTransform(const vtkAbstractTransform&);
00310 void operator=(const vtkAbstractTransform&);
00311 };
00312
00313
00314
00315
00316
00317
00318 class vtkTransformPair
00319 {
00320 public:
00321 vtkAbstractTransform *ForwardTransform;
00322 vtkAbstractTransform *InverseTransform;
00323
00324 void SwapForwardInverse() {
00325 vtkAbstractTransform *tmp = this->ForwardTransform;
00326 this->ForwardTransform = this->InverseTransform;
00327 this->InverseTransform = tmp; };
00328 };
00329
00330
00331
00332 class VTK_COMMON_EXPORT vtkTransformConcatenation
00333 {
00334 public:
00335 static vtkTransformConcatenation *New() {
00336 return new vtkTransformConcatenation(); };
00337 void Delete() { delete this; };
00338
00339
00340 void Concatenate(vtkAbstractTransform *transform);
00341
00342
00343 void Concatenate(const double elements[16]);
00344
00345
00346 void SetPreMultiplyFlag(int flag) { this->PreMultiplyFlag = flag; };
00347 int GetPreMultiplyFlag() { return this->PreMultiplyFlag; };
00348
00349
00350 void Translate(double x, double y, double z);
00351 void Rotate(double angle, double x, double y, double z);
00352 void Scale(double x, double y, double z);
00353
00354
00355 void Inverse();
00356
00357
00358 int GetInverseFlag() { return this->InverseFlag; };
00359
00360
00361 void Identity();
00362
00363
00364 void DeepCopy(vtkTransformConcatenation *transform);
00365
00366
00367 int GetNumberOfTransforms() { return this->NumberOfTransforms; };
00368
00369
00370
00371
00372 int GetNumberOfPreTransforms() { return this->NumberOfPreTransforms; };
00373
00374
00375 int GetNumberOfPostTransforms() {
00376 return this->NumberOfTransforms-this->NumberOfPreTransforms; };
00377
00378
00379 vtkAbstractTransform *GetTransform(int i);
00380
00381
00382 unsigned long GetMaxMTime();
00383
00384 void PrintSelf(ostream& os, vtkIndent indent);
00385
00386 protected:
00387 vtkTransformConcatenation();
00388 ~vtkTransformConcatenation();
00389
00390 int InverseFlag;
00391 int PreMultiplyFlag;
00392
00393 vtkMatrix4x4 *PreMatrix;
00394 vtkMatrix4x4 *PostMatrix;
00395 vtkAbstractTransform *PreMatrixTransform;
00396 vtkAbstractTransform *PostMatrixTransform;
00397
00398 int NumberOfTransforms;
00399 int NumberOfPreTransforms;
00400 int MaxNumberOfTransforms;
00401 vtkTransformPair *TransformList;
00402 };
00403
00404
00405
00406 class VTK_COMMON_EXPORT vtkTransformConcatenationStack
00407 {
00408 public:
00409 static vtkTransformConcatenationStack *New() {
00410 return new vtkTransformConcatenationStack(); };
00411 void Delete() { delete this; };
00412
00413
00414
00415 void Pop(vtkTransformConcatenation **concat);
00416
00417
00418
00419 void Push(vtkTransformConcatenation **concat);
00420
00421 void DeepCopy(vtkTransformConcatenationStack *stack);
00422
00423 protected:
00424 vtkTransformConcatenationStack();
00425 ~vtkTransformConcatenationStack();
00426
00427 int StackSize;
00428 vtkTransformConcatenation **Stack;
00429 vtkTransformConcatenation **StackBottom;
00430 };
00431
00432
00433
00434 #endif
00435
00436
00437
00438
00439