00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00029 #ifndef __vtkOpenGLGPUVolumeRayCastMapper_h
00030 #define __vtkOpenGLGPUVolumeRayCastMapper_h
00031
00032 #include "vtkGPUVolumeRayCastMapper.h"
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 VTK_VOLUMERENDERING_EXPORT vtkOpenGLGPUVolumeRayCastMapper : public vtkGPUVolumeRayCastMapper
00056 {
00057 public:
00058 static vtkOpenGLGPUVolumeRayCastMapper *New();
00059 vtkTypeMacro(vtkOpenGLGPUVolumeRayCastMapper,vtkGPUVolumeRayCastMapper);
00060 virtual void PrintSelf(ostream& os, vtkIndent indent);
00061
00063
00067 virtual int IsRenderSupported(vtkRenderWindow *window,
00068 vtkVolumeProperty *property);
00070
00073 static const char *OpenGLErrorMessage(unsigned int errorCode);
00074
00077 static void PrintError(const char *headerMessage);
00078
00079
00080
00081 protected:
00082 vtkOpenGLGPUVolumeRayCastMapper();
00083 ~vtkOpenGLGPUVolumeRayCastMapper();
00084
00085
00086 virtual void GPURender(vtkRenderer *ren,
00087 vtkVolume *vol);
00088
00089
00090 virtual void PreRender(vtkRenderer *ren,
00091 vtkVolume *vol,
00092 double datasetBounds[6],
00093 double scalarRange[2],
00094 int numberOfScalarComponents,
00095 unsigned int numberOfLevels);
00096
00097
00098 virtual void RenderBlock(vtkRenderer *ren,
00099 vtkVolume *vol,
00100 unsigned int level);
00101
00102 virtual void PostRender(vtkRenderer *ren,
00103 int numberOfScalarComponents);
00104
00106
00110 int TestRequiredExtension(vtkOpenGLExtensionManager *extensions,
00111 const char *extensionName);
00113
00119 void LoadExtensions(vtkRenderWindow *window);
00120
00122 void CreateGLSLObjects();
00123
00129 void CreateOpenGLObjects();
00130
00132 void ReleaseGraphicsResources(vtkWindow *window);
00133
00139 int AllocateFrameBuffers(vtkRenderer *ren);
00140
00142
00159 int LoadScalarField(vtkImageData *input,
00160 vtkImageData *maskInput,
00161 int textureExtent[6],
00162 vtkVolume *volume);
00164
00166
00170 int UpdateColorTransferFunction(vtkVolume *vol,
00171 int numberOfScalarComponents);
00172
00173
00174
00175
00176
00177 int UpdateOpacityTransferFunction(vtkVolume *vol,
00178 int numberOfScalarComponents,
00179 unsigned int level);
00181
00184 void SetupRender(vtkRenderer *ren, vtkVolume *vol);
00185
00187
00189 void ClipBoundingBox(vtkRenderer *ren,
00190 double worldBounds[6],
00191 vtkVolume *vol);
00193
00195
00198 int RenderClippedBoundingBox(int tcoordFlag,
00199 size_t currentBlock,
00200 size_t numberOfBlocks,
00201 vtkRenderWindow *renWin);
00203
00206 void CopyFBOToTexture();
00207
00209 void CleanupRender();
00210
00212 void RenderTextureToScreen(vtkRenderer *ren);
00213
00216 int PowerOfTwoGreaterOrEqual(int x);
00217
00219 void CheckFrameBufferStatus();
00220
00223 vtkStdString BufferToString(int buffer);
00224
00226 void DisplayReadAndDrawBuffers();
00227
00229 void DisplayFrameBufferAttachments();
00230
00232 void DisplayFrameBufferAttachment(unsigned int uattachment);
00233
00235
00241 void BuildProgram(int parallelProjection,
00242 int raycastMethod,
00243 int shadeMethod,
00244 int componentMethod);
00246
00248 void GetLightingStatus();
00249
00251 void CheckCompilation(unsigned int fragmentShader);
00252
00254 int CheckLinkage(unsigned int programShader);
00255
00257 void PrintUniformVariables(unsigned int programShader);
00258
00261 void ValidateProgram();
00262
00272 void ComputeReductionFactor(double allocatedTime);
00273
00275
00276 void RenderWholeVolume(vtkRenderer *ren,
00277 vtkVolume *vol);
00279
00281
00282 void RenderRegions(vtkRenderer *ren,
00283 vtkVolume *vol);
00285
00286
00287 int RenderSubVolume(vtkRenderer *ren,
00288 double bounds[6],
00289 vtkVolume *vol);
00290
00291 void LoadProjectionParameters(vtkRenderer *ren,
00292 vtkVolume *vol);
00293
00295 void ComputeNumberOfCroppingRegions();
00296
00297 void GetTextureFormat(vtkImageData *input,
00298 unsigned int *internalFormat,
00299 unsigned int *format,
00300 unsigned int *type,
00301 int *componentSize);
00302
00303 bool TestLoadingScalar(unsigned int internalFormat,
00304 unsigned int format,
00305 unsigned int type,
00306 int textureSize[3],
00307 int componentSize);
00308
00309 void SlabsFromDatasetToIndex(double slabsDataSet[6],
00310 double slabsPoints[6]);
00311
00312 void SlabsFromIndexToDataset(double slabsPoints[6],
00313 double slabsDataSet[6]);
00314
00315 const char *GetEnabledString(unsigned char value);
00316 void GetOpenGLState();
00317
00318 void DebugDisplayBox(vtkPolyData *box);
00319
00320 void UpdateNoiseTexture();
00321
00323
00327 double ComputeMinimalSampleDistancePerPixel(vtkRenderer *renderer,
00328 vtkVolume *volume);
00330
00339 virtual void GetReductionRatio(double ratio[3]);
00340
00341 int NumberOfCroppingRegions;
00342
00343
00344 double BoundingBox[8][3];
00345
00346
00347 vtkPolyData *PolyDataBoundingBox;
00348 vtkPlaneCollection *Planes;
00349 vtkPlane *NearPlane;
00350
00351 vtkClipConvexPolyData *Clip;
00352 vtkMatrix4x4 *InvVolumeMatrix;
00353
00354 vtkDensifyPolyData *Densify;
00355
00356 int OpenGLObjectsCreated;
00357 int NumberOfFrameBuffers;
00358
00359 unsigned int FrameBufferObject;
00360 unsigned int DepthRenderBufferObject;
00361
00362
00363
00364 unsigned int TextureObjects[5];
00365 unsigned int FragmentMainShader;
00366 unsigned int FragmentProjectionShader;
00367 unsigned int FragmentTraceShader;
00368 unsigned int FragmentCroppingShader;
00369 unsigned int FragmentComponentShader;
00370 unsigned int FragmentShadeShader;
00371 unsigned int ProgramShader;
00372
00373 unsigned int MaxValueFrameBuffer;
00374 unsigned int MaxValueFrameBuffer2;
00375 int ReducedSize[2];
00376
00377 vtkPolyData *ClippedBoundingBox;
00378
00379 int LastSize[2];
00380
00381 double ReductionFactor;
00382
00383
00384
00385 vtkUnsupportedRequiredExtensionsStringStream *UnsupportedRequiredExtensions;
00386 int LoadExtensionsSucceeded;
00387
00388 int Supports_GL_ARB_texture_float;
00389 int SupportsPixelBufferObjects;
00390
00391 vtkTimeStamp DataBufferTime;
00392
00393
00394
00395 vtkMatrix4x4 *TempMatrix[3];
00396
00397 double TableRange[2];
00398
00399
00400
00401
00402
00403 int ErrorLine;
00404 int ErrorColumn;
00405 char *ErrorString;
00406
00407
00408
00409 int LastParallelProjection;
00410 int LastRayCastMethod;
00411 int LastCroppingMode;
00412 int LastComponent;
00413 int LastShade;
00414
00415 vtkImageData *SmallInput;
00416 vtkTimeStamp SmallInputBuildTime;
00417
00420 void BuildScaleBiasProgram();
00421
00422 unsigned int ScaleBiasProgramShader;
00423 int UFrameBufferTexture;
00424 int UScale;
00425 int UBias;
00426
00427 #if 0
00428 vtkIdType LoadedExtent[6];
00429 double LoadedBounds[6];
00430 vtkTimeStamp LoadedScalarTime;
00431 int LoadedCellFlag;
00432 #endif
00433
00434 unsigned int SavedFrameBuffer;
00435
00436 vtkTessellatedBoxSource *BoxSource;
00437
00438 float *NoiseTexture;
00439 int NoiseTextureSize;
00440 unsigned int NoiseTextureId;
00441
00442 bool IgnoreSampleDistancePerPixel;
00443
00444 vtkMapDataArrayTextureId *ScalarsTextures;
00445 vtkMapMaskTextureId *MaskTextures;
00446
00447 vtkRGBTable *RGBTable;
00448 vtkRGBTable *Mask1RGBTable;
00449 vtkRGBTable *Mask2RGBTable;
00450
00451 vtkOpacityTables *OpacityTables;
00452
00453 vtkKWScalarField *CurrentScalar;
00454 vtkKWMask *CurrentMask;
00455
00456 float ActualSampleDistance;
00457
00458 double LastProgressEventTime;
00459
00460 bool PreserveOrientation;
00461
00462 private:
00463 vtkOpenGLGPUVolumeRayCastMapper(const vtkOpenGLGPUVolumeRayCastMapper&);
00464 void operator=(const vtkOpenGLGPUVolumeRayCastMapper&);
00465 };
00466
00467 #endif