Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

vtkAbstractTransform.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkAbstractTransform.h,v $
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
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 //BTX
00268   // We need to record the time of the last update, and we also need
00269   // to do mutex locking so updates don't collide.  These are private
00270   // because Update() is not virtual.
00271   // If DependsOnInverse is set, then this transform object will
00272   // check its inverse on every update, and update itself accordingly
00273   // if necessary.
00274 //ETX
00275   vtkTimeStamp UpdateTime;
00276   vtkSimpleCriticalSection *UpdateMutex;
00277   vtkSimpleCriticalSection *InverseMutex;
00278   int DependsOnInverse;
00279 
00280 //BTX
00281   // MyInverse is a transform which is the inverse of this one.
00282 //ETX
00283   vtkAbstractTransform *MyInverse;
00284 
00285   int InUnRegister;
00286   
00287 private:
00288   vtkAbstractTransform(const vtkAbstractTransform&);  // Not implemented.
00289   void operator=(const vtkAbstractTransform&);  // Not implemented.
00290 };
00291 
00292 //BTX
00293 //-------------------------------------------------------------------------
00294 // A simple data structure to hold both a transform and its inverse.
00295 // One of ForwardTransform or InverseTransform might be NULL,
00296 // and must be acquired by calling GetInverse() on the other.
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 // A helper class (not derived from vtkObject) to store a series of
00310 // transformations in a pipelined concatenation.
00311 class VTK_COMMON_EXPORT vtkTransformConcatenation
00312 {
00313 public:
00314   static vtkTransformConcatenation *New() {
00315     return new vtkTransformConcatenation(); };
00316   void Delete() { delete this; };
00317 
00318   // add a transform to the list according to Pre/PostMultiply semantics
00319   void Concatenate(vtkAbstractTransform *transform); 
00320     
00321   // concatenate with a matrix according to Pre/PostMultiply semantics
00322   void Concatenate(const double elements[16]);
00323 
00324   // set the PreMultiply flag
00325   void SetPreMultiplyFlag(int flag) { this->PreMultiplyFlag = flag; };
00326   int GetPreMultiplyFlag() { return this->PreMultiplyFlag; };
00327   
00328   // the three basic linear transformations
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   // invert the concatenation
00334   void Inverse();
00335   
00336   // get the inverse flag
00337   int GetInverseFlag() { return this->InverseFlag; };
00338   
00339   // identity simply clears the transform list
00340   void Identity();
00341     
00342   // copy the list
00343   void DeepCopy(vtkTransformConcatenation *transform);
00344     
00345   // the number of stored transforms
00346   int GetNumberOfTransforms() { return this->NumberOfTransforms; };
00347     
00348   // the number of transforms that were pre-concatenated (note that
00349   // whenever Iverse() is called, the pre-concatenated and
00350   // post-concatenated transforms are switched)
00351   int GetNumberOfPreTransforms() { return this->NumberOfPreTransforms; };
00352 
00353   // the number of transforms that were post-concatenated.
00354   int GetNumberOfPostTransforms() { 
00355     return this->NumberOfTransforms-this->NumberOfPreTransforms; };
00356 
00357   // get one of the transforms
00358   vtkAbstractTransform *GetTransform(int i);
00359     
00360   // get maximum MTime of all transforms
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 // A helper class (not derived from vtkObject) to store a stack of
00384 // concatenations.
00385 class VTK_COMMON_EXPORT vtkTransformConcatenationStack
00386 {
00387 public:
00388   static vtkTransformConcatenationStack *New() {
00389     return new vtkTransformConcatenationStack(); };
00390   void Delete() { delete this; };
00391 
00392   // pop will pop delete 'concat', then pop the
00393   // top item on the stack onto 'concat'.
00394   void Pop(vtkTransformConcatenation **concat);
00395 
00396   // push will move 'concat' onto the stack, and
00397   // make 'concat' a copy of its previous self
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 //ETX
00412 
00413 #endif
00414 
00415 
00416 
00417 
00418 

Generated on Mon Jan 21 23:07:16 2008 for VTK by  doxygen 1.4.3-20050530