00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00048 #ifndef __vtkVolumeShearWarpMapper_h
00049 #define __vtkVolumeShearWarpMapper_h
00050
00051 #include "vtkVolumeMapper.h"
00052
00053 class vtkEncodedGradientShader;
00054 class vtkEncodedGradientEstimator;
00055
00056 class vtkStructuredPoints;
00057 class vtkCamera;
00058 class vtkVolume;
00059 class vtkImageData;
00060 class vtkVolumeProperty;
00061 class vtkPiecewiseFunction;
00062 class vtkTransform;
00063 class vtkMatrix4x4;
00064
00065 class vtkRenderer;
00066 class vtkRenderWindow;
00067
00068
00069
00070 class vtkShearWarpPixelData;
00071 class vtkShearWarpRLEImage;
00072 template <class T> struct vtkShearWarpVoxelData;
00073 template <class T> class vtkShearWarpRLERun;
00074 template <class T> class vtkShearWarpRLESlice;
00075 class vtkShearWarpBase;
00076 template <class T> class vtkShearWarpRLEVolume;
00077 template <class T> class vtkShearWarpSummedAreaTable;
00078 struct vtkShearWarpOctreeRun;
00079 template <class T> class vtkShearWarpOctreeNode;
00080 template <class T> class vtkShearWarpOctree;
00081
00082 #define VTK_X_AXIS 0
00083 #define VTK_Y_AXIS 1
00084 #define VTK_Z_AXIS 2
00085
00086 #define VTK_SHEAR_WARP_COMPOSITE_FUNCTION 0
00087 #define VTK_SHEAR_WARP_MIP_FUNCTION 1
00088 #define VTK_SHEAR_WARP_ISOSURFACE_FUNCTION 2
00089
00090 #define VTK_SHEAR_WARP_OCTREE_TRANSPARENT 0
00091 #define VTK_SHEAR_WARP_OCTREE_NONTRANSPARENT 1
00092 #define VTK_SHEAR_WARP_OCTREE_COMBINATION 2
00093 #define VTK_SHEAR_WARP_OCTREE_MINIMUM_SIZE 16
00094
00095
00096 class VTK_VOLUMERENDERING_EXPORT vtkVolumeShearWarpMapper : public vtkVolumeMapper
00097 {
00098
00099 template <class T>
00100 friend void CompositeIntermediateNearestSimple(vtkShearWarpRLEImage *image, vtkVolumeShearWarpMapper *myThis);
00101
00102 template <class T>
00103 friend void CompositeIntermediateLinearSimple(vtkShearWarpRLEImage *image, vtkVolumeShearWarpMapper *myThis);
00104
00105 template <class T>
00106 friend void CompositeIntermediateNearestRLE(vtkShearWarpRLEImage *image, vtkVolumeShearWarpMapper *myThis);
00107
00108 template <class T>
00109 friend void CompositeIntermediateLinearRLE(vtkShearWarpRLEImage *image, vtkVolumeShearWarpMapper *myThis);
00110
00111 template <class T>
00112 friend void CompositeIntermediateNearestUnclassified(vtkShearWarpRLEImage *image, vtkVolumeShearWarpMapper *myThis);
00113
00114 template <class T>
00115 friend void CompositeIntermediateLinearUnclassified(vtkShearWarpRLEImage *image, vtkVolumeShearWarpMapper *myThis);
00116
00117 template <class T>
00118 friend void CompositeIntermediateLinearRLEPerspective(vtkShearWarpRLEImage *image, vtkVolumeShearWarpMapper *myThis);
00119
00120
00121 public:
00122 static vtkVolumeShearWarpMapper *New();
00123 vtkTypeRevisionMacro(vtkVolumeShearWarpMapper,vtkVolumeMapper);
00124 void PrintSelf(ostream& os, vtkIndent indent);
00125
00127 virtual void Update();
00128
00130
00131 void SetGradientEstimator( vtkEncodedGradientEstimator *gradest );
00132 vtkGetObjectMacro( GradientEstimator, vtkEncodedGradientEstimator );
00134
00136
00137 vtkGetObjectMacro( GradientShader, vtkEncodedGradientShader );
00139
00141
00142 vtkSetMacro( IsoValue, float );
00143 vtkGetMacro( IsoValue, float );
00145
00147
00148 vtkSetMacro(RunlengthEncoding,int);
00149 vtkGetMacro(RunlengthEncoding,int);
00150 vtkBooleanMacro(RunlengthEncoding,int);
00152
00154
00155 vtkSetMacro(FastClassification,int);
00156 vtkGetMacro(FastClassification,int);
00157 vtkBooleanMacro(FastClassification,int);
00159
00161
00162 vtkSetMacro(ParallelProjection,int);
00163 vtkGetMacro(ParallelProjection,int);
00164 vtkBooleanMacro(ParallelProjection, int);
00166
00167 vtkSetMacro(MyPerspectiveProjection,int);
00168 vtkGetMacro(MyPerspectiveProjection,int);
00169 vtkBooleanMacro(MyPerspectiveProjection, int);
00170
00172
00173 vtkSetClampMacro( FunctionType, int,
00174 VTK_SHEAR_WARP_COMPOSITE_FUNCTION, VTK_SHEAR_WARP_ISOSURFACE_FUNCTION);
00175 vtkGetMacro(FunctionType,int);
00176 void SetFunctionTypeToComposite()
00177 {this->SetFunctionType(VTK_SHEAR_WARP_COMPOSITE_FUNCTION);};
00178 void SetFunctionTypeToMIP()
00179 {this->SetFunctionType(VTK_SHEAR_WARP_MIP_FUNCTION);};
00180 void SetFunctionTypeToIsosurface()
00181 {this->SetFunctionType(VTK_SHEAR_WARP_ISOSURFACE_FUNCTION);};
00183
00184 int Debug;
00185
00187
00189 vtkSetClampMacro( ImageSampleDistance, int, 1, 32 );
00190 vtkGetMacro( ImageSampleDistance, int );
00192
00194
00196 vtkSetClampMacro( MinimumImageSampleDistance, int, 1, 32 );
00197 vtkGetMacro( MinimumImageSampleDistance, int );
00199
00201
00203 vtkSetClampMacro( MaximumImageSampleDistance, int, 1, 32 );
00204 vtkGetMacro( MaximumImageSampleDistance, int );
00206
00208
00211 vtkSetClampMacro( AutoAdjustSampleDistances, int, 0, 1 );
00212 vtkGetMacro( AutoAdjustSampleDistances, int );
00213 vtkBooleanMacro( AutoAdjustSampleDistances, int );
00215
00217
00219 vtkSetClampMacro( IntermixIntersectingGeometry, int, 0, 1 );
00220 vtkGetMacro( IntermixIntersectingGeometry, int );
00221 vtkBooleanMacro( IntermixIntersectingGeometry, int );
00223
00224
00225
00228 virtual void Render(vtkRenderer *ren, vtkVolume *vol);
00229
00230
00231
00232 protected:
00233 vtkVolumeShearWarpMapper();
00234 ~vtkVolumeShearWarpMapper();
00235
00236
00237 vtkEncodedGradientEstimator *GradientEstimator;
00238 vtkEncodedGradientShader *GradientShader;
00239 int Shade;
00240
00241 float *RedDiffuseShadingTable;
00242 float *GreenDiffuseShadingTable;
00243 float *BlueDiffuseShadingTable;
00244 float *RedSpecularShadingTable;
00245 float *GreenSpecularShadingTable;
00246 float *BlueSpecularShadingTable;
00247
00248 unsigned short *EncodedNormals;
00249 unsigned char *GradientMagnitudes;
00250
00251 vtkTransform *PerspectiveTransform;
00252 vtkMatrix4x4 *PerspectiveMatrix;
00253 vtkMatrix4x4 *ViewToWorldMatrix;
00254 vtkMatrix4x4 *ViewToVoxelsMatrix;
00255 vtkMatrix4x4 *VoxelsToViewMatrix;
00256 vtkMatrix4x4 *WorldToVoxelsMatrix;
00257 vtkMatrix4x4 *VoxelsToWorldMatrix;
00258 vtkMatrix4x4 *VoxelTransformMatrix;
00259 vtkMatrix4x4 *ViewportMatrix;
00260 vtkMatrix4x4 *ShearMatrix;
00261 vtkMatrix4x4 *WarpMatrix;
00262 vtkMatrix4x4 *PermutationMatrix;
00263 vtkMatrix4x4 *PermutedViewToVoxelsMatrix;
00264 vtkMatrix4x4 *PermutedVoxelsToViewMatrix;
00265
00266 int IntermixIntersectingGeometry;
00267 float *ZBuffer;
00268 float *IntermediateZBuffer;
00269 int ZBufferSize[2];
00270 int ZBufferOrigin[2];
00271 float MinimumViewDistance;
00272
00273
00274 vtkVolume *Volume;
00275 vtkShearWarpBase *EncodedVolume;
00276 vtkShearWarpBase *Octree;
00277 vtkShearWarpRLEImage *IntemediateImage;
00278 unsigned char *ImageData;
00279
00280 int ImageWidth;
00281 int ImageHeight;
00282 int AllocatedSize;
00283
00284 unsigned long ScalarOpacityMTime;
00285 int FunctionType;
00286 float IsoValue;
00287 int RunlengthEncoding;
00288 int FastClassification;
00289
00290 int CountI;
00291 int CountJ;
00292 int CountK;
00293
00294 int ReverseOrder;
00295 int MajorAxis;
00296 int ParallelProjection;
00297 int MyPerspectiveProjection;
00298
00299 int IntermediateWidth;
00300 int IntermediateHeight;
00301 int MaximumIntermediateDimension;
00302
00303 float ShearI;
00304 float ShearJ;
00305 float TranslationI;
00306 float TranslationJ;
00307 float Scale;
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321 float ClippingPlane[4*6];
00322 int ClippingPlaneCount;
00323
00324
00325 int ImageViewportSize[2];
00326
00327 double WorldViewingDirection[4];
00328 double ObjectViewingDirection[4];
00329 double StandardViewingDirection[4];
00330
00331 double WorldEyePosition[4];
00332 double ObjectEyePosition[4];
00333 double StandardEyePosition[4];
00334
00335
00336 int ImageSampleDistance;
00337 int MinimumImageSampleDistance;
00338 int MaximumImageSampleDistance;
00339 int AutoAdjustSampleDistances;
00340
00341 float *RenderTimeTable;
00342 vtkVolume **RenderVolumeTable;
00343 vtkRenderer **RenderRendererTable;
00344 int RenderTableSize;
00345 int RenderTableEntries;
00346
00347 void StoreRenderTime( vtkRenderer *ren, vtkVolume *vol, float t );
00348 float RetrieveRenderTime( vtkRenderer *ren, vtkVolume *vol );
00349
00350 void ComputeMatrices( vtkImageData *data, vtkVolume *vol );
00351 void FactorViewMatrix();
00352 void ComputeViewMatrix();
00353 void ComputeViewportMatrix();
00354 void ComputePrincipalAxisParallel();
00355 void ComputePrincipalAxisPerspective();
00356 void ComputePermutationMatrix();
00357 void ComputeShearMatrixParallel();
00358 void ComputeShearMatrixPerspective();
00359 void ComputeWarpMatrix();
00360 void CompositeIntermediate();
00361 void BuildImage(unsigned char *id, vtkShearWarpPixelData *im);
00362
00363 void Unwarp(float *destination, int dWidth, int dHeight, float *source, int left, int top, int sWidth, int sHeight, vtkMatrix4x4* w);
00364 void ExtractZBuffer(vtkRenderer *ren, vtkVolume *vol);
00365
00366 void InitializeClippingPlanes( vtkPlaneCollection *planes );
00367 int IsVoxelClipped(int x, int y, int z);
00368
00369
00370
00371
00372 virtual void RenderTexture(vtkRenderer *ren, vtkVolume *vol) = 0;
00373
00374 private:
00375 vtkVolumeShearWarpMapper(const vtkVolumeShearWarpMapper&);
00376 void operator=(const vtkVolumeShearWarpMapper&);
00377 };
00378
00379
00380
00381 #endif
00382
00383