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

vtkVolumeShearWarpMapper.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkVolumeShearWarpMapper.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 =========================================================================*/
00058 #ifndef __vtkVolumeShearWarpMapper_h
00059 #define __vtkVolumeShearWarpMapper_h
00060 
00061 #include "vtkVolumeMapper.h"
00062 
00063 class vtkEncodedGradientShader;
00064 class vtkEncodedGradientEstimator;
00065 
00066 class vtkStructuredPoints;
00067 class vtkCamera;
00068 class vtkVolume;
00069 class vtkImageData;
00070 class vtkVolumeProperty;
00071 class vtkPiecewiseFunction;
00072 class vtkTransform;
00073 class vtkMatrix4x4;
00074 
00075 class vtkRenderer;
00076 class vtkRenderWindow;
00077 
00078 //#include "vtkVolumeShearWarpDataStructure.h"
00079 
00080 class vtkShearWarpPixelData;
00081 class vtkShearWarpRLEImage;
00082 template <class T> struct vtkShearWarpVoxelData;
00083 template <class T> class vtkShearWarpRLERun;
00084 template <class T> class vtkShearWarpRLESlice;
00085 class vtkShearWarpBase;
00086 template <class T> class vtkShearWarpRLEVolume;
00087 template <class T> class vtkShearWarpSummedAreaTable;
00088 struct vtkShearWarpOctreeRun;
00089 template <class T> class vtkShearWarpOctreeNode;
00090 template <class T> class vtkShearWarpOctree;
00091 
00092 #define VTK_X_AXIS  0
00093 #define VTK_Y_AXIS  1
00094 #define VTK_Z_AXIS  2
00095 
00096 #define VTK_SHEAR_WARP_COMPOSITE_FUNCTION      0
00097 #define VTK_SHEAR_WARP_MIP_FUNCTION            1
00098 #define VTK_SHEAR_WARP_ISOSURFACE_FUNCTION     2
00099 
00100 #define VTK_SHEAR_WARP_OCTREE_TRANSPARENT      0
00101 #define VTK_SHEAR_WARP_OCTREE_NONTRANSPARENT   1
00102 #define VTK_SHEAR_WARP_OCTREE_COMBINATION      2
00103 #define VTK_SHEAR_WARP_OCTREE_MINIMUM_SIZE     16
00104                                                
00105 
00106 class VTK_RENDERING_EXPORT vtkVolumeShearWarpMapper : public vtkVolumeMapper
00107 {
00108 //BTX
00109   template <class T>
00110   friend void CompositeIntermediateNearestSimple(vtkShearWarpRLEImage *image, vtkVolumeShearWarpMapper *myThis);
00111 
00112   template <class T>
00113   friend void CompositeIntermediateLinearSimple(vtkShearWarpRLEImage *image, vtkVolumeShearWarpMapper *myThis);
00114   
00115   template <class T>
00116   friend void CompositeIntermediateNearestRLE(vtkShearWarpRLEImage *image, vtkVolumeShearWarpMapper *myThis);
00117 
00118   template <class T>
00119   friend void CompositeIntermediateLinearRLE(vtkShearWarpRLEImage *image, vtkVolumeShearWarpMapper *myThis);
00120 
00121   template <class T>
00122   friend void CompositeIntermediateNearestUnclassified(vtkShearWarpRLEImage *image, vtkVolumeShearWarpMapper *myThis);
00123 
00124   template <class T>
00125   friend void CompositeIntermediateLinearUnclassified(vtkShearWarpRLEImage *image, vtkVolumeShearWarpMapper *myThis);
00126 
00127   template <class T>
00128   friend void CompositeIntermediateLinearRLEPerspective(vtkShearWarpRLEImage *image, vtkVolumeShearWarpMapper *myThis);
00129 //ETX
00130 
00131 public:
00132   static vtkVolumeShearWarpMapper *New();  
00133   vtkTypeRevisionMacro(vtkVolumeShearWarpMapper,vtkVolumeMapper);
00134   void PrintSelf(ostream& os, vtkIndent indent);
00135 
00137   virtual void Update();
00138 
00140 
00141   void SetGradientEstimator( vtkEncodedGradientEstimator *gradest );
00142   vtkGetObjectMacro( GradientEstimator, vtkEncodedGradientEstimator );
00144 
00146 
00147   vtkGetObjectMacro( GradientShader, vtkEncodedGradientShader );
00149   
00151 
00152   vtkSetMacro( IsoValue, float );
00153   vtkGetMacro( IsoValue, float );
00155 
00157 
00158   vtkSetMacro(RunlengthEncoding,int);
00159   vtkGetMacro(RunlengthEncoding,int);
00160   vtkBooleanMacro(RunlengthEncoding,int);
00162 
00164 
00165   vtkSetMacro(FastClassification,int);
00166   vtkGetMacro(FastClassification,int);
00167   vtkBooleanMacro(FastClassification,int);
00169 
00171 
00172   vtkSetMacro(ParallelProjection,int);
00173   vtkGetMacro(ParallelProjection,int);
00174   vtkBooleanMacro(ParallelProjection, int);
00176   
00177   vtkSetMacro(MyPerspectiveProjection,int);
00178   vtkGetMacro(MyPerspectiveProjection,int);
00179   vtkBooleanMacro(MyPerspectiveProjection, int);
00180 
00182 
00183   vtkSetClampMacro( FunctionType, int,
00184         VTK_SHEAR_WARP_COMPOSITE_FUNCTION, VTK_SHEAR_WARP_ISOSURFACE_FUNCTION);
00185   vtkGetMacro(FunctionType,int);
00186   void SetFunctionTypeToComposite()
00187         {this->SetFunctionType(VTK_SHEAR_WARP_COMPOSITE_FUNCTION);};
00188   void SetFunctionTypeToMIP()
00189         {this->SetFunctionType(VTK_SHEAR_WARP_MIP_FUNCTION);};
00190   void SetFunctionTypeToIsosurface()
00191         {this->SetFunctionType(VTK_SHEAR_WARP_ISOSURFACE_FUNCTION);};
00193 
00194   int Debug;
00195 
00197 
00199   vtkSetClampMacro( ImageSampleDistance, int, 1, 32 );
00200   vtkGetMacro( ImageSampleDistance, int );
00202 
00204 
00206   vtkSetClampMacro( MinimumImageSampleDistance, int, 1, 32 );
00207   vtkGetMacro( MinimumImageSampleDistance, int );
00209 
00211 
00213   vtkSetClampMacro( MaximumImageSampleDistance, int, 1, 32 );
00214   vtkGetMacro( MaximumImageSampleDistance, int );
00216 
00218 
00221   vtkSetClampMacro( AutoAdjustSampleDistances, int, 0, 1 );
00222   vtkGetMacro( AutoAdjustSampleDistances, int );
00223   vtkBooleanMacro( AutoAdjustSampleDistances, int );
00225 
00227 
00229   vtkSetClampMacro( IntermixIntersectingGeometry, int, 0, 1 );
00230   vtkGetMacro( IntermixIntersectingGeometry, int );
00231   vtkBooleanMacro( IntermixIntersectingGeometry, int );
00233                                
00234 //BTX
00235   
00238   virtual void Render(vtkRenderer *ren, vtkVolume *vol);
00239 
00240 //ETX
00241 
00242 protected:
00243   vtkVolumeShearWarpMapper();
00244   ~vtkVolumeShearWarpMapper();
00245 
00246   // Objects / variables  needed for shading / gradient magnitude opacity
00247   vtkEncodedGradientEstimator  *GradientEstimator;
00248   vtkEncodedGradientShader     *GradientShader;
00249   int                          Shade;
00250 
00251   float          *RedDiffuseShadingTable;
00252   float          *GreenDiffuseShadingTable;
00253   float          *BlueDiffuseShadingTable;
00254   float          *RedSpecularShadingTable;
00255   float          *GreenSpecularShadingTable;
00256   float          *BlueSpecularShadingTable;
00257 
00258   unsigned short *EncodedNormals;
00259   unsigned char  *GradientMagnitudes;
00260 
00261   vtkTransform *PerspectiveTransform;
00262   vtkMatrix4x4 *PerspectiveMatrix;
00263   vtkMatrix4x4 *ViewToWorldMatrix;
00264   vtkMatrix4x4 *ViewToVoxelsMatrix;
00265   vtkMatrix4x4 *VoxelsToViewMatrix;
00266   vtkMatrix4x4 *WorldToVoxelsMatrix;
00267   vtkMatrix4x4 *VoxelsToWorldMatrix;
00268   vtkMatrix4x4 *VoxelTransformMatrix;
00269   vtkMatrix4x4 *ViewportMatrix;
00270   vtkMatrix4x4 *ShearMatrix;
00271   vtkMatrix4x4 *WarpMatrix;
00272   vtkMatrix4x4 *PermutationMatrix;
00273   vtkMatrix4x4 *PermutedViewToVoxelsMatrix;
00274   vtkMatrix4x4 *PermutedVoxelsToViewMatrix;
00275 
00276   int           IntermixIntersectingGeometry;
00277   float        *ZBuffer;
00278   float        *IntermediateZBuffer;  
00279   int           ZBufferSize[2];
00280   int           ZBufferOrigin[2];
00281   float         MinimumViewDistance;
00282   
00283 
00284   vtkVolume *Volume;
00285   vtkShearWarpBase *EncodedVolume;
00286   vtkShearWarpBase *Octree;
00287   vtkShearWarpRLEImage *IntemediateImage;
00288   unsigned char *ImageData;
00289 
00290   int ImageWidth;
00291   int ImageHeight;
00292   int AllocatedSize;
00293   
00294   unsigned long ScalarOpacityMTime;
00295   int FunctionType;
00296   float IsoValue;
00297   int RunlengthEncoding;
00298   int FastClassification;
00299 
00300   int CountI;
00301   int CountJ;
00302   int CountK;
00303     
00304   int ReverseOrder;
00305   int MajorAxis;
00306   int ParallelProjection;
00307   int MyPerspectiveProjection;
00308 
00309   int IntermediateWidth;
00310   int IntermediateHeight;
00311   int MaximumIntermediateDimension;
00312 
00313   float ShearI;
00314   float ShearJ;
00315   float TranslationI;
00316   float TranslationJ;
00317   float Scale;
00318 
00319   // Depth cueing stuff
00320   /*
00321   float DepthI;
00322   float DepthJ;
00323   float DepthK;
00324   float Depth0;
00325   float DeltaDepth;
00326   float FrontDepth;
00327   float DepthDensity;
00328   float DepthTable[512];
00329   int DepthTableSize;
00330   */
00331   float ClippingPlane[4*6];
00332   int ClippingPlaneCount;
00333 
00334   // This is how big the image would be if it covered the entire viewport
00335   int ImageViewportSize[2];
00336     
00337   double WorldViewingDirection[4];
00338   double ObjectViewingDirection[4];
00339   double StandardViewingDirection[4];
00340 
00341   double WorldEyePosition[4];
00342   double ObjectEyePosition[4];
00343   double StandardEyePosition[4];
00344 
00345   // The distance between sample points along the ray
00346   int                          ImageSampleDistance;
00347   int                          MinimumImageSampleDistance;
00348   int                          MaximumImageSampleDistance;
00349   int                          AutoAdjustSampleDistances;
00350 
00351   float        *RenderTimeTable;
00352   vtkVolume   **RenderVolumeTable;
00353   vtkRenderer **RenderRendererTable;
00354   int           RenderTableSize;
00355   int           RenderTableEntries;
00356 
00357   void StoreRenderTime( vtkRenderer *ren, vtkVolume *vol, float t );
00358   float RetrieveRenderTime( vtkRenderer *ren, vtkVolume *vol );
00359 
00360   void ComputeMatrices( vtkImageData *data, vtkVolume *vol );
00361   void FactorViewMatrix();
00362   void ComputeViewMatrix();
00363   void ComputeViewportMatrix();
00364   void ComputePrincipalAxisParallel();
00365   void ComputePrincipalAxisPerspective();
00366   void ComputePermutationMatrix();
00367   void ComputeShearMatrixParallel();
00368   void ComputeShearMatrixPerspective();
00369   void ComputeWarpMatrix();
00370   void CompositeIntermediate();
00371   void BuildImage(unsigned char *id, vtkShearWarpPixelData *im);
00372 
00373   void Unwarp(float *destination, int dWidth, int dHeight, float *source, int left, int top, int sWidth, int sHeight, vtkMatrix4x4* w);
00374   void ExtractZBuffer(vtkRenderer *ren, vtkVolume *vol);
00375 
00376   void InitializeClippingPlanes( vtkPlaneCollection *planes );
00377   int IsVoxelClipped(int x, int y, int z);
00378 
00379   // void ComputeDepthTable(int first, int last);
00380   //void DepthCueImage (vtkShearWarpPixelData *im, int slice);
00381 
00382   virtual void RenderTexture(vtkRenderer *ren, vtkVolume *vol) = 0;
00383    
00384 private:
00385   vtkVolumeShearWarpMapper(const vtkVolumeShearWarpMapper&);  // Not implemented.
00386   void operator=(const vtkVolumeShearWarpMapper&);  // Not implemented.
00387 };
00388 
00389 
00390 
00391 #endif
00392 
00393