00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00048 #ifndef __vtkAbstractTransform_h
00049 #define __vtkAbstractTransform_h
00050
00051 #include "vtkObject.h"
00052
00053
00054
00055
00056 class vtkDataArray;
00057 class vtkMatrix4x4;
00058 class vtkPoints;
00059 class vtkSimpleCriticalSection;
00060
00061
00062 class VTK_COMMON_EXPORT vtkAbstractTransform : public vtkObject
00063 {
00064 public:
00065
00066 vtkTypeRevisionMacro(vtkAbstractTransform,vtkObject);
00067 void PrintSelf(ostream& os, vtkIndent indent);
00068
00070
00072 void TransformPoint(const float in[3], float out[3]) {
00073 this->Update(); this->InternalTransformPoint(in,out); };
00075
00077
00079 void TransformPoint(const double in[3], double out[3]) {
00080 this->Update(); this->InternalTransformPoint(in,out); };
00082
00084
00086 double *TransformPoint(double x, double y, double z) {
00087 return this->TransformDoublePoint(x,y,z); }
00088 double *TransformPoint(const double point[3]) {
00089 return this->TransformPoint(point[0],point[1],point[2]); };
00091
00093
00095 float *TransformFloatPoint(float x, float y, float z) {
00096 this->InternalFloatPoint[0] = x;
00097 this->InternalFloatPoint[1] = y;
00098 this->InternalFloatPoint[2] = z;
00099 this->TransformPoint(this->InternalFloatPoint,this->InternalFloatPoint);
00100 return this->InternalFloatPoint; };
00101 float *TransformFloatPoint(const float point[3]) {
00102 return this->TransformFloatPoint(point[0],point[1],point[2]); };
00104
00106
00108 double *TransformDoublePoint(double x, double y, double z) {
00109 this->InternalDoublePoint[0] = x;
00110 this->InternalDoublePoint[1] = y;
00111 this->InternalDoublePoint[2] = z;
00112 this->TransformPoint(this->InternalDoublePoint,this->InternalDoublePoint);
00113 return this->InternalDoublePoint; };
00114 double *TransformDoublePoint(const double point[3]) {
00115 return this->TransformDoublePoint(point[0],point[1],point[2]); };
00117
00119
00122 void TransformNormalAtPoint(const float point[3], const float in[3],
00123 float out[3]);
00124 void TransformNormalAtPoint(const double point[3], const double in[3],
00125 double out[3]);
00127
00128 double *TransformNormalAtPoint(const double point[3],
00129 const double normal[3]) {
00130 this->TransformNormalAtPoint(point,normal,this->InternalDoublePoint);
00131 return this->InternalDoublePoint; };
00132
00134
00137 double *TransformDoubleNormalAtPoint(const double point[3],
00138 const double normal[3]) {
00139 this->TransformNormalAtPoint(point,normal,this->InternalDoublePoint);
00140 return this->InternalDoublePoint; };
00142
00144
00147 float *TransformFloatNormalAtPoint(const float point[3],
00148 const float normal[3]) {
00149 this->TransformNormalAtPoint(point,normal,this->InternalFloatPoint);
00150 return this->InternalFloatPoint; };
00152
00154
00157 void TransformVectorAtPoint(const float point[3], const float in[3],
00158 float out[3]);
00159 void TransformVectorAtPoint(const double point[3], const double in[3],
00160 double out[3]);
00162
00163 double *TransformVectorAtPoint(const double point[3],
00164 const double vector[3]) {
00165 this->TransformVectorAtPoint(point,vector,this->InternalDoublePoint);
00166 return this->InternalDoublePoint; };
00167
00169
00172 double *TransformDoubleVectorAtPoint(const double point[3],
00173 const double vector[3]) {
00174 this->TransformVectorAtPoint(point,vector,this->InternalDoublePoint);
00175 return this->InternalDoublePoint; };
00177
00179
00182 float *TransformFloatVectorAtPoint(const float point[3],
00183 const float vector[3]) {
00184 this->TransformVectorAtPoint(point,vector,this->InternalFloatPoint);
00185 return this->InternalFloatPoint; };
00187
00190 virtual void TransformPoints(vtkPoints *inPts, vtkPoints *outPts);
00191
00193
00195 virtual void TransformPointsNormalsVectors(vtkPoints *inPts,
00196 vtkPoints *outPts,
00197 vtkDataArray *inNms,
00198 vtkDataArray *outNms,
00199 vtkDataArray *inVrs,
00200 vtkDataArray *outVrs);
00202
00208 vtkAbstractTransform *GetInverse();
00209
00213 void SetInverse(vtkAbstractTransform *transform);
00214
00216 virtual void Inverse() = 0;
00217
00219 void DeepCopy(vtkAbstractTransform *);
00220
00224 void Update();
00225
00227
00229 virtual void InternalTransformPoint(const float in[3], float out[3]) = 0;
00230 virtual void InternalTransformPoint(const double in[3], double out[3]) = 0;
00232
00234
00238 virtual void InternalTransformDerivative(const float in[3], float out[3],
00239 float derivative[3][3]) = 0;
00240 virtual void InternalTransformDerivative(const double in[3], double out[3],
00241 double derivative[3][3]) = 0;
00243
00245 virtual vtkAbstractTransform *MakeTransform() = 0;
00246
00253 virtual int CircuitCheck(vtkAbstractTransform *transform);
00254
00256 unsigned long GetMTime();
00257
00260 virtual void UnRegister(vtkObjectBase *O);
00261
00263
00265 void Identity() {
00266 vtkWarningMacro("vtkAbstractTransform::Identity() is deprecated"); };
00268
00269 protected:
00270 vtkAbstractTransform();
00271 ~vtkAbstractTransform();
00272
00274 virtual void InternalUpdate() {};
00275
00277 virtual void InternalDeepCopy(vtkAbstractTransform *) {};
00278
00279 float InternalFloatPoint[3];
00280 double InternalDoublePoint[3];
00281
00282 private:
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292 vtkTimeStamp UpdateTime;
00293 vtkSimpleCriticalSection *UpdateMutex;
00294 vtkSimpleCriticalSection *InverseMutex;
00295 int DependsOnInverse;
00296
00297
00298
00299
00300 vtkAbstractTransform *MyInverse;
00301
00302 int InUnRegister;
00303
00304 private:
00305 vtkAbstractTransform(const vtkAbstractTransform&);
00306 void operator=(const vtkAbstractTransform&);
00307 };
00308
00309
00310
00311
00312
00313
00314 class vtkTransformPair
00315 {
00316 public:
00317 vtkAbstractTransform *ForwardTransform;
00318 vtkAbstractTransform *InverseTransform;
00319
00320 void SwapForwardInverse() {
00321 vtkAbstractTransform *tmp = this->ForwardTransform;
00322 this->ForwardTransform = this->InverseTransform;
00323 this->InverseTransform = tmp; };
00324 };
00325
00326
00327
00328 class VTK_COMMON_EXPORT vtkTransformConcatenation
00329 {
00330 public:
00331 static vtkTransformConcatenation *New() {
00332 return new vtkTransformConcatenation(); };
00333 void Delete() { delete this; };
00334
00335
00336 void Concatenate(vtkAbstractTransform *transform);
00337
00338
00339 void Concatenate(const double elements[16]);
00340
00341
00342 void SetPreMultiplyFlag(int flag) { this->PreMultiplyFlag = flag; };
00343 int GetPreMultiplyFlag() { return this->PreMultiplyFlag; };
00344
00345
00346 void Translate(double x, double y, double z);
00347 void Rotate(double angle, double x, double y, double z);
00348 void Scale(double x, double y, double z);
00349
00350
00351 void Inverse();
00352
00353
00354 int GetInverseFlag() { return this->InverseFlag; };
00355
00356
00357 void Identity();
00358
00359
00360 void DeepCopy(vtkTransformConcatenation *transform);
00361
00362
00363 int GetNumberOfTransforms() { return this->NumberOfTransforms; };
00364
00365
00366
00367
00368 int GetNumberOfPreTransforms() { return this->NumberOfPreTransforms; };
00369
00370
00371 int GetNumberOfPostTransforms() {
00372 return this->NumberOfTransforms-this->NumberOfPreTransforms; };
00373
00374
00375 vtkAbstractTransform *GetTransform(int i);
00376
00377
00378 unsigned long GetMaxMTime();
00379
00380 void PrintSelf(ostream& os, vtkIndent indent);
00381
00382 protected:
00383 vtkTransformConcatenation();
00384 ~vtkTransformConcatenation();
00385
00386 int InverseFlag;
00387 int PreMultiplyFlag;
00388
00389 vtkMatrix4x4 *PreMatrix;
00390 vtkMatrix4x4 *PostMatrix;
00391 vtkAbstractTransform *PreMatrixTransform;
00392 vtkAbstractTransform *PostMatrixTransform;
00393
00394 int NumberOfTransforms;
00395 int NumberOfPreTransforms;
00396 int MaxNumberOfTransforms;
00397 vtkTransformPair *TransformList;
00398 };
00399
00400
00401
00402 class VTK_COMMON_EXPORT vtkTransformConcatenationStack
00403 {
00404 public:
00405 static vtkTransformConcatenationStack *New() {
00406 return new vtkTransformConcatenationStack(); };
00407 void Delete() { delete this; };
00408
00409
00410
00411 void Pop(vtkTransformConcatenation **concat);
00412
00413
00414
00415 void Push(vtkTransformConcatenation **concat);
00416
00417 void DeepCopy(vtkTransformConcatenationStack *stack);
00418
00419 protected:
00420 vtkTransformConcatenationStack();
00421 ~vtkTransformConcatenationStack();
00422
00423 int StackSize;
00424 vtkTransformConcatenation **Stack;
00425 vtkTransformConcatenation **StackBottom;
00426 };
00427
00428
00429
00430 #endif
00431
00432
00433
00434
00435