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
00067 #ifndef __vtkAbstractTransform_h
00068 #define __vtkAbstractTransform_h
00069
00070 #include "vtkObject.h"
00071 #include "vtkMatrix4x4.h"
00072 #include "vtkPoints.h"
00073
00074 class vtkSimpleCriticalSection;
00075
00076
00077 class VTK_COMMON_EXPORT vtkAbstractTransform : public vtkObject
00078 {
00079 public:
00080
00081 vtkTypeMacro(vtkAbstractTransform,vtkObject);
00082 void PrintSelf(ostream& os, vtkIndent indent);
00083
00085
00087 void TransformPoint(const float in[3], float out[3]) {
00088 this->Update(); this->InternalTransformPoint(in,out); };
00090
00092
00094 void TransformPoint(const double in[3], double out[3]) {
00095 this->Update(); this->InternalTransformPoint(in,out); };
00097
00099
00101 double *TransformPoint(double x, double y, double z) {
00102 return this->TransformDoublePoint(x,y,z); }
00103 double *TransformPoint(const double point[3]) {
00104 return this->TransformPoint(point[0],point[1],point[2]); };
00106
00108
00110 float *TransformFloatPoint(float x, float y, float z) {
00111 this->InternalFloatPoint[0] = x;
00112 this->InternalFloatPoint[1] = y;
00113 this->InternalFloatPoint[2] = z;
00114 this->TransformPoint(this->InternalFloatPoint,this->InternalFloatPoint);
00115 return this->InternalFloatPoint; };
00116 float *TransformFloatPoint(const float point[3]) {
00117 return this->TransformFloatPoint(point[0],point[1],point[2]); };
00119
00121
00123 double *TransformDoublePoint(double x, double y, double z) {
00124 this->InternalDoublePoint[0] = x;
00125 this->InternalDoublePoint[1] = y;
00126 this->InternalDoublePoint[2] = z;
00127 this->TransformPoint(this->InternalDoublePoint,this->InternalDoublePoint);
00128 return this->InternalDoublePoint; };
00129 double *TransformDoublePoint(const double point[3]) {
00130 return this->TransformDoublePoint(point[0],point[1],point[2]); };
00132
00134
00137 void TransformNormalAtPoint(const float point[3], const float in[3],
00138 float out[3]);
00139 void TransformNormalAtPoint(const double point[3], const double in[3],
00140 double out[3]);
00142
00143 double *TransformNormalAtPoint(const double point[3],
00144 const double normal[3]) {
00145 this->TransformNormalAtPoint(point,normal,this->InternalDoublePoint);
00146 return this->InternalDoublePoint; };
00147
00149
00152 double *TransformDoubleNormalAtPoint(const double point[3],
00153 const double normal[3]) {
00154 this->TransformNormalAtPoint(point,normal,this->InternalDoublePoint);
00155 return this->InternalDoublePoint; };
00157
00159
00162 float *TransformFloatNormalAtPoint(const float point[3],
00163 const float normal[3]) {
00164 this->TransformNormalAtPoint(point,normal,this->InternalFloatPoint);
00165 return this->InternalFloatPoint; };
00167
00169
00172 void TransformVectorAtPoint(const float point[3], const float in[3],
00173 float out[3]);
00174 void TransformVectorAtPoint(const double point[3], const double in[3],
00175 double out[3]);
00177
00178 double *TransformVectorAtPoint(const double point[3],
00179 const double vector[3]) {
00180 this->TransformVectorAtPoint(point,vector,this->InternalDoublePoint);
00181 return this->InternalDoublePoint; };
00182
00184
00187 double *TransformDoubleVectorAtPoint(const double point[3],
00188 const double vector[3]) {
00189 this->TransformVectorAtPoint(point,vector,this->InternalDoublePoint);
00190 return this->InternalDoublePoint; };
00192
00194
00197 float *TransformFloatVectorAtPoint(const float point[3],
00198 const float vector[3]) {
00199 this->TransformVectorAtPoint(point,vector,this->InternalFloatPoint);
00200 return this->InternalFloatPoint; };
00202
00205 virtual void TransformPoints(vtkPoints *inPts, vtkPoints *outPts);
00206
00208
00210 virtual void TransformPointsNormalsVectors(vtkPoints *inPts,
00211 vtkPoints *outPts,
00212 vtkDataArray *inNms,
00213 vtkDataArray *outNms,
00214 vtkDataArray *inVrs,
00215 vtkDataArray *outVrs);
00217
00223 vtkAbstractTransform *GetInverse();
00224
00228 void SetInverse(vtkAbstractTransform *transform);
00229
00231 virtual void Inverse() = 0;
00232
00234 void DeepCopy(vtkAbstractTransform *);
00235
00239 void Update();
00240
00242
00244 virtual void InternalTransformPoint(const float in[3], float out[3]) = 0;
00245 virtual void InternalTransformPoint(const double in[3], double out[3]) = 0;
00247
00249
00253 virtual void InternalTransformDerivative(const float in[3], float out[3],
00254 float derivative[3][3]) = 0;
00255 virtual void InternalTransformDerivative(const double in[3], double out[3],
00256 double derivative[3][3]) = 0;
00258
00260 virtual vtkAbstractTransform *MakeTransform() = 0;
00261
00268 virtual int CircuitCheck(vtkAbstractTransform *transform);
00269
00271 unsigned long GetMTime();
00272
00275 void UnRegister(vtkObject *O);
00276
00278
00280 void Identity() {
00281 vtkWarningMacro("vtkAbstractTransform::Identity() is deprecated"); };
00283
00284 protected:
00285 vtkAbstractTransform();
00286 ~vtkAbstractTransform();
00287
00289 virtual void InternalUpdate() {};
00290
00292 virtual void InternalDeepCopy(vtkAbstractTransform *) {};
00293
00294 float InternalFloatPoint[3];
00295 double InternalDoublePoint[3];
00296
00297 private:
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307 vtkTimeStamp UpdateTime;
00308 vtkSimpleCriticalSection *UpdateMutex;
00309 vtkSimpleCriticalSection *InverseMutex;
00310 int DependsOnInverse;
00311
00312
00313
00314
00315 vtkAbstractTransform *MyInverse;
00316
00317 int InUnRegister;
00318
00319 private:
00320 vtkAbstractTransform(const vtkAbstractTransform&);
00321 void operator=(const vtkAbstractTransform&);
00322 };
00323
00324
00325
00326
00327
00328
00329 class vtkTransformPair
00330 {
00331 public:
00332 vtkAbstractTransform *ForwardTransform;
00333 vtkAbstractTransform *InverseTransform;
00334
00335 void SwapForwardInverse() {
00336 vtkAbstractTransform *tmp = this->ForwardTransform;
00337 this->ForwardTransform = this->InverseTransform;
00338 this->InverseTransform = tmp; };
00339 };
00340
00341
00342
00343 class VTK_COMMON_EXPORT vtkTransformConcatenation
00344 {
00345 public:
00346 static vtkTransformConcatenation *New() {
00347 return new vtkTransformConcatenation(); };
00348 void Delete() { delete this; };
00349
00350
00351 void Concatenate(vtkAbstractTransform *transform);
00352
00353
00354 void Concatenate(const double elements[16]);
00355
00356
00357 void SetPreMultiplyFlag(int flag) { this->PreMultiplyFlag = flag; };
00358 int GetPreMultiplyFlag() { return this->PreMultiplyFlag; };
00359
00360
00361 void Translate(double x, double y, double z);
00362 void Rotate(double angle, double x, double y, double z);
00363 void Scale(double x, double y, double z);
00364
00365
00366 void Inverse();
00367
00368
00369 int GetInverseFlag() { return this->InverseFlag; };
00370
00371
00372 void Identity();
00373
00374
00375 void DeepCopy(vtkTransformConcatenation *transform);
00376
00377
00378 int GetNumberOfTransforms() { return this->NumberOfTransforms; };
00379
00380
00381
00382
00383 int GetNumberOfPreTransforms() { return this->NumberOfPreTransforms; };
00384
00385
00386 int GetNumberOfPostTransforms() {
00387 return this->NumberOfTransforms-this->NumberOfPreTransforms; };
00388
00389
00390 vtkAbstractTransform *GetTransform(int i);
00391
00392
00393 unsigned long GetMaxMTime();
00394
00395 void PrintSelf(ostream& os, vtkIndent indent);
00396
00397 protected:
00398 vtkTransformConcatenation();
00399 ~vtkTransformConcatenation();
00400
00401 int InverseFlag;
00402 int PreMultiplyFlag;
00403
00404 vtkMatrix4x4 *PreMatrix;
00405 vtkMatrix4x4 *PostMatrix;
00406 vtkAbstractTransform *PreMatrixTransform;
00407 vtkAbstractTransform *PostMatrixTransform;
00408
00409 int NumberOfTransforms;
00410 int NumberOfPreTransforms;
00411 int MaxNumberOfTransforms;
00412 vtkTransformPair *TransformList;
00413 };
00414
00415
00416
00417 class VTK_COMMON_EXPORT vtkTransformConcatenationStack
00418 {
00419 public:
00420 static vtkTransformConcatenationStack *New() {
00421 return new vtkTransformConcatenationStack(); };
00422 void Delete() { delete this; };
00423
00424
00425
00426 void Pop(vtkTransformConcatenation **concat);
00427
00428
00429
00430 void Push(vtkTransformConcatenation **concat);
00431
00432 void DeepCopy(vtkTransformConcatenationStack *stack);
00433
00434 protected:
00435 vtkTransformConcatenationStack();
00436 ~vtkTransformConcatenationStack();
00437
00438 int StackSize;
00439 vtkTransformConcatenation **Stack;
00440 vtkTransformConcatenation **StackBottom;
00441 };
00442
00443
00444
00445 #endif
00446
00447
00448
00449
00450