VTK
/Users/kitware/Dashboards/MyTests/VTK_BLD_Release_docs/Utilities/Doxygen/dox/Rendering/VolumeOpenGL2/vtkSmartVolumeMapper.h
Go to the documentation of this file.
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 =========================================================================*/
00072 #ifndef vtkSmartVolumeMapper_h
00073 #define vtkSmartVolumeMapper_h
00074 
00075 #include "vtkRenderingVolumeOpenGL2Module.h" // For export macro
00076 #include "vtkVolumeMapper.h"
00077 #include "vtkImageReslice.h" // for VTK_RESLICE_NEAREST, VTK_RESLICE_CUBIC
00078 
00079 class vtkFixedPointVolumeRayCastMapper;
00080 class vtkGPUVolumeRayCastMapper;
00081 class vtkImageResample;
00082 class vtkRenderWindow;
00083 class vtkVolume;
00084 class vtkVolumeProperty;
00085 
00086 class VTKRENDERINGVOLUMEOPENGL2_EXPORT vtkSmartVolumeMapper : public vtkVolumeMapper
00087 {
00088 public:
00089   static vtkSmartVolumeMapper *New();
00090   vtkTypeMacro(vtkSmartVolumeMapper,vtkVolumeMapper);
00091   void PrintSelf( ostream& os, vtkIndent indent );
00092 
00094 
00100   vtkSetMacro( FinalColorWindow, float );
00102 
00104 
00105   vtkGetMacro( FinalColorWindow, float );
00107 
00109 
00113   vtkSetMacro( FinalColorLevel,  float );
00115 
00117 
00118   vtkGetMacro( FinalColorLevel,  float );
00120 
00121 //BTX
00122 // The possible values for the default and current render mode ivars
00123   enum
00124   {
00125     DefaultRenderMode=0,
00126     RayCastAndTextureRenderMode,
00127     RayCastRenderMode,
00128     TextureRenderMode,
00129     GPURenderMode,
00130     UndefinedRenderMode,
00131     InvalidRenderMode
00132   };
00133 //ETX
00134 
00137   void SetRequestedRenderMode(int mode);
00138 
00143   void SetRequestedRenderModeToDefault();
00144 
00149   void SetRequestedRenderModeToRayCast();
00150 
00152 
00153   vtkGetMacro( RequestedRenderMode, int );
00155 
00157 
00162   vtkSetClampMacro( InteractiveUpdateRate, double, 1.0e-10, 1.0e10 );
00164 
00166 
00168   vtkGetMacro( InteractiveUpdateRate, double );
00170 
00173   int GetLastUsedRenderMode();
00174 
00176 
00180   vtkSetMacro( MaxMemoryInBytes, vtkIdType );
00181   vtkGetMacro( MaxMemoryInBytes, vtkIdType );
00183 
00185 
00188   vtkSetClampMacro( MaxMemoryFraction, float, 0.1f, 1.0f );
00189   vtkGetMacro( MaxMemoryFraction, float );
00191 
00193 
00195   vtkSetClampMacro(InterpolationMode, int,
00196                    VTK_RESLICE_NEAREST, VTK_RESLICE_CUBIC);
00197   vtkGetMacro(InterpolationMode, int);
00198   void SetInterpolationModeToNearestNeighbor();
00199   void SetInterpolationModeToLinear();
00200   void SetInterpolationModeToCubic();
00202 
00204 
00207   void CreateCanonicalView( vtkRenderer *ren,
00208                             vtkVolume *volume,
00209                             vtkVolume *volume2,
00210                             vtkImageData *image,
00211                             int blend_mode,
00212                             double viewDirection[3],
00213                             double viewUp[3] );
00215 
00216 
00217 //BTX
00220   void Render( vtkRenderer *, vtkVolume * );
00221 
00223 
00227   void ReleaseGraphicsResources(vtkWindow *);
00228 //ETX
00230 
00231 protected:
00232   vtkSmartVolumeMapper();
00233   ~vtkSmartVolumeMapper();
00234 
00238   void ConnectMapperInput(vtkVolumeMapper *m);
00239 
00243   void ConnectFilterInput(vtkImageResample *f);
00244 
00245   // Window / level ivars
00246   float   FinalColorWindow;
00247   float   FinalColorLevel;
00248 
00249   // GPU mapper-specific memory ivars.
00250   vtkIdType MaxMemoryInBytes;
00251   float MaxMemoryFraction;
00252 
00253   // Used for downsampling.
00254   int InterpolationMode;
00255 
00256   // The requested render mode is used to compute the current render mode. Note
00257   // that the current render mode can be invalid if the requested mode is not
00258   // supported.
00259   int     RequestedRenderMode;
00260   int     CurrentRenderMode;
00261 
00262   // Initialization variables.
00263   int          Initialized;
00264   vtkTimeStamp SupportStatusCheckTime;
00265   int          GPUSupported;
00266   int          RayCastSupported;
00267   int          LowResGPUNecessary;
00268 
00269   // This is the resample filter that may be used if we need to
00270   // create a low resolution version of the volume for GPU rendering
00271   vtkImageResample *GPUResampleFilter;
00272 
00273   // If the DesiredUpdateRate of the vtkRenderWindow causing the Render is at
00274   // or above this value, the render is considered interactive. Otherwise it is
00275   // considered still.
00276   double InteractiveUpdateRate;
00277 
00278   // The initialize method. Called from ComputeRenderMode whenever something
00279   // relevant has changed.
00280   void  Initialize(vtkRenderer *ren,
00281                    vtkVolume *vol);
00282 
00283   // The method that computes the render mode from the requested render mode
00284   // based on the support status for each render method.
00285   void  ComputeRenderMode(vtkRenderer *ren,
00286                           vtkVolume *vol);
00287 
00288   // The three potential mappers
00289   vtkGPUVolumeRayCastMapper      *GPULowResMapper;
00290   vtkGPUVolumeRayCastMapper      *GPUMapper;
00291   vtkFixedPointVolumeRayCastMapper  *RayCastMapper;
00292 
00293 
00294   // We need to keep track of the blend mode we had when we initialized
00295   // because we need to reinitialize (and recheck hardware support) if
00296   // it changes
00297   int  InitializedBlendMode;
00298 
00299 private:
00300   vtkSmartVolumeMapper(const vtkSmartVolumeMapper&);  // Not implemented.
00301   void operator=(const vtkSmartVolumeMapper&);  // Not implemented.
00302 };
00303 
00304 #endif