Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members File Members Related Pages

# Rendering/vtkVolumeRayCastMapper.h

Go to the documentation of this file.

    00001 /*=========================================================================
    00002
    00003   Program:   Visualization Toolkit
    00004   Module:    $RCSfile: vtkVolumeRayCastMapper.h,v $
    00005   Language:  C++
    00006
    00007   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen
    00008   All rights reserved.
    00009   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
    00010
    00011      This software is distributed WITHOUT ANY WARRANTY; without even
    00012      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
    00013      PURPOSE.  See the above copyright notice for more information.
    00014
    00015 =========================================================================*/
    00016
    00045 #ifndef __vtkVolumeRayCastMapper_h
    00046 #define __vtkVolumeRayCastMapper_h
    00047
    00048 #include "vtkVolumeMapper.h"
    00049 #include "vtkVolumeRayCastFunction.h" // For vtkVolumeRayCastStaticInfo
    00050                                       // and vtkVolumeRayCastDynamicInfo
    00051 class vtkEncodedGradientEstimator;
    00052 class vtkEncodedGradientShader;
    00053 class vtkMatrix4x4;
    00054 class vtkMultiThreader;
    00055 class vtkPlaneCollection;
    00056 class vtkRenderer;
    00057 class vtkTimerLog;
    00058 class vtkVolume;
    00059 class vtkVolumeRayCastFunction;
    00060 class vtkVolumeTransform;
    00061 class vtkTransform;
    00062
    00063 //BTX
    00064 // Macro for floor of x
    00065 inline int vtkFloorFuncMacro(double x)
    00066 {
    00067 #if defined i386 || defined _M_IX86
    00068   double tempval;
    00069   // use 52-bit precision of IEEE double to round (x - 0.25) to
    00070   // the nearest multiple of 0.5, according to prevailing rounding
    00071   // mode which is IEEE round-to-nearest,even
    00072   tempval = (x - 0.25) + 3377699720527872.0; // (2**51)*1.5
    00073   // extract mantissa, use shift to divide by 2 and hence get rid
    00074   // of the bit that gets messed up because the FPU uses
    00075   // round-to-nearest,even mode instead of round-to-nearest,+infinity
    00076   return ((int*)&tempval)[0] >> 1;
    00077 #else
    00078   // quick-and-dirty, assumes x >= 0
    00079   return (int)(x);
    00080 #endif
    00081 }
    00082
    00083 // Macro for rounding x (for x >= 0)
    00084 inline int vtkRoundFuncMacro(double x)
    00085 {
    00086   return vtkFloorFuncMacro(x + 0.5);
    00087 }
    00088 //ETX
    00089
    00090 // Macro for tri-linear interpolation - do four linear interpolations on
    00091 // edges, two linear interpolations between pairs of edges, then a final
    00092 // interpolation between faces
    00093 #define vtkTrilinFuncMacro(v,x,y,z,a,b,c,d,e,f,g,h)         \
    00094         t00 =   a + (x)*(b-a);      \
    00095         t01 =   c + (x)*(d-c);      \
    00096         t10 =   e + (x)*(f-e);      \
    00097         t11 =   g + (x)*(h-g);      \
    00098         t0  = t00 + (y)*(t01-t00);  \
    00099         t1  = t10 + (y)*(t11-t10);  \
    00100         v   =  t0 + (z)*(t1-t0);
    00101
    00102 class VTK_RENDERING_EXPORT vtkVolumeRayCastMapper : public vtkVolumeMapper
    00103 {
    00104 public:
    00105   static vtkVolumeRayCastMapper *New();
    00106   vtkTypeRevisionMacro(vtkVolumeRayCastMapper,vtkVolumeMapper);
    00107   void PrintSelf( ostream& os, vtkIndent indent );
    00108
    00110
    00113   vtkSetMacro( SampleDistance, float );
    00114   vtkGetMacro( SampleDistance, float );
    00116
    00118
    00120   virtual void SetVolumeRayCastFunction(vtkVolumeRayCastFunction*);
    00121   vtkGetObjectMacro( VolumeRayCastFunction, vtkVolumeRayCastFunction );
    00123
    00125
    00126   virtual void SetGradientEstimator(vtkEncodedGradientEstimator *gradest);
    00127   vtkGetObjectMacro( GradientEstimator, vtkEncodedGradientEstimator );
    00129
    00131
    00132   vtkGetObjectMacro( GradientShader, vtkEncodedGradientShader );
    00134
    00136
    00139   vtkSetClampMacro( ImageSampleDistance, float, 0.1f, 100.0f );
    00140   vtkGetMacro( ImageSampleDistance, float );
    00142
    00144
    00146   vtkSetClampMacro( MinimumImageSampleDistance, float, 0.1f, 100.0f );
    00147   vtkGetMacro( MinimumImageSampleDistance, float );
    00149
    00151
    00153   vtkSetClampMacro( MaximumImageSampleDistance, float, 0.1f, 100.0f );
    00154   vtkGetMacro( MaximumImageSampleDistance, float );
    00156
    00158
    00161   vtkSetClampMacro( AutoAdjustSampleDistances, int, 0, 1 );
    00162   vtkGetMacro( AutoAdjustSampleDistances, int );
    00163   vtkBooleanMacro( AutoAdjustSampleDistances, int );
    00165
    00167
    00169   void SetNumberOfThreads( int num );
    00170   vtkGetMacro( NumberOfThreads, int );
    00172
    00174
    00176   vtkSetClampMacro( IntermixIntersectingGeometry, int, 0, 1 );
    00177   vtkGetMacro( IntermixIntersectingGeometry, int );
    00178   vtkBooleanMacro( IntermixIntersectingGeometry, int );
    00180
    00181 //BTX
    00184   void Render( vtkRenderer *, vtkVolume * );
    00185
    00190   void ReleaseGraphicsResources(vtkWindow *);
    00191
    00194   float GetZeroOpacityThreshold( vtkVolume *vol );
    00195
    00197
    00199   virtual float GetGradientMagnitudeScale();
    00200   virtual float GetGradientMagnitudeBias();
    00201   virtual float GetGradientMagnitudeScale(int)
    00202     {return this->GetGradientMagnitudeScale();};
    00203   virtual float GetGradientMagnitudeBias(int)
    00204     {return this->GetGradientMagnitudeBias();};
    00206
    00207 //ETX
    00208
    00209 protected:
    00210   vtkVolumeRayCastMapper();
    00211   ~vtkVolumeRayCastMapper();
    00212
    00213   vtkVolumeRayCastFunction     *VolumeRayCastFunction;
    00214   vtkEncodedGradientEstimator  *GradientEstimator;
    00215   vtkEncodedGradientShader     *GradientShader;
    00216
    00217   // The distance between sample points along the ray
    00218   float                        SampleDistance;
    00219   float                        ImageSampleDistance;
    00220   float                        MinimumImageSampleDistance;
    00221   float                        MaximumImageSampleDistance;
    00222   int                          AutoAdjustSampleDistances;
    00223
    00224   float                        WorldSampleDistance;
    00225   int                          ScalarDataType;
    00226   void                         *ScalarDataPointer;
    00227
    00228   void                         UpdateShadingTables( vtkRenderer *ren,
    00229                                                     vtkVolume *vol );
    00230
    00231   void ComputeMatrices( vtkImageData *data, vtkVolume *vol );
    00232   virtual void RenderTexture( vtkVolume *vol, vtkRenderer *ren)=0;
    00233   int ComputeRowBounds( vtkVolume *vol, vtkRenderer *ren );
    00234
    00235   friend VTK_THREAD_RETURN_TYPE VolumeRayCastMapper_CastRays( void *arg );
    00236
    00237   vtkMultiThreader  *Threader;
    00238   int               NumberOfThreads;
    00239
    00240   vtkMatrix4x4 *PerspectiveMatrix;
    00241   vtkMatrix4x4 *ViewToWorldMatrix;
    00242   vtkMatrix4x4 *ViewToVoxelsMatrix;
    00243   vtkMatrix4x4 *VoxelsToViewMatrix;
    00244   vtkMatrix4x4 *WorldToVoxelsMatrix;
    00245   vtkMatrix4x4 *VoxelsToWorldMatrix;
    00246
    00247   vtkMatrix4x4 *VolumeMatrix;
    00248
    00249   vtkTransform *PerspectiveTransform;
    00250   vtkTransform *VoxelsTransform;
    00251   vtkTransform *VoxelsToViewTransform;
    00252
    00253   // This is how big the image would be if it covered the entire viewport
    00254   int            ImageViewportSize[2];
    00255
    00256   // This is how big the allocated memory for image is. This may be bigger
    00257   // or smaller than ImageFullSize - it will be bigger if necessary to
    00258   // ensure a power of 2, it will be smaller if the volume only covers a
    00259   // small region of the viewport
    00260   int            ImageMemorySize[2];
    00261
    00262   // This is the size of subregion in ImageSize image that we are using for
    00263   // the current image. Since ImageSize is a power of 2, there is likely
    00264   // wasted space in it. This number will be used for things such as clearing
    00265   // the image if necessary.
    00266   int            ImageInUseSize[2];
    00267
    00268   // This is the location in ImageFullSize image where our ImageSize image
    00269   // is located.
    00270   int            ImageOrigin[2];
    00271
    00272   // This is the allocated image
    00273   unsigned char *Image;
    00274
    00275   int  *RowBounds;
    00276   int  *OldRowBounds;
    00277
    00278   float        *RenderTimeTable;
    00279   vtkVolume   **RenderVolumeTable;
    00280   vtkRenderer **RenderRendererTable;
    00281   int           RenderTableSize;
    00282   int           RenderTableEntries;
    00283
    00284   void StoreRenderTime( vtkRenderer *ren, vtkVolume *vol, float t );
    00285   float RetrieveRenderTime( vtkRenderer *ren, vtkVolume *vol );
    00286
    00287   int           IntermixIntersectingGeometry;
    00288
    00289   float        *ZBuffer;
    00290   int           ZBufferSize[2];
    00291   int           ZBufferOrigin[2];
    00292
    00293   float         MinimumViewDistance;
    00294
    00295   int           ClipRayAgainstVolume( vtkVolumeRayCastDynamicInfo *dynamicInfo,
    00296                                       float bounds[6] );
    00297
    00298   void          InitializeClippingPlanes( vtkVolumeRayCastStaticInfo *staticInfo,
    00299                                           vtkPlaneCollection *planes );
    00300
    00301   int           ClipRayAgainstClippingPlanes( vtkVolumeRayCastDynamicInfo *dynamicInfo,
    00302                                               vtkVolumeRayCastStaticInfo *staticInfo);
    00303
    00304   // Get the ZBuffer value corresponding to location (x,y) where (x,y)
    00305   // are indexing into the ImageInUse image. This must be converted to
    00306   // the zbuffer image coordinates. Nearest neighbor value is returned.
    00307   float         GetZBufferValue( int x, int y );
    00308
    00309 private:
    00310   vtkVolumeRayCastMapper(const vtkVolumeRayCastMapper&);  // Not implemented.
    00311   void operator=(const vtkVolumeRayCastMapper&);  // Not implemented.
    00312 };
    00313
    00314 #endif
    00315