00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00066 #ifndef __vtkAbstractTransform_h
00067 #define __vtkAbstractTransform_h
00068
00069 #include "vtkObject.h"
00070 #include "vtkMatrix4x4.h"
00071 #include "vtkPoints.h"
00072 #include "vtkNormals.h"
00073 #include "vtkVectors.h"
00074 #include "vtkMutexLock.h"
00075
00076 class VTK_EXPORT vtkAbstractTransform : public vtkObject
00077 {
00078 public:
00079
00080 vtkTypeMacro(vtkAbstractTransform,vtkObject);
00081 void PrintSelf(ostream& os, vtkIndent indent);
00082
00085 void TransformPoint(const float in[3], float out[3]) {
00086 this->Update(); this->InternalTransformPoint(in,out); };
00087
00090 void TransformPoint(const double in[3], double out[3]) {
00091 this->Update(); this->InternalTransformPoint(in,out); };
00092
00095 double *TransformPoint(double x, double y, double z) {
00096 return this->TransformDoublePoint(x,y,z); }
00097 double *TransformPoint(const double point[3]) {
00098 return this->TransformPoint(point[0],point[1],point[2]); };
00099
00102 float *TransformFloatPoint(float x, float y, float z) {
00103 this->InternalFloatPoint[0] = x;
00104 this->InternalFloatPoint[1] = y;
00105 this->InternalFloatPoint[2] = z;
00106 this->TransformPoint(this->InternalFloatPoint,this->InternalFloatPoint);
00107 return this->InternalFloatPoint; };
00108 float *TransformFloatPoint(const float point[3]) {
00109 return this->TransformFloatPoint(point[0],point[1],point[2]); };
00110
00113 double *TransformDoublePoint(double x, double y, double z) {
00114 this->InternalDoublePoint[0] = x;
00115 this->InternalDoublePoint[1] = y;
00116 this->InternalDoublePoint[2] = z;
00117 this->TransformPoint(this->InternalDoublePoint,this->InternalDoublePoint);
00118 return this->InternalDoublePoint; };
00119 double *TransformDoublePoint(const double point[3]) {
00120 return this->TransformDoublePoint(point[0],point[1],point[2]); };
00121
00125 void TransformNormalAtPoint(const float point[3], const float in[3],
00126 float out[3]);
00127 void TransformNormalAtPoint(const double point[3], const double in[3],
00128 double out[3]);
00129
00130 double *TransformNormalAtPoint(const double point[3],
00131 const double normal[3]) {
00132 this->TransformNormalAtPoint(point,normal,this->InternalDoublePoint);
00133 return this->InternalDoublePoint; };
00134
00138 double *TransformDoubleNormalAtPoint(const double point[3],
00139 const double normal[3]) {
00140 this->TransformNormalAtPoint(point,normal,this->InternalDoublePoint);
00141 return this->InternalDoublePoint; };
00142
00146 float *TransformFloatNormalAtPoint(const float point[3],
00147 const float normal[3]) {
00148 this->TransformNormalAtPoint(point,normal,this->InternalFloatPoint);
00149 return this->InternalFloatPoint; };
00150
00154 void TransformVectorAtPoint(const float point[3], const float in[3],
00155 float out[3]);
00156 void TransformVectorAtPoint(const double point[3], const double in[3],
00157 double out[3]);
00158
00159 double *TransformVectorAtPoint(const double point[3],
00160 const double vector[3]) {
00161 this->TransformVectorAtPoint(point,vector,this->InternalDoublePoint);
00162 return this->InternalDoublePoint; };
00163
00167 double *TransformDoubleVectorAtPoint(const double point[3],
00168 const double vector[3]) {
00169 this->TransformVectorAtPoint(point,vector,this->InternalDoublePoint);
00170 return this->InternalDoublePoint; };
00171
00175 float *TransformFloatVectorAtPoint(const float point[3],
00176 const float vector[3]) {
00177 this->TransformVectorAtPoint(point,vector,this->InternalFloatPoint);
00178 return this->InternalFloatPoint; };
00179
00182 virtual void TransformPoints(vtkPoints *inPts, vtkPoints *outPts);
00183
00186 virtual void TransformPointsNormalsVectors(vtkPoints *inPts,
00187 vtkPoints *outPts,
00188 vtkNormals *inNms,
00189 vtkNormals *outNms,
00190 vtkVectors *inVrs,
00191 vtkVectors *outVrs);
00192
00198 vtkAbstractTransform *GetInverse();
00199
00203 void SetInverse(vtkAbstractTransform *transform);
00204
00206 virtual void Inverse() = 0;
00207
00209 void DeepCopy(vtkAbstractTransform *);
00210
00214 void Update();
00215
00218 virtual void InternalTransformPoint(const float in[3], float out[3]) = 0;
00219 virtual void InternalTransformPoint(const double in[3], double out[3]) = 0;
00220
00225 virtual void InternalTransformDerivative(const float in[3], float out[3],
00226 float derivative[3][3]) = 0;
00227 virtual void InternalTransformDerivative(const double in[3], double out[3],
00228 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 void UnRegister(vtkObject *O);
00247
00250 void Identity() {
00251 vtkWarningMacro("vtkAbstractTransform::Identity() is deprecated"); };
00252
00253 protected:
00254 vtkAbstractTransform();
00255 ~vtkAbstractTransform();
00256 vtkAbstractTransform(const vtkAbstractTransform&) {};
00257 void operator=(const vtkAbstractTransform&) {};
00258
00260 virtual void InternalUpdate() {};
00261
00263 virtual void InternalDeepCopy(vtkAbstractTransform *) {};
00264
00265 float InternalFloatPoint[3];
00266 double InternalDoublePoint[3];
00267
00268 private:
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278 vtkTimeStamp UpdateTime;
00279 vtkSimpleMutexLock *UpdateMutex;
00280 vtkSimpleMutexLock *InverseMutex;
00281 int DependsOnInverse;
00282
00283
00284
00285
00286 vtkAbstractTransform *MyInverse;
00287
00288 int InUnRegister;
00289 };
00290
00291
00292
00293
00294
00295
00296 class vtkTransformPair
00297 {
00298 public:
00299 vtkAbstractTransform *ForwardTransform;
00300 vtkAbstractTransform *InverseTransform;
00301
00302 void SwapForwardInverse() {
00303 vtkAbstractTransform *tmp = this->ForwardTransform;
00304 this->ForwardTransform = this->InverseTransform;
00305 this->InverseTransform = tmp; };
00306 };
00307
00308
00309
00310 class VTK_EXPORT vtkTransformConcatenation
00311 {
00312 public:
00313 static vtkTransformConcatenation *New() {
00314 return new vtkTransformConcatenation(); };
00315 void Delete() { delete this; };
00316
00317
00318 void Concatenate(vtkAbstractTransform *transform);
00319
00320
00321 void Concatenate(const double elements[16]);
00322
00323
00324 void SetPreMultiplyFlag(int flag) { this->PreMultiplyFlag = flag; };
00325 int GetPreMultiplyFlag() { return this->PreMultiplyFlag; };
00326
00327
00328 void Translate(double x, double y, double z);
00329 void Rotate(double angle, double x, double y, double z);
00330 void Scale(double x, double y, double z);
00331
00332
00333 void Inverse();
00334
00335
00336 int GetInverseFlag() { return this->InverseFlag; };
00337
00338
00339 void Identity();
00340
00341
00342 void DeepCopy(vtkTransformConcatenation *transform);
00343
00344
00345 int GetNumberOfTransforms() { return this->NumberOfTransforms; };
00346
00347
00348
00349
00350 int GetNumberOfPreTransforms() { return this->NumberOfPreTransforms; };
00351
00352
00353 int GetNumberOfPostTransforms() {
00354 return this->NumberOfTransforms-this->NumberOfPreTransforms; };
00355
00356
00357 vtkAbstractTransform *GetTransform(int i);
00358
00359
00360 unsigned long GetMaxMTime();
00361
00362 void PrintSelf(ostream& os, vtkIndent indent);
00363
00364 protected:
00365 vtkTransformConcatenation();
00366 ~vtkTransformConcatenation();
00367
00368 int InverseFlag;
00369 int PreMultiplyFlag;
00370
00371 vtkMatrix4x4 *PreMatrix;
00372 vtkMatrix4x4 *PostMatrix;
00373 vtkAbstractTransform *PreMatrixTransform;
00374 vtkAbstractTransform *PostMatrixTransform;
00375
00376 int NumberOfTransforms;
00377 int NumberOfPreTransforms;
00378 int MaxNumberOfTransforms;
00379 vtkTransformPair *TransformList;
00380 };
00381
00382
00383
00384 class VTK_EXPORT vtkTransformConcatenationStack
00385 {
00386 public:
00387 static vtkTransformConcatenationStack *New() {
00388 return new vtkTransformConcatenationStack(); };
00389 void Delete() { delete this; };
00390
00391
00392
00393 void Pop(vtkTransformConcatenation **concat);
00394
00395
00396
00397 void Push(vtkTransformConcatenation **concat);
00398
00399 void DeepCopy(vtkTransformConcatenationStack *stack);
00400
00401 protected:
00402 vtkTransformConcatenationStack();
00403 ~vtkTransformConcatenationStack();
00404
00405 int StackSize;
00406 vtkTransformConcatenation **Stack;
00407 vtkTransformConcatenation **StackBottom;
00408 };
00409
00410
00411
00412 #endif
00413
00414
00415
00416
00417