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 vtkShaderProgram2;
00056 class vtkShader2;
00057
00058 class VTK_VOLUMERENDERING_EXPORT vtkOpenGLGPUVolumeRayCastMapper : public vtkGPUVolumeRayCastMapper
00059 {
00060 public:
00061 static vtkOpenGLGPUVolumeRayCastMapper *New();
00062 vtkTypeMacro(vtkOpenGLGPUVolumeRayCastMapper,vtkGPUVolumeRayCastMapper);
00063 virtual void PrintSelf(ostream& os, vtkIndent indent);
00064
00066
00070 virtual int IsRenderSupported(vtkRenderWindow *window,
00071 vtkVolumeProperty *property);
00073
00075 virtual void ReleaseGraphicsResources(vtkWindow *window);
00076
00079 static const char *OpenGLErrorMessage(unsigned int errorCode);
00080
00083 static void PrintError(const char *headerMessage);
00084
00085 protected:
00086 vtkOpenGLGPUVolumeRayCastMapper();
00087 ~vtkOpenGLGPUVolumeRayCastMapper();
00088
00089
00090 virtual void GPURender(vtkRenderer *ren,
00091 vtkVolume *vol);
00092
00093
00094 virtual void PreRender(vtkRenderer *ren,
00095 vtkVolume *vol,
00096 double datasetBounds[6],
00097 double scalarRange[2],
00098 int numberOfScalarComponents,
00099 unsigned int numberOfLevels);
00100
00101
00102 virtual void RenderBlock(vtkRenderer *ren,
00103 vtkVolume *vol,
00104 unsigned int level);
00105
00106 virtual void PostRender(vtkRenderer *ren,
00107 int numberOfScalarComponents);
00108
00110
00114 int TestRequiredExtension(vtkOpenGLExtensionManager *extensions,
00115 const char *extensionName);
00117
00123 void LoadExtensions(vtkRenderWindow *window);
00124
00130 void CreateOpenGLObjects(vtkRenderer *ren);
00131
00137 int AllocateFrameBuffers(vtkRenderer *ren);
00138
00140
00157 int LoadScalarField(vtkImageData *input,
00158 vtkImageData *maskInput,
00159 int textureExtent[6],
00160 vtkVolume *volume);
00162
00164
00168 int UpdateColorTransferFunction(vtkVolume *vol,
00169 int numberOfScalarComponents);
00170
00171
00172
00173
00174
00175 int UpdateOpacityTransferFunction(vtkVolume *vol,
00176 int numberOfScalarComponents,
00177 unsigned int level);
00179
00182 void SetupRender(vtkRenderer *ren, vtkVolume *vol);
00183
00185
00187 void ClipBoundingBox(vtkRenderer *ren,
00188 double worldBounds[6],
00189 vtkVolume *vol);
00191
00193
00196 int RenderClippedBoundingBox(int tcoordFlag,
00197 size_t currentBlock,
00198 size_t numberOfBlocks,
00199 vtkRenderWindow *renWin);
00201
00204 void CopyFBOToTexture();
00205
00207 void CleanupRender();
00208
00210 void RenderTextureToScreen(vtkRenderer *ren);
00211
00214 int PowerOfTwoGreaterOrEqual(int x);
00215
00217 void CheckFrameBufferStatus();
00218
00221 vtkStdString BufferToString(int buffer);
00222
00224 void DisplayReadAndDrawBuffers();
00225
00227 void DisplayFrameBufferAttachments();
00228
00230 void DisplayFrameBufferAttachment(unsigned int uattachment);
00231
00233
00239 void BuildProgram(vtkRenderWindow *w,
00240 int parallelProjection,
00241 int raycastMethod,
00242 int shadeMethod,
00243 int componentMethod);
00245
00247 void GetLightingStatus();
00248
00258 void ComputeReductionFactor(double allocatedTime);
00259
00261
00262 void RenderWholeVolume(vtkRenderer *ren,
00263 vtkVolume *vol);
00265
00267
00268 void RenderRegions(vtkRenderer *ren,
00269 vtkVolume *vol);
00271
00272
00273 int RenderSubVolume(vtkRenderer *ren,
00274 double bounds[6],
00275 vtkVolume *vol);
00276
00277 void LoadProjectionParameters(vtkRenderer *ren,
00278 vtkVolume *vol);
00279
00281 void ComputeNumberOfCroppingRegions();
00282
00283 void GetTextureFormat(vtkImageData *input,
00284 unsigned int *internalFormat,
00285 unsigned int *format,
00286 unsigned int *type,
00287 int *componentSize);
00288
00289 bool TestLoadingScalar(unsigned int internalFormat,
00290 unsigned int format,
00291 unsigned int type,
00292 int textureSize[3],
00293 int componentSize);
00294
00295 void SlabsFromDatasetToIndex(double slabsDataSet[6],
00296 double slabsPoints[6]);
00297
00298 void SlabsFromIndexToDataset(double slabsPoints[6],
00299 double slabsDataSet[6]);
00300
00301 const char *GetEnabledString(unsigned char value);
00302 void GetOpenGLState();
00303
00304 void DebugDisplayBox(vtkPolyData *box);
00305
00306 void UpdateNoiseTexture();
00307
00309
00313 double ComputeMinimalSampleDistancePerPixel(vtkRenderer *renderer,
00314 vtkVolume *volume);
00316
00325 virtual void GetReductionRatio(double ratio[3]);
00326
00327 int NumberOfCroppingRegions;
00328
00329
00330 double BoundingBox[8][3];
00331
00332
00333 vtkPolyData *PolyDataBoundingBox;
00334 vtkPlaneCollection *Planes;
00335 vtkPlane *NearPlane;
00336
00337 vtkClipConvexPolyData *Clip;
00338 vtkMatrix4x4 *InvVolumeMatrix;
00339
00340 vtkDensifyPolyData *Densify;
00341
00342 int OpenGLObjectsCreated;
00343 int NumberOfFrameBuffers;
00344
00345 unsigned int FrameBufferObject;
00346 unsigned int DepthRenderBufferObject;
00347
00348
00349
00350 unsigned int TextureObjects[5];
00351
00352 unsigned int MaxValueFrameBuffer;
00353 unsigned int MaxValueFrameBuffer2;
00354 int ReducedSize[2];
00355
00356 vtkPolyData *ClippedBoundingBox;
00357
00358 int LastSize[2];
00359
00360 double ReductionFactor;
00361
00362
00363
00364 vtkUnsupportedRequiredExtensionsStringStream *UnsupportedRequiredExtensions;
00365 int LoadExtensionsSucceeded;
00366
00367 int Supports_GL_ARB_texture_float;
00368 int SupportsPixelBufferObjects;
00369
00370 vtkTimeStamp DataBufferTime;
00371
00372
00373
00374 vtkMatrix4x4 *TempMatrix[3];
00375
00376 double TableRange[2];
00377
00378
00379
00380
00381
00382 int ErrorLine;
00383 int ErrorColumn;
00384 char *ErrorString;
00385
00386
00387
00388 int LastParallelProjection;
00389 int LastRayCastMethod;
00390 int LastCroppingMode;
00391 int LastComponent;
00392 int LastShade;
00393
00394 vtkImageData *SmallInput;
00395 vtkTimeStamp SmallInputBuildTime;
00396
00399 void BuildScaleBiasProgram(vtkRenderWindow *w);
00400
00401 #if 0
00402 vtkIdType LoadedExtent[6];
00403 double LoadedBounds[6];
00404 vtkTimeStamp LoadedScalarTime;
00405 int LoadedCellFlag;
00406 #endif
00407
00408 unsigned int SavedFrameBuffer;
00409
00410 vtkTessellatedBoxSource *BoxSource;
00411
00412 float *NoiseTexture;
00413 int NoiseTextureSize;
00414 unsigned int NoiseTextureId;
00415
00416 bool IgnoreSampleDistancePerPixel;
00417
00418 vtkMapDataArrayTextureId *ScalarsTextures;
00419 vtkMapMaskTextureId *MaskTextures;
00420
00421 vtkRGBTable *RGBTable;
00422 vtkRGBTable *Mask1RGBTable;
00423 vtkRGBTable *Mask2RGBTable;
00424
00425 vtkOpacityTables *OpacityTables;
00426
00427 vtkKWScalarField *CurrentScalar;
00428 vtkKWMask *CurrentMask;
00429
00430 float ActualSampleDistance;
00431
00432 double LastProgressEventTime;
00433
00434 bool PreserveOrientation;
00435
00436 vtkShaderProgram2 *Program;
00437 vtkShader2 *Main;
00438 vtkShader2 *Projection;
00439 vtkShader2 *Trace;
00440 vtkShader2 *CroppingShader;
00441 vtkShader2 *Component;
00442 vtkShader2 *Shade;
00443
00444
00445
00446 bool SizeChanged;
00447
00448 vtkShaderProgram2 *ScaleBiasProgram;
00449
00450 private:
00451 vtkOpenGLGPUVolumeRayCastMapper(const vtkOpenGLGPUVolumeRayCastMapper&);
00452 void operator=(const vtkOpenGLGPUVolumeRayCastMapper&);
00453 };
00454
00455 #endif