VTK
dox/VolumeRendering/vtkEncodedGradientShader.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkEncodedGradientShader.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 =========================================================================*/
00015 
00032 #ifndef __vtkEncodedGradientShader_h
00033 #define __vtkEncodedGradientShader_h
00034 
00035 #include "vtkObject.h"
00036 
00037 class vtkVolume;
00038 class vtkRenderer;
00039 class vtkEncodedGradientEstimator;
00040 
00041 #define VTK_MAX_SHADING_TABLES   100
00042 
00043 class VTK_VOLUMERENDERING_EXPORT vtkEncodedGradientShader : public vtkObject
00044 {
00045 public:
00046   static vtkEncodedGradientShader *New();
00047   vtkTypeMacro(vtkEncodedGradientShader,vtkObject);
00048 
00050   void PrintSelf( ostream& os, vtkIndent indent );
00051 
00053 
00055   vtkSetClampMacro( ZeroNormalDiffuseIntensity,  float, 0.0f, 1.0f);
00056   vtkGetMacro( ZeroNormalDiffuseIntensity, float );
00057   vtkSetClampMacro( ZeroNormalSpecularIntensity, float, 0.0f, 1.0f);
00058   vtkGetMacro( ZeroNormalSpecularIntensity, float );
00060 
00062 
00063   void UpdateShadingTable( vtkRenderer *ren, vtkVolume *vol,
00064                            vtkEncodedGradientEstimator *gradest);
00066 
00068 
00069   float *GetRedDiffuseShadingTable(    vtkVolume *vol );
00070   float *GetGreenDiffuseShadingTable(  vtkVolume *vol );
00071   float *GetBlueDiffuseShadingTable(   vtkVolume *vol );
00072   float *GetRedSpecularShadingTable(   vtkVolume *vol );
00073   float *GetGreenSpecularShadingTable( vtkVolume *vol );
00074   float *GetBlueSpecularShadingTable(  vtkVolume *vol );
00076 
00078 
00081   vtkSetClampMacro( ActiveComponent, int, 0, 3 );
00082   vtkGetMacro( ActiveComponent, int );
00084   
00085 protected:
00086   vtkEncodedGradientShader();
00087   ~vtkEncodedGradientShader();
00088 
00090 
00102   void  BuildShadingTable( int index,
00103                            double lightDirection[3],
00104                            double lightAmbientColor[3],
00105                            double lightDiffuseColor[3],
00106                            double lightSpecularColor[3],
00107                            double lightIntensity,
00108                            double viewDirection[3],
00109                            double material[4],
00110                            int twoSided,
00111                            vtkEncodedGradientEstimator *gradest,
00112                            int updateFlag );
00114   
00115   // The six shading tables (r diffuse ,g diffuse ,b diffuse, 
00116   // r specular, g specular, b specular ) - with an entry for each
00117   // encoded normal plus one entry at the end for the zero normal
00118   // There is one shading table per volume listed in the ShadingTableVolume
00119   // array. A null entry indicates an available slot.
00120   float                        *ShadingTable[VTK_MAX_SHADING_TABLES][6];
00121   vtkVolume                    *ShadingTableVolume[VTK_MAX_SHADING_TABLES];
00122   int                          ShadingTableSize[VTK_MAX_SHADING_TABLES];
00123 
00124   int                          ActiveComponent;
00125   
00126   // The intensity of light used for the zero normals, since it
00127   // can not be computed from the normal angles. Defaults to 0.0.
00128   float    ZeroNormalDiffuseIntensity;
00129   float    ZeroNormalSpecularIntensity;
00130 private:
00131   vtkEncodedGradientShader(const vtkEncodedGradientShader&);  // Not implemented.
00132   void operator=(const vtkEncodedGradientShader&);  // Not implemented.
00133 }; 
00134 
00135 
00136 #endif