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