VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkSmartVolumeMapper.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00108 #ifndef vtkSmartVolumeMapper_h 00109 #define vtkSmartVolumeMapper_h 00110 00111 #include "vtkRenderingVolumeOpenGLModule.h" // For export macro 00112 #include "vtkVolumeMapper.h" 00113 #include "vtkImageReslice.h" // for VTK_RESLICE_NEAREST, VTK_RESLICE_CUBIC 00114 00115 class vtkFixedPointVolumeRayCastMapper; 00116 class vtkGPUVolumeRayCastMapper; 00117 class vtkImageResample; 00118 class vtkRenderWindow; 00119 class vtkVolume; 00120 class vtkVolumeProperty; 00121 class vtkVolumeTextureMapper3D; 00122 00123 class VTKRENDERINGVOLUMEOPENGL_EXPORT vtkSmartVolumeMapper : public vtkVolumeMapper 00124 { 00125 public: 00126 static vtkSmartVolumeMapper *New(); 00127 vtkTypeMacro(vtkSmartVolumeMapper,vtkVolumeMapper); 00128 void PrintSelf( ostream& os, vtkIndent indent ); 00129 00131 00137 vtkSetMacro( FinalColorWindow, float ); 00139 00141 00142 vtkGetMacro( FinalColorWindow, float ); 00144 00146 00150 vtkSetMacro( FinalColorLevel, float ); 00152 00154 00155 vtkGetMacro( FinalColorLevel, float ); 00157 00158 //BTX 00159 // The possible values for the default and current render mode ivars 00160 enum 00161 { 00162 DefaultRenderMode=0, 00163 RayCastAndTextureRenderMode, 00164 RayCastRenderMode, 00165 TextureRenderMode, 00166 GPURenderMode, 00167 UndefinedRenderMode, 00168 InvalidRenderMode 00169 }; 00170 //ETX 00171 00174 void SetRequestedRenderMode(int mode); 00175 00180 void SetRequestedRenderModeToDefault(); 00181 00187 void SetRequestedRenderModeToRayCastAndTexture(); 00188 00193 void SetRequestedRenderModeToRayCast(); 00194 00196 00197 vtkGetMacro( RequestedRenderMode, int ); 00199 00201 00206 vtkSetClampMacro( InteractiveUpdateRate, double, 1.0e-10, 1.0e10 ); 00208 00210 00212 vtkGetMacro( InteractiveUpdateRate, double ); 00214 00217 int GetLastUsedRenderMode(); 00218 00220 00224 vtkSetMacro( MaxMemoryInBytes, vtkIdType ); 00225 vtkGetMacro( MaxMemoryInBytes, vtkIdType ); 00227 00229 00232 vtkSetClampMacro( MaxMemoryFraction, float, 0.1f, 1.0f ); 00233 vtkGetMacro( MaxMemoryFraction, float ); 00235 00237 00239 vtkSetClampMacro(InterpolationMode, int, 00240 VTK_RESLICE_NEAREST, VTK_RESLICE_CUBIC); 00241 vtkGetMacro(InterpolationMode, int); 00242 void SetInterpolationModeToNearestNeighbor(); 00243 void SetInterpolationModeToLinear(); 00244 void SetInterpolationModeToCubic(); 00246 00248 00251 void CreateCanonicalView( vtkRenderer *ren, 00252 vtkVolume *volume, 00253 vtkVolume *volume2, 00254 vtkImageData *image, 00255 int blend_mode, 00256 double viewDirection[3], 00257 double viewUp[3] ); 00259 00260 00261 //BTX 00264 void Render( vtkRenderer *, vtkVolume * ); 00265 00267 00271 void ReleaseGraphicsResources(vtkWindow *); 00272 //ETX 00274 00275 protected: 00276 vtkSmartVolumeMapper(); 00277 ~vtkSmartVolumeMapper(); 00278 00282 void ConnectMapperInput(vtkVolumeMapper *m); 00283 00287 void ConnectFilterInput(vtkImageResample *f); 00288 00289 // Window / level ivars 00290 float FinalColorWindow; 00291 float FinalColorLevel; 00292 00293 // GPU mapper-specific memory ivars. 00294 vtkIdType MaxMemoryInBytes; 00295 float MaxMemoryFraction; 00296 00297 // Used for downsampling. 00298 int InterpolationMode; 00299 00300 // The requested render mode is used to compute the current render mode. Note 00301 // that the current render mode can be invalid if the requested mode is not 00302 // supported. 00303 int RequestedRenderMode; 00304 int CurrentRenderMode; 00305 00306 // Initialization variables. 00307 int Initialized; 00308 vtkTimeStamp SupportStatusCheckTime; 00309 int TextureSupported; 00310 int GPUSupported; 00311 int RayCastSupported; 00312 int LowResGPUNecessary; 00313 00314 // This is the resample filter that may be used if we need to 00315 // create a low resolution version of the volume for GPU rendering 00316 vtkImageResample *GPUResampleFilter; 00317 00318 // If the DesiredUpdateRate of the vtkRenderWindow causing the Render is at 00319 // or above this value, the render is considered interactive. Otherwise it is 00320 // considered still. 00321 double InteractiveUpdateRate; 00322 00323 // The initialize method. Called from ComputeRenderMode whenever something 00324 // relevant has changed. 00325 void Initialize(vtkRenderer *ren, 00326 vtkVolume *vol); 00327 00328 // The method that computes the render mode from the requested render mode 00329 // based on the support status for each render method. 00330 void ComputeRenderMode(vtkRenderer *ren, 00331 vtkVolume *vol); 00332 00333 // The three potential mappers 00334 vtkGPUVolumeRayCastMapper *GPULowResMapper; 00335 vtkGPUVolumeRayCastMapper *GPUMapper; 00336 vtkFixedPointVolumeRayCastMapper *RayCastMapper; 00337 vtkVolumeTextureMapper3D *TextureMapper; 00338 00339 00340 // We need to keep track of the blend mode we had when we initialized 00341 // because we need to reinitialize (and recheck hardware support) if 00342 // it changes 00343 int InitializedBlendMode; 00344 00345 private: 00346 vtkSmartVolumeMapper(const vtkSmartVolumeMapper&); // Not implemented. 00347 void operator=(const vtkSmartVolumeMapper&); // Not implemented. 00348 }; 00349 00350 #endif