00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00041 #ifndef __vtkVolumeRayCastMapper_h
00042 #define __vtkVolumeRayCastMapper_h
00043
00044 #include "vtkVolumeMapper.h"
00045 #include "vtkVolumeRayCastFunction.h"
00046
00047 class vtkEncodedGradientEstimator;
00048 class vtkEncodedGradientShader;
00049 class vtkMatrix4x4;
00050 class vtkMultiThreader;
00051 class vtkPlaneCollection;
00052 class vtkRenderer;
00053 class vtkTimerLog;
00054 class vtkVolume;
00055 class vtkVolumeRayCastFunction;
00056 class vtkVolumeTransform;
00057 class vtkTransform;
00058
00059
00060
00061 inline int vtkFloorFuncMacro(double x)
00062 {
00063 #if defined i386 || defined _M_IX86
00064 double tempval;
00065
00066
00067
00068 tempval = (x - 0.25) + 3377699720527872.0;
00069
00070
00071
00072 return ((int*)&tempval)[0] >> 1;
00073 #else
00074
00075 return (int)(x);
00076 #endif
00077 }
00078
00079
00080 inline int vtkRoundFuncMacro(double x)
00081 {
00082 return vtkFloorFuncMacro(x + 0.5);
00083 }
00084
00085
00086
00087
00088
00089 #define vtkTrilinFuncMacro(v,x,y,z,a,b,c,d,e,f,g,h) \
00090 t00 = a + (x)*(b-a); \
00091 t01 = c + (x)*(d-c); \
00092 t10 = e + (x)*(f-e); \
00093 t11 = g + (x)*(h-g); \
00094 t0 = t00 + (y)*(t01-t00); \
00095 t1 = t10 + (y)*(t11-t10); \
00096 v = t0 + (z)*(t1-t0);
00097
00098
00099 VTK_THREAD_RETURN_TYPE VolumeRayCastMapper_CastRays( void *arg );
00100
00101 class VTK_RENDERING_EXPORT vtkVolumeRayCastMapper : public vtkVolumeMapper
00102 {
00103 public:
00104 static vtkVolumeRayCastMapper *New();
00105 vtkTypeRevisionMacro(vtkVolumeRayCastMapper,vtkVolumeMapper);
00106 void PrintSelf( ostream& os, vtkIndent indent );
00107
00109
00112 vtkSetMacro( SampleDistance, double );
00113 vtkGetMacro( SampleDistance, double );
00115
00117
00119 virtual void SetVolumeRayCastFunction(vtkVolumeRayCastFunction*);
00120 vtkGetObjectMacro( VolumeRayCastFunction, vtkVolumeRayCastFunction );
00122
00124
00125 virtual void SetGradientEstimator(vtkEncodedGradientEstimator *gradest);
00126 vtkGetObjectMacro( GradientEstimator, vtkEncodedGradientEstimator );
00128
00130
00131 vtkGetObjectMacro( GradientShader, vtkEncodedGradientShader );
00133
00135
00138 vtkSetClampMacro( ImageSampleDistance, double, 0.1, 100.0 );
00139 vtkGetMacro( ImageSampleDistance, double );
00141
00143
00145 vtkSetClampMacro( MinimumImageSampleDistance, double, 0.1, 100.0 );
00146 vtkGetMacro( MinimumImageSampleDistance, double );
00148
00150
00152 vtkSetClampMacro( MaximumImageSampleDistance, double, 0.1, 100.0 );
00153 vtkGetMacro( MaximumImageSampleDistance, double );
00155
00157
00160 vtkSetClampMacro( AutoAdjustSampleDistances, int, 0, 1 );
00161 vtkGetMacro( AutoAdjustSampleDistances, int );
00162 vtkBooleanMacro( AutoAdjustSampleDistances, int );
00164
00166
00168 void SetNumberOfThreads( int num );
00169 vtkGetMacro( NumberOfThreads, int );
00171
00173
00175 vtkSetClampMacro( IntermixIntersectingGeometry, int, 0, 1 );
00176 vtkGetMacro( IntermixIntersectingGeometry, int );
00177 vtkBooleanMacro( IntermixIntersectingGeometry, int );
00179
00180
00183 void Render( vtkRenderer *, vtkVolume * );
00184
00189 void ReleaseGraphicsResources(vtkWindow *);
00190
00193 float GetZeroOpacityThreshold( vtkVolume *vol );
00194
00196
00198 virtual float GetGradientMagnitudeScale();
00199 virtual float GetGradientMagnitudeBias();
00200 virtual float GetGradientMagnitudeScale(int)
00201 {return this->GetGradientMagnitudeScale();};
00202 virtual float GetGradientMagnitudeBias(int)
00203 {return this->GetGradientMagnitudeBias();};
00205
00206
00207
00208 protected:
00209 vtkVolumeRayCastMapper();
00210 ~vtkVolumeRayCastMapper();
00211
00212 vtkVolumeRayCastFunction *VolumeRayCastFunction;
00213 vtkEncodedGradientEstimator *GradientEstimator;
00214 vtkEncodedGradientShader *GradientShader;
00215
00216 virtual void ReportReferences(vtkGarbageCollector*);
00217 virtual void RemoveReferences();
00218
00219
00220 double SampleDistance;
00221 double ImageSampleDistance;
00222 double MinimumImageSampleDistance;
00223 double MaximumImageSampleDistance;
00224 int AutoAdjustSampleDistances;
00225
00226 double WorldSampleDistance;
00227 int ScalarDataType;
00228 void *ScalarDataPointer;
00229
00230 void UpdateShadingTables( vtkRenderer *ren,
00231 vtkVolume *vol );
00232
00233 void ComputeMatrices( vtkImageData *data, vtkVolume *vol );
00234 virtual void RenderTexture( vtkVolume *vol, vtkRenderer *ren)=0;
00235 int ComputeRowBounds( vtkVolume *vol, vtkRenderer *ren );
00236
00237 friend VTK_THREAD_RETURN_TYPE VolumeRayCastMapper_CastRays( void *arg );
00238
00239 vtkMultiThreader *Threader;
00240 int NumberOfThreads;
00241
00242 vtkMatrix4x4 *PerspectiveMatrix;
00243 vtkMatrix4x4 *ViewToWorldMatrix;
00244 vtkMatrix4x4 *ViewToVoxelsMatrix;
00245 vtkMatrix4x4 *VoxelsToViewMatrix;
00246 vtkMatrix4x4 *WorldToVoxelsMatrix;
00247 vtkMatrix4x4 *VoxelsToWorldMatrix;
00248
00249 vtkMatrix4x4 *VolumeMatrix;
00250
00251 vtkTransform *PerspectiveTransform;
00252 vtkTransform *VoxelsTransform;
00253 vtkTransform *VoxelsToViewTransform;
00254
00255
00256 int ImageViewportSize[2];
00257
00258
00259
00260
00261
00262 int ImageMemorySize[2];
00263
00264
00265
00266
00267
00268 int ImageInUseSize[2];
00269
00270
00271
00272 int ImageOrigin[2];
00273
00274
00275 unsigned char *Image;
00276
00277 int *RowBounds;
00278 int *OldRowBounds;
00279
00280 float *RenderTimeTable;
00281 vtkVolume **RenderVolumeTable;
00282 vtkRenderer **RenderRendererTable;
00283 int RenderTableSize;
00284 int RenderTableEntries;
00285
00286 void StoreRenderTime( vtkRenderer *ren, vtkVolume *vol, float t );
00287 float RetrieveRenderTime( vtkRenderer *ren, vtkVolume *vol );
00288
00289 int IntermixIntersectingGeometry;
00290
00291 float *ZBuffer;
00292 int ZBufferSize[2];
00293 int ZBufferOrigin[2];
00294
00295 float MinimumViewDistance;
00296
00297 int ClipRayAgainstVolume( vtkVolumeRayCastDynamicInfo *dynamicInfo,
00298 float bounds[6] );
00299
00300 void InitializeClippingPlanes( vtkVolumeRayCastStaticInfo *staticInfo,
00301 vtkPlaneCollection *planes );
00302
00303 int ClipRayAgainstClippingPlanes( vtkVolumeRayCastDynamicInfo *dynamicInfo,
00304 vtkVolumeRayCastStaticInfo *staticInfo);
00305
00306
00307
00308
00309 double GetZBufferValue( int x, int y );
00310
00311 private:
00312 vtkVolumeRayCastMapper(const vtkVolumeRayCastMapper&);
00313 void operator=(const vtkVolumeRayCastMapper&);
00314 };
00315
00316 #endif
00317