VTK
dox/VolumeRendering/vtkVolumeTextureMapper3D.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkVolumeTextureMapper3D.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 =========================================================================*/
00081 #ifndef __vtkVolumeTextureMapper3D_h
00082 #define __vtkVolumeTextureMapper3D_h
00083 
00084 #include "vtkVolumeMapper.h"
00085 
00086 class vtkImageData;
00087 class vtkColorTransferFunction;
00088 class vtkPiecewiseFunction;
00089 class vtkVolumeProperty;
00090 
00091 class VTK_VOLUMERENDERING_EXPORT vtkVolumeTextureMapper3D : public vtkVolumeMapper
00092 {
00093 public:
00094   vtkTypeMacro(vtkVolumeTextureMapper3D,vtkVolumeMapper);
00095   void PrintSelf(ostream& os, vtkIndent indent);
00096 
00097   static vtkVolumeTextureMapper3D *New();
00098 
00100 
00103   vtkSetMacro( SampleDistance, float );
00104   vtkGetMacro( SampleDistance, float );
00106 
00108 
00109   vtkGetVectorMacro( VolumeDimensions, int,   3 );
00111   
00113 
00114   vtkGetVectorMacro( VolumeSpacing,    float, 3 );
00116 
00118 
00122   virtual int IsRenderSupported( vtkVolumeProperty *,
00123                                  vtkRenderer *vtkNotUsed(r))
00124     {return 0;}
00126 
00128 
00129   vtkGetMacro( NumberOfPolygons, int );
00131   
00133 
00134   vtkGetMacro( ActualSampleDistance, float );
00136 
00137 //BTX
00138 
00141   virtual void Render(vtkRenderer *, vtkVolume *) {};  
00142   
00144 
00145   enum 
00146   {
00147     FRAGMENT_PROGRAM_METHOD=0,
00148     NVIDIA_METHOD=1,
00149     ATI_METHOD=2,
00150     NO_METHOD=3
00151   }; 
00153 //ETX
00154 
00156 
00158   vtkSetClampMacro( PreferredRenderMethod, int, 
00159                     vtkVolumeTextureMapper3D::FRAGMENT_PROGRAM_METHOD,
00160                     vtkVolumeTextureMapper3D::NVIDIA_METHOD );
00161   void SetPreferredMethodToFragmentProgram()
00162     { this->SetPreferredRenderMethod( vtkVolumeTextureMapper3D::FRAGMENT_PROGRAM_METHOD ); }
00163   void SetPreferredMethodToNVidia() 
00164     { this->SetPreferredRenderMethod( vtkVolumeTextureMapper3D::NVIDIA_METHOD ); }
00165   vtkGetMacro(PreferredRenderMethod, int);
00167 
00168   
00170 
00175   vtkSetMacro(UseCompressedTexture,bool);
00176   vtkGetMacro(UseCompressedTexture,bool);
00178   
00179 protected:
00180   vtkVolumeTextureMapper3D();
00181   ~vtkVolumeTextureMapper3D();
00182 
00183   float                    *PolygonBuffer;
00184   float                    *IntersectionBuffer;
00185   int                       NumberOfPolygons;
00186   int                       BufferSize;
00187   
00188   unsigned char            *Volume1;
00189   unsigned char            *Volume2;
00190   unsigned char            *Volume3;
00191   int                       VolumeSize;
00192   int                       VolumeComponents;
00193   int                       VolumeDimensions[3];
00194   float                     VolumeSpacing[3];
00195   
00196   float                     SampleDistance;
00197   float                     ActualSampleDistance;
00198   
00199   vtkImageData             *SavedTextureInput;
00200   vtkImageData             *SavedParametersInput;
00201   
00202   vtkColorTransferFunction *SavedRGBFunction;
00203   vtkPiecewiseFunction     *SavedGrayFunction;
00204   vtkPiecewiseFunction     *SavedScalarOpacityFunction;
00205   vtkPiecewiseFunction     *SavedGradientOpacityFunction;
00206   int                       SavedColorChannels;
00207   float                     SavedSampleDistance;
00208   float                     SavedScalarOpacityDistance;
00209   
00210   unsigned char             ColorLookup[65536*4];
00211   unsigned char             AlphaLookup[65536];
00212   float                     TempArray1[3*4096];
00213   float                     TempArray2[4096];
00214   int                       ColorTableSize;
00215   float                     ColorTableScale;
00216   float                     ColorTableOffset; 
00217 
00218   unsigned char             DiffuseLookup[65536*4];
00219   unsigned char             SpecularLookup[65536*4];
00220   
00221   vtkTimeStamp              SavedTextureMTime;
00222   vtkTimeStamp              SavedParametersMTime;
00223 
00224   int                       RenderMethod;
00225   int                       PreferredRenderMethod;
00226   bool                      UseCompressedTexture;
00227   
00228   bool                      SupportsNonPowerOfTwoTextures;
00229   
00231   void   ComputePolygons( vtkRenderer *ren, vtkVolume *vol, double bounds[6] );
00232 
00234 
00236   int    UpdateVolumes( vtkVolume * );
00237   int    UpdateColorLookup( vtkVolume * );
00239 
00241 
00242   virtual int IsTextureSizeSupported(int vtkNotUsed(size)[3],
00243                                      int vtkNotUsed(components))
00244     {
00245       return 0;
00246     }
00247   //ETX
00249   
00250 private:
00251   vtkVolumeTextureMapper3D(const vtkVolumeTextureMapper3D&);  // Not implemented.
00252   void operator=(const vtkVolumeTextureMapper3D&);  // Not implemented.
00253 };
00254 
00255 
00256 #endif
00257 
00258 
00259 
00260 
00261 
00262