00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00028 #ifndef __vtkVolumeRayCastMapper_h
00029 #define __vtkVolumeRayCastMapper_h
00030
00031 #include "vtkVolumeMapper.h"
00032 #include "vtkVolumeRayCastFunction.h"
00033
00034 #include "vtkFastNumericConversion.h"
00035
00036 class vtkEncodedGradientEstimator;
00037 class vtkEncodedGradientShader;
00038 class vtkMatrix4x4;
00039 class vtkMultiThreader;
00040 class vtkPlaneCollection;
00041 class vtkRenderer;
00042 class vtkTimerLog;
00043 class vtkVolume;
00044 class vtkVolumeRayCastFunction;
00045 class vtkVolumeTransform;
00046 class vtkTransform;
00047 class vtkRayCastImageDisplayHelper;
00048
00049
00050
00051
00052 inline int vtkFloorFuncMacro(double x)
00053 {
00054 return vtkFastNumericConversion::QuickFloor(x);
00055 }
00056
00057
00058
00059 inline int vtkRoundFuncMacro(double x)
00060 {
00061 return vtkFastNumericConversion::Round(x);
00062 }
00063
00064
00065
00066
00067
00068 #define vtkTrilinFuncMacro(v,x,y,z,a,b,c,d,e,f,g,h) \
00069 t00 = a + (x)*(b-a); \
00070 t01 = c + (x)*(d-c); \
00071 t10 = e + (x)*(f-e); \
00072 t11 = g + (x)*(h-g); \
00073 t0 = t00 + (y)*(t01-t00); \
00074 t1 = t10 + (y)*(t11-t10); \
00075 v = t0 + (z)*(t1-t0);
00076
00077
00078 VTK_THREAD_RETURN_TYPE VolumeRayCastMapper_CastRays( void *arg );
00079
00080 class VTK_VOLUMERENDERING_EXPORT vtkVolumeRayCastMapper : public vtkVolumeMapper
00081 {
00082 public:
00083 static vtkVolumeRayCastMapper *New();
00084 vtkTypeRevisionMacro(vtkVolumeRayCastMapper,vtkVolumeMapper);
00085 void PrintSelf( ostream& os, vtkIndent indent );
00086
00088
00091 vtkSetMacro( SampleDistance, double );
00092 vtkGetMacro( SampleDistance, double );
00094
00096
00098 virtual void SetVolumeRayCastFunction(vtkVolumeRayCastFunction*);
00099 vtkGetObjectMacro( VolumeRayCastFunction, vtkVolumeRayCastFunction );
00101
00103
00104 virtual void SetGradientEstimator(vtkEncodedGradientEstimator *gradest);
00105 vtkGetObjectMacro( GradientEstimator, vtkEncodedGradientEstimator );
00107
00109
00110 vtkGetObjectMacro( GradientShader, vtkEncodedGradientShader );
00112
00114
00117 vtkSetClampMacro( ImageSampleDistance, double, 0.1, 100.0 );
00118 vtkGetMacro( ImageSampleDistance, double );
00120
00122
00124 vtkSetClampMacro( MinimumImageSampleDistance, double, 0.1, 100.0 );
00125 vtkGetMacro( MinimumImageSampleDistance, double );
00127
00129
00131 vtkSetClampMacro( MaximumImageSampleDistance, double, 0.1, 100.0 );
00132 vtkGetMacro( MaximumImageSampleDistance, double );
00134
00136
00139 vtkSetClampMacro( AutoAdjustSampleDistances, int, 0, 1 );
00140 vtkGetMacro( AutoAdjustSampleDistances, int );
00141 vtkBooleanMacro( AutoAdjustSampleDistances, int );
00143
00145
00147 void SetNumberOfThreads( int num );
00148 int GetNumberOfThreads();
00150
00152
00154 vtkSetClampMacro( IntermixIntersectingGeometry, int, 0, 1 );
00155 vtkGetMacro( IntermixIntersectingGeometry, int );
00156 vtkBooleanMacro( IntermixIntersectingGeometry, int );
00158
00159
00162 void Render( vtkRenderer *, vtkVolume * );
00163
00168 void ReleaseGraphicsResources(vtkWindow *);
00169
00172 float GetZeroOpacityThreshold( vtkVolume *vol );
00173
00175
00177 virtual float GetGradientMagnitudeScale();
00178 virtual float GetGradientMagnitudeBias();
00179 virtual float GetGradientMagnitudeScale(int)
00180 {return this->GetGradientMagnitudeScale();};
00181 virtual float GetGradientMagnitudeBias(int)
00182 {return this->GetGradientMagnitudeBias();};
00184
00185
00186
00187 protected:
00188 vtkVolumeRayCastMapper();
00189 ~vtkVolumeRayCastMapper();
00190
00191 vtkVolumeRayCastFunction *VolumeRayCastFunction;
00192 vtkEncodedGradientEstimator *GradientEstimator;
00193 vtkEncodedGradientShader *GradientShader;
00194 vtkRayCastImageDisplayHelper *ImageDisplayHelper;
00195
00196 virtual void ReportReferences(vtkGarbageCollector*);
00197
00198
00199 double SampleDistance;
00200 double ImageSampleDistance;
00201 double MinimumImageSampleDistance;
00202 double MaximumImageSampleDistance;
00203 int AutoAdjustSampleDistances;
00204
00205 double WorldSampleDistance;
00206 int ScalarDataType;
00207 void *ScalarDataPointer;
00208
00209 void UpdateShadingTables( vtkRenderer *ren,
00210 vtkVolume *vol );
00211
00212 void ComputeMatrices( vtkImageData *data, vtkVolume *vol );
00213 int ComputeRowBounds( vtkVolume *vol, vtkRenderer *ren );
00214
00215 friend VTK_THREAD_RETURN_TYPE VolumeRayCastMapper_CastRays( void *arg );
00216
00217 vtkMultiThreader *Threader;
00218
00219 vtkMatrix4x4 *PerspectiveMatrix;
00220 vtkMatrix4x4 *ViewToWorldMatrix;
00221 vtkMatrix4x4 *ViewToVoxelsMatrix;
00222 vtkMatrix4x4 *VoxelsToViewMatrix;
00223 vtkMatrix4x4 *WorldToVoxelsMatrix;
00224 vtkMatrix4x4 *VoxelsToWorldMatrix;
00225
00226 vtkMatrix4x4 *VolumeMatrix;
00227
00228 vtkTransform *PerspectiveTransform;
00229 vtkTransform *VoxelsTransform;
00230 vtkTransform *VoxelsToViewTransform;
00231
00232
00233 int ImageViewportSize[2];
00234
00235
00236
00237
00238
00239 int ImageMemorySize[2];
00240
00241
00242
00243
00244
00245 int ImageInUseSize[2];
00246
00247
00248
00249 int ImageOrigin[2];
00250
00251
00252 unsigned char *Image;
00253
00254 int *RowBounds;
00255 int *OldRowBounds;
00256
00257 float *RenderTimeTable;
00258 vtkVolume **RenderVolumeTable;
00259 vtkRenderer **RenderRendererTable;
00260 int RenderTableSize;
00261 int RenderTableEntries;
00262
00263 void StoreRenderTime( vtkRenderer *ren, vtkVolume *vol, float t );
00264 float RetrieveRenderTime( vtkRenderer *ren, vtkVolume *vol );
00265
00266 int IntermixIntersectingGeometry;
00267
00268 float *ZBuffer;
00269 int ZBufferSize[2];
00270 int ZBufferOrigin[2];
00271
00272 float MinimumViewDistance;
00273
00274 int ClipRayAgainstVolume( vtkVolumeRayCastDynamicInfo *dynamicInfo,
00275 float bounds[6] );
00276
00277 void InitializeClippingPlanes( vtkVolumeRayCastStaticInfo *staticInfo,
00278 vtkPlaneCollection *planes );
00279
00280 int ClipRayAgainstClippingPlanes( vtkVolumeRayCastDynamicInfo *dynamicInfo,
00281 vtkVolumeRayCastStaticInfo *staticInfo);
00282
00283
00284
00285
00286 double GetZBufferValue( int x, int y );
00287
00288 private:
00289 vtkVolumeRayCastMapper(const vtkVolumeRayCastMapper&);
00290 void operator=(const vtkVolumeRayCastMapper&);
00291 };
00292
00293 #endif
00294