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
class vtkEncodedGradientEstimator;
00038
class vtkEncodedGradientShader;
00039
class vtkMatrix4x4;
00040
class vtkMultiThreader;
00041
class vtkPlaneCollection;
00042
class vtkRenderer;
00043
class vtkTimerLog;
00044
class vtkVolume;
00045
class vtkVolumeRayCastFunction;
00046
class vtkVolumeTransform;
00047
class vtkTransform;
00048
00049
00050
00051 inline int vtkFloorFuncMacro(
double x)
00052 {
00053
#if defined i386 || defined _M_IX86
00054
double tempval;
00055
00056
00057
00058 tempval = (x - 0.25) + 3377699720527872.0;
00059
00060
00061
00062
return ((
int*)&tempval)[0] >> 1;
00063
#else
00064
00065
return (
int)(x);
00066
#endif
00067
}
00068
00069
00070 inline int vtkRoundFuncMacro(
double x)
00071 {
00072
return vtkFloorFuncMacro(x + 0.5);
00073 }
00074
00075
00076
00077
00078
00079 #define vtkTrilinFuncMacro(v,x,y,z,a,b,c,d,e,f,g,h) \
00080
t00 = a + (x)*(b-a); \
00081
t01 = c + (x)*(d-c); \
00082
t10 = e + (x)*(f-e); \
00083
t11 = g + (x)*(h-g); \
00084
t0 = t00 + (y)*(t01-t00); \
00085
t1 = t10 + (y)*(t11-t10); \
00086
v = t0 + (z)*(t1-t0);
00087
00088
00089
VTK_THREAD_RETURN_TYPE VolumeRayCastMapper_CastRays(
void *arg );
00090
00091 class VTK_RENDERING_EXPORT vtkVolumeRayCastMapper :
public vtkVolumeMapper
00092 {
00093
public:
00094
static vtkVolumeRayCastMapper *
New();
00095 vtkTypeRevisionMacro(vtkVolumeRayCastMapper,
vtkVolumeMapper);
00096
void PrintSelf( ostream& os,
vtkIndent indent );
00097
00099
00102 vtkSetMacro( SampleDistance,
double );
00103 vtkGetMacro( SampleDistance,
double );
00105
00107
00109
virtual void SetVolumeRayCastFunction(
vtkVolumeRayCastFunction*);
00110 vtkGetObjectMacro( VolumeRayCastFunction,
vtkVolumeRayCastFunction );
00112
00114
00115
virtual void SetGradientEstimator(
vtkEncodedGradientEstimator *gradest);
00116 vtkGetObjectMacro( GradientEstimator,
vtkEncodedGradientEstimator );
00118
00120
00121 vtkGetObjectMacro( GradientShader,
vtkEncodedGradientShader );
00123
00125
00128 vtkSetClampMacro( ImageSampleDistance,
double, 0.1f, 100.0f );
00129 vtkGetMacro( ImageSampleDistance,
double );
00131
00133
00135 vtkSetClampMacro( MinimumImageSampleDistance,
double, 0.1f, 100.0f );
00136 vtkGetMacro( MinimumImageSampleDistance,
double );
00138
00140
00142 vtkSetClampMacro( MaximumImageSampleDistance,
double, 0.1f, 100.0f );
00143 vtkGetMacro( MaximumImageSampleDistance,
double );
00145
00147
00150 vtkSetClampMacro( AutoAdjustSampleDistances,
int, 0, 1 );
00151 vtkGetMacro( AutoAdjustSampleDistances,
int );
00152 vtkBooleanMacro( AutoAdjustSampleDistances,
int );
00154
00156
00158
void SetNumberOfThreads(
int num );
00159 vtkGetMacro( NumberOfThreads,
int );
00161
00163
00165 vtkSetClampMacro( IntermixIntersectingGeometry,
int, 0, 1 );
00166 vtkGetMacro( IntermixIntersectingGeometry,
int );
00167 vtkBooleanMacro( IntermixIntersectingGeometry,
int );
00169
00170
00173
void Render(
vtkRenderer *,
vtkVolume * );
00174
00179
void ReleaseGraphicsResources(
vtkWindow *);
00180
00183
float GetZeroOpacityThreshold(
vtkVolume *vol );
00184
00186
00188
virtual float GetGradientMagnitudeScale();
00189
virtual float GetGradientMagnitudeBias();
00190 virtual float GetGradientMagnitudeScale(
int)
00191 {
return this->
GetGradientMagnitudeScale();};
00192 virtual float GetGradientMagnitudeBias(
int)
00193 {
return this->
GetGradientMagnitudeBias();};
00195
00196
00197
00198
protected:
00199 vtkVolumeRayCastMapper();
00200 ~vtkVolumeRayCastMapper();
00201
00202 vtkVolumeRayCastFunction *VolumeRayCastFunction;
00203 vtkEncodedGradientEstimator *GradientEstimator;
00204 vtkEncodedGradientShader *GradientShader;
00205
00206
00207 double SampleDistance;
00208 double ImageSampleDistance;
00209 double MinimumImageSampleDistance;
00210 double MaximumImageSampleDistance;
00211 int AutoAdjustSampleDistances;
00212
00213 double WorldSampleDistance;
00214 int ScalarDataType;
00215 void *ScalarDataPointer;
00216
00217
void UpdateShadingTables(
vtkRenderer *ren,
00218
vtkVolume *vol );
00219
00220
void ComputeMatrices(
vtkImageData *data,
vtkVolume *vol );
00221
virtual void RenderTexture(
vtkVolume *vol,
vtkRenderer *ren)=0;
00222
int ComputeRowBounds(
vtkVolume *vol,
vtkRenderer *ren );
00223
00224
friend VTK_THREAD_RETURN_TYPE VolumeRayCastMapper_CastRays(
void *arg );
00225
00226 vtkMultiThreader *Threader;
00227 int NumberOfThreads;
00228
00229 vtkMatrix4x4 *PerspectiveMatrix;
00230 vtkMatrix4x4 *ViewToWorldMatrix;
00231 vtkMatrix4x4 *ViewToVoxelsMatrix;
00232 vtkMatrix4x4 *VoxelsToViewMatrix;
00233 vtkMatrix4x4 *WorldToVoxelsMatrix;
00234 vtkMatrix4x4 *VoxelsToWorldMatrix;
00235
00236 vtkMatrix4x4 *VolumeMatrix;
00237
00238 vtkTransform *PerspectiveTransform;
00239 vtkTransform *VoxelsTransform;
00240 vtkTransform *VoxelsToViewTransform;
00241
00242
00243 int ImageViewportSize[2];
00244
00245
00246
00247
00248
00249 int ImageMemorySize[2];
00250
00251
00252
00253
00254
00255 int ImageInUseSize[2];
00256
00257
00258
00259 int ImageOrigin[2];
00260
00261
00262 unsigned char *Image;
00263
00264 int *RowBounds;
00265 int *OldRowBounds;
00266
00267 float *RenderTimeTable;
00268 vtkVolume **RenderVolumeTable;
00269 vtkRenderer **RenderRendererTable;
00270 int RenderTableSize;
00271 int RenderTableEntries;
00272
00273
void StoreRenderTime(
vtkRenderer *ren,
vtkVolume *vol,
float t );
00274
float RetrieveRenderTime(
vtkRenderer *ren,
vtkVolume *vol );
00275
00276 int IntermixIntersectingGeometry;
00277
00278 float *ZBuffer;
00279 int ZBufferSize[2];
00280 int ZBufferOrigin[2];
00281
00282 float MinimumViewDistance;
00283
00284
int ClipRayAgainstVolume(
vtkVolumeRayCastDynamicInfo *dynamicInfo,
00285
float bounds[6] );
00286
00287
void InitializeClippingPlanes(
vtkVolumeRayCastStaticInfo *staticInfo,
00288
vtkPlaneCollection *planes );
00289
00290
int ClipRayAgainstClippingPlanes(
vtkVolumeRayCastDynamicInfo *dynamicInfo,
00291
vtkVolumeRayCastStaticInfo *staticInfo);
00292
00293
00294
00295
00296
double GetZBufferValue(
int x,
int y );
00297
00298
private:
00299 vtkVolumeRayCastMapper(
const vtkVolumeRayCastMapper&);
00300
void operator=(
const vtkVolumeRayCastMapper&);
00301 };
00302
00303
#endif
00304