00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00055 #ifndef __vtkRayCaster_h
00056 #define __vtkRayCaster_h
00057
00058 #include "vtkRenderer.h"
00059 #include "vtkVolume.h"
00060 #include "vtkViewRays.h"
00061 #include "vtkVolumeMapper.h"
00062 #include "vtkMultiThreader.h"
00063
00064 #define VTK_MAX_VIEW_RAYS_LEVEL 4
00065
00066 class VTK_EXPORT vtkRayCaster : public vtkObject
00067 {
00068 public:
00069 static vtkRayCaster *New();
00070 vtkTypeMacro(vtkRayCaster,vtkObject);
00071 void PrintSelf(ostream& os, vtkIndent indent);
00072
00075 float *GetPerspectiveViewRays();
00076
00078 void GetViewRaysSize( int size[2] );
00079
00080
00083 float *GetParallelStartPosition( void );
00084
00087 float *GetParallelIncrements( void );
00088
00089
00092 void SetImageScale(int level, float scale);
00093 float GetImageScale(int level);
00094
00096 int GetImageScaleCount( void ) { return VTK_MAX_VIEW_RAYS_LEVEL; };
00097
00100 vtkSetClampMacro(SelectedImageScaleIndex, int, 0, VTK_MAX_VIEW_RAYS_LEVEL-1);
00101 vtkGetMacro( SelectedImageScaleIndex, int );
00102
00105 void SetViewRaysStepSize(int level, float scale);
00106 float GetViewRaysStepSize(int level);
00107
00109 vtkGetMacro( AutomaticScaleAdjustment, int );
00110
00112 void AutomaticScaleAdjustmentOn( void );
00113
00115 void AutomaticScaleAdjustmentOff( void );
00116
00120 vtkSetClampMacro( AutomaticScaleLowerLimit, float, 0.0, 1.0 );
00121 vtkGetMacro( AutomaticScaleLowerLimit, float );
00122
00124 vtkSetMacro( BilinearImageZoom, int );
00125 vtkGetMacro( BilinearImageZoom, int );
00126 vtkBooleanMacro( BilinearImageZoom, int );
00127
00129 vtkGetMacro( TotalRenderTime, float );
00130
00132 vtkSetMacro( NumberOfThreads, int );
00133 vtkGetMacro( NumberOfThreads, int );
00134
00138 int GetNumberOfSamplesTaken();
00139
00140 int **RowBounds;
00141 int *RowBoundsSize;
00142
00143 vtkProp **SoftwareProps;
00144 vtkProp **RayCastProps;
00145
00146
00147
00151 vtkSetObjectMacro(Renderer,vtkRenderer);
00152 vtkGetObjectMacro(Renderer,vtkRenderer);
00153
00159 void Render(vtkRenderer *, int, vtkProp **, int, vtkProp **);
00160
00168 float GetViewportScaleFactor( vtkRenderer *ren );
00169
00173 float GetViewportStepSize( );
00174
00175
00178 float *GetCurrentZBuffer()
00179 {
00180 if ( this->FirstBlend )
00181 {
00182 return NULL;
00183 }
00184 else
00185 {
00186 return this->ZImage;
00187 }
00188 };
00189
00190
00191
00192 protected:
00193 vtkRayCaster();
00194 ~vtkRayCaster();
00195 vtkRayCaster(const vtkRayCaster&) {};
00196 void operator=(const vtkRayCaster&) {};
00197
00200 void NearestNeighborZoom(float *smallImage, float *largeImage,
00201 int smallDims[2], int largeDims[2] );
00202
00204 void BilinearZoom(float *smallImage, float *largeImage,
00205 int smallDims[2], int largeDims[2] );
00206
00207
00211 void RescaleImage( );
00212
00213 void RenderFrameBufferVolumes( vtkRenderer *ren );
00214 void InitializeRenderBuffers( vtkRenderer *ren );
00215 void InitializeRayCasting( vtkRenderer *ren );
00216
00217
00218 void ComputeRowBounds( vtkRenderer *ren, vtkProp *prop, int index );
00219
00220
00221 friend VTK_THREAD_RETURN_TYPE RayCast_RenderImage( void *arg );
00222
00223 vtkMultiThreader *Threader;
00224
00225 int NumberOfThreads;
00226
00227 int NumberOfSamplesTaken[VTK_MAX_THREADS];
00228
00229 vtkRenderer *Renderer;
00230
00231
00232
00233 vtkViewRays *ViewRays[VTK_MAX_VIEW_RAYS_LEVEL+1];
00234 float *SelectedViewRays;
00235 float ImageScale[VTK_MAX_VIEW_RAYS_LEVEL+1];
00236 int ImageSize[2];
00237 int FullImageSize[2];
00238 int BilinearImageZoom;
00239 int SelectedImageScaleIndex;
00240 int StableImageScaleCounter;
00241 float PreviousAllocatedTime;
00242 int AutomaticScaleAdjustment;
00243 float AutomaticScaleLowerLimit;
00244 float ImageRenderTime[2];
00245 float ViewRaysStepSize[VTK_MAX_VIEW_RAYS_LEVEL];
00246 float TotalRenderTime;
00247
00248
00249 float *RGBAImage;
00250 float *ZImage;
00251
00252
00253
00254
00255 vtkVolume **RayCastVolumes;
00256
00257 struct VolumeRayCastVolumeInfoStruct *VolumeInfo;
00258
00259 int RayCastPropCount;
00260 int SoftwareBufferPropCount;
00261 vtkTransform *ViewToWorldTransform;
00262 float CameraClippingRange[2];
00263 float ViewToWorldMatrix[4][4];
00264 int FirstBlend;
00265 float CameraInverse22;
00266 float CameraInverse23;
00267 float CameraInverse32;
00268 float CameraInverse33;
00269 float CameraPosition[3];
00270 float *ParallelStartPosition;
00271 float *ParallelIncrements;
00272 int ParallelProjection;
00273 int NeedBackgroundBlend;
00274 float Background[3];
00275 };
00276
00277 #endif
00278
00279