Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef __vtkMitkOpenGLGPUVolumeRayCastMapper_h
00025 #define __vtkMitkOpenGLGPUVolumeRayCastMapper_h
00026
00027 #include "vtkMitkGPUVolumeRayCastMapper.h"
00028 #include "mitkCommon.h"
00029 #include "MitkExtExports.h"
00030
00031
00032 #if ((VTK_MAJOR_VERSION > 5) || ((VTK_MAJOR_VERSION==5) && (VTK_MINOR_VERSION>=6) ))
00033
00034 class vtkVolume;
00035 class vtkRenderer;
00036 class vtkOpenGLExtensionManager;
00037 class vtkMatrix4x4;
00038 class vtkUnsupportedRequiredExtensionsStringStream;
00039 class vtkMapDataArrayTextureId;
00040 class vtkMapMaskTextureId;
00041 class vtkPolyData;
00042 class vtkClipConvexPolyData;
00043 class vtkClipPolyData;
00044 class vtkTessellatedBoxSource;
00045
00046 class vtkOpacityTable;
00047 class vtkRGBTable;
00048 class vtkKWScalarField;
00049 class vtkKWMask;
00050
00051 class vtkOpacityTables;
00052 class vtkDensifyPolyData;
00053 class vtkStdString;
00054
00055 class MitkExt_EXPORT vtkMitkOpenGLGPUVolumeRayCastMapper : public vtkMitkGPUVolumeRayCastMapper
00056 {
00057 public:
00058 static vtkMitkOpenGLGPUVolumeRayCastMapper *New();
00059 vtkTypeRevisionMacro(vtkMitkOpenGLGPUVolumeRayCastMapper,vtkMitkGPUVolumeRayCastMapper);
00060 virtual void PrintSelf(ostream& os, vtkIndent indent);
00061
00062
00063
00064
00065
00066
00067 virtual int IsRenderSupported(vtkRenderWindow *window,
00068 vtkVolumeProperty *property);
00069
00070
00071
00072
00073 static const char *OpenGLErrorMessage(unsigned int errorCode);
00074
00075
00076
00077
00078
00079 static void PrintError(const char *headerMessage);
00080
00081
00082
00083 protected:
00084 vtkMitkOpenGLGPUVolumeRayCastMapper();
00085 ~vtkMitkOpenGLGPUVolumeRayCastMapper();
00086
00087
00088 virtual void GPURender(vtkRenderer *ren,
00089 vtkVolume *vol);
00090
00091
00092 virtual void PreRender(vtkRenderer *ren,
00093 vtkVolume *vol,
00094 double datasetBounds[6],
00095 double scalarRange[2],
00096 int numberOfScalarComponents,
00097 unsigned int numberOfLevels);
00098
00099
00100 virtual void RenderBlock(vtkRenderer *ren,
00101 vtkVolume *vol,
00102 unsigned int level);
00103
00104 virtual void PostRender(vtkRenderer *ren,
00105 int numberOfScalarComponents);
00106
00107
00108
00109
00110
00111
00112
00113 int TestRequiredExtension(vtkOpenGLExtensionManager *extensions,
00114 const char *extensionName);
00115
00116
00117
00118
00119
00120
00121
00122 void LoadExtensions(vtkRenderWindow *window);
00123
00124
00125
00126 void CreateGLSLObjects();
00127
00128
00129
00130
00131
00132
00133
00134 void CreateOpenGLObjects();
00135
00136
00137
00138
00139 void ReleaseGraphicsResources(vtkWindow *window);
00140
00141
00142
00143
00144
00145
00146
00147
00148 int AllocateFrameBuffers(vtkRenderer *ren);
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171 int LoadScalarField(vtkImageData *input,
00172 vtkImageData *maskInput,
00173 int textureExtent[6],
00174 vtkVolume *volume);
00175
00176
00177
00178
00179
00180
00181 int UpdateColorTransferFunction(vtkVolume *vol,
00182 int numberOfScalarComponents);
00183
00184
00185
00186
00187
00188 int UpdateOpacityTransferFunction(vtkVolume *vol,
00189 int numberOfScalarComponents,
00190 unsigned int level);
00191
00192
00193
00194
00195
00196 void SetupRender(vtkRenderer *ren, vtkVolume *vol);
00197
00198
00199
00200
00201 void ClipBoundingBox(vtkRenderer *ren,
00202 double worldBounds[6],
00203 vtkVolume *vol);
00204
00205
00206
00207
00208
00209 int RenderClippedBoundingBox(int tcoordFlag,
00210 size_t currentBlock,
00211 size_t numberOfBlocks,
00212 vtkRenderWindow *renWin);
00213
00214
00215
00216
00217 void CopyFBOToTexture();
00218
00219
00220
00221 void CleanupRender();
00222
00223
00224
00225
00226 void RenderTextureToScreen(vtkRenderer *ren);
00227
00228
00229
00230
00231
00232 int PowerOfTwoGreaterOrEqual(int x);
00233
00234
00235
00236 void CheckFrameBufferStatus();
00237
00238
00239
00240 vtkStdString BufferToString(int buffer);
00241
00242
00243
00244 void DisplayReadAndDrawBuffers();
00245
00246
00247
00248 void DisplayFrameBufferAttachments();
00249
00250
00251
00252 void DisplayFrameBufferAttachment(unsigned int uattachment);
00253
00254
00255
00256
00257
00258 void BuildProgram(int parallelProjection,
00259 int raycastMethod,
00260 int shadeMethod,
00261 int componentMethod);
00262
00263
00264
00265 void GetLightingStatus();
00266
00267
00268
00269 void CheckCompilation(unsigned int fragmentShader);
00270
00271
00272
00273 int CheckLinkage(unsigned int programShader);
00274
00275
00276
00277 void PrintUniformVariables(unsigned int programShader);
00278
00279
00280
00281
00282 void ValidateProgram();
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293 void ComputeReductionFactor(double allocatedTime);
00294
00295
00296
00297
00298 void RenderWholeVolume(vtkRenderer *ren,
00299 vtkVolume *vol);
00300
00301
00302
00303
00304 void RenderRegions(vtkRenderer *ren,
00305 vtkVolume *vol);
00306
00307
00308 int RenderSubVolume(vtkRenderer *ren,
00309 double bounds[6],
00310 vtkVolume *vol);
00311
00312 void LoadProjectionParameters(vtkRenderer *ren,
00313 vtkVolume *vol);
00314
00315
00316
00317 void ComputeNumberOfCroppingRegions();
00318
00319 void GetTextureFormat(vtkImageData *input,
00320 unsigned int *internalFormat,
00321 unsigned int *format,
00322 unsigned int *type,
00323 int *componentSize);
00324
00325 bool TestLoadingScalar(unsigned int internalFormat,
00326 unsigned int format,
00327 unsigned int type,
00328 int textureSize[3],
00329 int componentSize);
00330
00331 void SlabsFromDatasetToIndex(double slabsDataSet[6],
00332 double slabsPoints[6]);
00333
00334 void SlabsFromIndexToDataset(double slabsPoints[6],
00335 double slabsDataSet[6]);
00336
00337 const char *GetEnabledString(unsigned char value);
00338 void GetOpenGLState();
00339
00340 void DebugDisplayBox(vtkPolyData *box);
00341
00342 void UpdateNoiseTexture();
00343
00344
00345
00346
00347
00348
00349 double ComputeMinimalSampleDistancePerPixel(vtkRenderer *renderer,
00350 vtkVolume *volume);
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363 virtual void GetReductionRatio(double ratio[3]);
00364
00365 int NumberOfCroppingRegions;
00366
00367
00368 double BoundingBox[8][3];
00369
00370
00371 vtkPolyData *PolyDataBoundingBox;
00372 vtkPlaneCollection *Planes;
00373 vtkPlane *NearPlane;
00374
00375 vtkClipConvexPolyData *Clip;
00376 vtkMatrix4x4 *InvVolumeMatrix;
00377
00378 vtkDensifyPolyData *Densify;
00379
00380 int OpenGLObjectsCreated;
00381 int NumberOfFrameBuffers;
00382
00383 unsigned int FrameBufferObject;
00384 unsigned int DepthRenderBufferObject;
00385
00386
00387
00388 unsigned int TextureObjects[5];
00389 unsigned int FragmentMainShader;
00390 unsigned int FragmentProjectionShader;
00391 unsigned int FragmentTraceShader;
00392 unsigned int FragmentCroppingShader;
00393 unsigned int FragmentComponentShader;
00394 unsigned int FragmentShadeShader;
00395 unsigned int ProgramShader;
00396
00397 unsigned int MaxValueFrameBuffer;
00398 unsigned int MaxValueFrameBuffer2;
00399 int ReducedSize[2];
00400
00401 vtkPolyData *ClippedBoundingBox;
00402
00403 int LastSize[2];
00404
00405 double ReductionFactor;
00406
00407
00408
00409 vtkUnsupportedRequiredExtensionsStringStream *UnsupportedRequiredExtensions;
00410 int LoadExtensionsSucceeded;
00411
00412 int Supports_GL_ARB_texture_float;
00413 int SupportsPixelBufferObjects;
00414
00415 vtkTimeStamp DataBufferTime;
00416
00417
00418
00419 vtkMatrix4x4 *TempMatrix[3];
00420
00421 double TableRange[2];
00422
00423
00424
00425
00426
00427 int ErrorLine;
00428 int ErrorColumn;
00429 char *ErrorString;
00430
00431
00432
00433 int LastParallelProjection;
00434 int LastRayCastMethod;
00435 int LastCroppingMode;
00436 int LastComponent;
00437 int LastShade;
00438
00439 vtkImageData *SmallInput;
00440 vtkTimeStamp SmallInputBuildTime;
00441
00442
00443
00444
00445 void BuildScaleBiasProgram();
00446
00447 unsigned int ScaleBiasProgramShader;
00448 int UFrameBufferTexture;
00449 int UScale;
00450 int UBias;
00451
00452 #if 0
00453 vtkIdType LoadedExtent[6];
00454 double LoadedBounds[6];
00455 vtkTimeStamp LoadedScalarTime;
00456 int LoadedCellFlag;
00457 #endif
00458
00459 unsigned int SavedFrameBuffer;
00460
00461 vtkTessellatedBoxSource *BoxSource;
00462
00463 float *NoiseTexture;
00464 int NoiseTextureSize;
00465 unsigned int NoiseTextureId;
00466
00467 bool IgnoreSampleDistancePerPixel;
00468
00469 vtkMapDataArrayTextureId *ScalarsTextures;
00470 vtkMapMaskTextureId *MaskTextures;
00471
00472 vtkRGBTable *RGBTable;
00473 vtkRGBTable *Mask1RGBTable;
00474 vtkRGBTable *Mask2RGBTable;
00475
00476 vtkOpacityTables *OpacityTables;
00477
00478 vtkKWScalarField *CurrentScalar;
00479 vtkKWMask *CurrentMask;
00480
00481 float ActualSampleDistance;
00482
00483 double LastProgressEventTime;
00484
00485 bool PreserveOrientation;
00486
00487 private:
00488 vtkMitkOpenGLGPUVolumeRayCastMapper(const vtkMitkOpenGLGPUVolumeRayCastMapper&);
00489 void operator=(const vtkMitkOpenGLGPUVolumeRayCastMapper&);
00490 };
00491
00492 #endif
00493
00494 #endif