vtkSlicerGPUMultiVolumeMapper.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkSlicerGPUMultiVolumeMapper.h,v $
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 =========================================================================*/
00015 // .NAME vtkSlicerGPUMultiVolumeMapper - GPU volume render with 3D texture mapping (GLSL)
00016 
00017 // .SECTION Description
00018 // vtkSlicerGPUMultiVolumeMapper renders two volume using 3D texture mapping in fragment shader. 
00019 // This class is actually an abstract superclass - with all the actual
00020 // work done by vtkSlicerGPURayCastVolumeMapper. 
00021 // 
00022 // This mappers currently supports:
00023 //
00024 // - any data type as input
00025 // - one component
00026 // - composite blending
00027 // - mip and minip
00028 // - two input volumes
00029 //
00030 // This mapper does not support:
00031 // - more than one component
00032 // 
00033 // Two input volumes must have same dimension, spacing and number of components
00034 //
00035 // .SECTION see also
00036 // vtkVolumeMapper
00037 
00038 #ifndef __vtkSlicerGPUMultiVolumeMapper_h
00039 #define __vtkSlicerGPUMultiVolumeMapper_h
00040 
00041 #include "vtkVolumeMapper.h"
00042 #include "vtkVolumeRenderingReplacements.h"
00043 
00044 class vtkMultiThreader;
00045 class vtkImageData;
00046 class vtkColorTransferFunction;
00047 class vtkPiecewiseFunction;
00048 class vtkVolumeProperty;
00049 
00050 class vtkSlicerGPUMultiVolumeMapper;
00051 typedef struct{
00052     float *dataPtr;
00053     vtkSlicerGPUMultiVolumeMapper *me;
00054     double scalarRange[2];
00055     unsigned char *volume;
00056 }GPUGradientsArgsType;
00057 
00058 class VTK_VOLUMERENDERINGREPLACEMENTS_EXPORT vtkSlicerGPUMultiVolumeMapper : public vtkVolumeMapper
00059 {
00060 public:
00061   vtkTypeRevisionMacro(vtkSlicerGPUMultiVolumeMapper,vtkVolumeMapper);
00062   void PrintSelf(ostream& os, vtkIndent indent);
00063 
00064   static vtkSlicerGPUMultiVolumeMapper *New();
00065 
00066   // Description:
00067   // Desired frame rate
00068   vtkSetMacro(Framerate, float);
00069   vtkGetMacro(Framerate, float);
00070   
00071   // Description:
00072   // Set/Get the nth input data, could be label map or just another volume
00073   virtual void SetNthInput( int index, vtkImageData *);
00074   virtual void SetNthInput( int index, vtkDataSet *);
00075   vtkImageData *GetNthInput(int index);
00076   
00077   // Description:
00078   // These are the dimensions of the 3D texture
00079   vtkGetVectorMacro( VolumeDimensions, int,   3 );
00080   
00081   // Description:
00082   // This is the spacing of the 3D texture
00083   vtkGetVectorMacro( VolumeSpacing,    float, 3 );
00084 
00085   // Description:
00086   // Based on hardware and properties, we may or may not be able to
00087   // render using 3D texture mapping. This indicates if 3D texture
00088   // mapping is supported by the hardware, and if the other extensions
00089   // necessary to support the specific properties are available.
00090   virtual int IsRenderSupported( vtkVolumeProperty * ) {return 0;};
00091 
00092 //BTX
00093 
00094   // Description:
00095   // WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE
00096   // DO NOT USE THIS METHOD OUTSIDE OF THE RENDERING PROCESS
00097   // Render the volume
00098   virtual void Render(vtkRenderer *, vtkVolume *) {};   
00099 
00100 protected:
00101   vtkSlicerGPUMultiVolumeMapper();
00102   ~vtkSlicerGPUMultiVolumeMapper();
00103 
00104   float                     ScalarOffset;
00105   float                     ScalarScale;
00106   
00107   float                     ScalarOffset2nd;
00108   float                     ScalarScale2nd;
00109   
00110   float                     Framerate;
00111   
00112   unsigned char            *Volume1;
00113   unsigned char            *Volume2;
00114   unsigned char            *Volume3;
00115   int                       VolumeSize;
00116   int                       VolumeDimensions[3];
00117   float                     VolumeSpacing[3];
00118   
00119   vtkImageData             *SavedTextureInput;
00120   vtkImageData             *SavedTextureInput2nd;
00121   
00122   vtkColorTransferFunction *SavedRGBFunction;
00123   vtkPiecewiseFunction     *SavedGrayFunction;
00124   vtkPiecewiseFunction     *SavedScalarOpacityFunction;
00125   vtkPiecewiseFunction     *SavedGradientOpacityFunction;
00126   int                       SavedColorChannels;
00127   float                     SavedScalarOpacityDistance;
00128   
00129   vtkColorTransferFunction *SavedRGBFunction2nd;
00130   vtkPiecewiseFunction     *SavedGrayFunction2nd;
00131   vtkPiecewiseFunction     *SavedScalarOpacityFunction2nd;
00132   vtkPiecewiseFunction     *SavedGradientOpacityFunction2nd;
00133   int                       SavedColorChannels2nd;
00134   float                     SavedScalarOpacityDistance2nd;
00135   
00136   unsigned char             ColorLookup[256*256*4];
00137   float                     TempArray1[3*4096];
00138   float                     TempArray2[4096];
00139   int                       ColorTableSize;
00140   
00141   unsigned char             ColorLookup2nd[256*256*4];
00142   float                     TempArray11[3*4096];
00143   float                     TempArray21[4096];
00144   int                       ColorTableSize2nd;
00145   
00146   vtkTimeStamp              SavedTextureMTime;
00147   vtkTimeStamp              SavedTextureMTime2nd;
00148   
00149   vtkTimeStamp              SavedColorOpacityMTime;
00150   vtkTimeStamp              SavedColorOpacityMTime2nd;
00151   
00152   vtkMultiThreader          *Threader;
00153   
00154   GPUGradientsArgsType         *GradientsArgs;
00155 
00156   // Description:
00157   // Update the internal RGBA representation of the volume. Return 1 if
00158   // anything change, 0 if nothing changed.
00159   
00160   int    UpdateVolumes( vtkVolume * );
00161   int    UpdateColorLookup( vtkVolume * );
00162   
00163   void   CopyToFloatBuffer(vtkImageData* input, float* floatDataPtr, int dataPtrSize);
00164 
00165   // Description:
00166   // Impemented in subclass - check is texture size is OK.
00167   //BTX
00168   virtual int IsTextureSizeSupported( int [3] ) {return 0;};
00169   //ETX
00170   
00171   friend VTK_THREAD_RETURN_TYPE vtkSlicerGPUMultiVolumeMapperComputeGradients( void *arg );
00172   
00173 private:
00174   vtkSlicerGPUMultiVolumeMapper(const vtkSlicerGPUMultiVolumeMapper&);  // Not implemented.
00175   void operator=(const vtkSlicerGPUMultiVolumeMapper&);  // Not implemented.
00176 };
00177 
00178 
00179 #endif
00180 
00181 
00182 
00183 
00184 
00185 

Generated on 6 Apr 2011 for Slicer3 by  doxygen 1.6.1