• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

dox/VolumeRendering/vtkVolumeRayCastMapper.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkVolumeRayCastMapper.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 
00028 #ifndef __vtkVolumeRayCastMapper_h
00029 #define __vtkVolumeRayCastMapper_h
00030 
00031 #include "vtkVolumeMapper.h"
00032 #include "vtkVolumeRayCastFunction.h" // For vtkVolumeRayCastStaticInfo 
00033                                       // and vtkVolumeRayCastDynamicInfo
00034 #include "vtkFastNumericConversion.h" // for fast rounding and floor
00035 
00036 class vtkEncodedGradientEstimator;
00037 class vtkEncodedGradientShader;
00038 class vtkMatrix4x4;
00039 class vtkMultiThreader;
00040 class vtkPlaneCollection;
00041 class vtkRenderer;
00042 class vtkTimerLog;
00043 class vtkVolume;
00044 class vtkVolumeRayCastFunction;
00045 class vtkVolumeTransform;
00046 class vtkTransform;
00047 class vtkRayCastImageDisplayHelper;
00048 
00049 //BTX
00050 // Macro for floor of x
00051 
00052 inline int vtkFloorFuncMacro(double x)
00053 {
00054   return vtkFastNumericConversion::QuickFloor(x);
00055 }
00056 
00057 
00058 // Macro for rounding x (for x >= 0)
00059 inline int vtkRoundFuncMacro(double x)
00060 {
00061   return vtkFastNumericConversion::Round(x);
00062 }
00063 //ETX
00064 
00065 // Macro for tri-linear interpolation - do four linear interpolations on
00066 // edges, two linear interpolations between pairs of edges, then a final
00067 // interpolation between faces
00068 #define vtkTrilinFuncMacro(v,x,y,z,a,b,c,d,e,f,g,h)         \
00069         t00 =   a + (x)*(b-a);      \
00070         t01 =   c + (x)*(d-c);      \
00071         t10 =   e + (x)*(f-e);      \
00072         t11 =   g + (x)*(h-g);      \
00073         t0  = t00 + (y)*(t01-t00);  \
00074         t1  = t10 + (y)*(t11-t10);  \
00075         v   =  t0 + (z)*(t1-t0);
00076 
00077 // Forward declaration needed for use by friend declaration below.
00078 VTK_THREAD_RETURN_TYPE VolumeRayCastMapper_CastRays( void *arg );
00079 
00080 class VTK_VOLUMERENDERING_EXPORT vtkVolumeRayCastMapper : public vtkVolumeMapper
00081 {
00082 public:
00083   static vtkVolumeRayCastMapper *New();
00084   vtkTypeRevisionMacro(vtkVolumeRayCastMapper,vtkVolumeMapper);
00085   void PrintSelf( ostream& os, vtkIndent indent );
00086 
00088 
00091   vtkSetMacro( SampleDistance, double );
00092   vtkGetMacro( SampleDistance, double );
00094 
00096 
00098   virtual void SetVolumeRayCastFunction(vtkVolumeRayCastFunction*);
00099   vtkGetObjectMacro( VolumeRayCastFunction, vtkVolumeRayCastFunction );
00101 
00103 
00104   virtual void SetGradientEstimator(vtkEncodedGradientEstimator *gradest);
00105   vtkGetObjectMacro( GradientEstimator, vtkEncodedGradientEstimator );
00107 
00109 
00110   vtkGetObjectMacro( GradientShader, vtkEncodedGradientShader );
00112 
00114 
00117   vtkSetClampMacro( ImageSampleDistance, double, 0.1, 100.0 );
00118   vtkGetMacro( ImageSampleDistance, double );
00120 
00122 
00124   vtkSetClampMacro( MinimumImageSampleDistance, double, 0.1, 100.0 );
00125   vtkGetMacro( MinimumImageSampleDistance, double );
00127 
00129 
00131   vtkSetClampMacro( MaximumImageSampleDistance, double, 0.1, 100.0 );
00132   vtkGetMacro( MaximumImageSampleDistance, double );
00134 
00136 
00139   vtkSetClampMacro( AutoAdjustSampleDistances, int, 0, 1 );
00140   vtkGetMacro( AutoAdjustSampleDistances, int );
00141   vtkBooleanMacro( AutoAdjustSampleDistances, int );
00143   
00145 
00147   void SetNumberOfThreads( int num );
00148   int GetNumberOfThreads();
00150 
00152 
00154   vtkSetClampMacro( IntermixIntersectingGeometry, int, 0, 1 );
00155   vtkGetMacro( IntermixIntersectingGeometry, int );
00156   vtkBooleanMacro( IntermixIntersectingGeometry, int );
00158   
00159 //BTX
00162   void Render( vtkRenderer *, vtkVolume * );
00163 
00168   void ReleaseGraphicsResources(vtkWindow *);
00169 
00172   float GetZeroOpacityThreshold( vtkVolume *vol );
00173 
00175 
00177   virtual float GetGradientMagnitudeScale();
00178   virtual float GetGradientMagnitudeBias();
00179   virtual float GetGradientMagnitudeScale(int)
00180     {return this->GetGradientMagnitudeScale();};
00181   virtual float GetGradientMagnitudeBias(int)
00182     {return this->GetGradientMagnitudeBias();};
00184   
00185 //ETX
00186 
00187 protected:
00188   vtkVolumeRayCastMapper();
00189   ~vtkVolumeRayCastMapper();
00190 
00191   vtkVolumeRayCastFunction     *VolumeRayCastFunction;
00192   vtkEncodedGradientEstimator  *GradientEstimator;
00193   vtkEncodedGradientShader     *GradientShader;
00194   vtkRayCastImageDisplayHelper *ImageDisplayHelper;
00195   
00196   virtual void ReportReferences(vtkGarbageCollector*);
00197 
00198   // The distance between sample points along the ray
00199   double                       SampleDistance;
00200   double                       ImageSampleDistance;
00201   double                       MinimumImageSampleDistance;
00202   double                       MaximumImageSampleDistance;
00203   int                          AutoAdjustSampleDistances;
00204   
00205   double                       WorldSampleDistance;
00206   int                          ScalarDataType;
00207   void                         *ScalarDataPointer;
00208 
00209   void                         UpdateShadingTables( vtkRenderer *ren, 
00210                                                     vtkVolume *vol );
00211 
00212   void ComputeMatrices( vtkImageData *data, vtkVolume *vol );
00213   int ComputeRowBounds( vtkVolume *vol, vtkRenderer *ren );
00214   
00215   friend VTK_THREAD_RETURN_TYPE VolumeRayCastMapper_CastRays( void *arg );
00216 
00217   vtkMultiThreader  *Threader;
00218 
00219   vtkMatrix4x4 *PerspectiveMatrix;
00220   vtkMatrix4x4 *ViewToWorldMatrix;
00221   vtkMatrix4x4 *ViewToVoxelsMatrix;
00222   vtkMatrix4x4 *VoxelsToViewMatrix;
00223   vtkMatrix4x4 *WorldToVoxelsMatrix;
00224   vtkMatrix4x4 *VoxelsToWorldMatrix;
00225 
00226   vtkMatrix4x4 *VolumeMatrix;
00227   
00228   vtkTransform *PerspectiveTransform;
00229   vtkTransform *VoxelsTransform;
00230   vtkTransform *VoxelsToViewTransform;
00231   
00232   // This is how big the image would be if it covered the entire viewport
00233   int            ImageViewportSize[2];
00234   
00235   // This is how big the allocated memory for image is. This may be bigger
00236   // or smaller than ImageFullSize - it will be bigger if necessary to 
00237   // ensure a power of 2, it will be smaller if the volume only covers a
00238   // small region of the viewport
00239   int            ImageMemorySize[2];
00240   
00241   // This is the size of subregion in ImageSize image that we are using for
00242   // the current image. Since ImageSize is a power of 2, there is likely
00243   // wasted space in it. This number will be used for things such as clearing
00244   // the image if necessary.
00245   int            ImageInUseSize[2];
00246   
00247   // This is the location in ImageFullSize image where our ImageSize image
00248   // is located.
00249   int            ImageOrigin[2];
00250   
00251   // This is the allocated image
00252   unsigned char *Image;
00253   
00254   int  *RowBounds;
00255   int  *OldRowBounds;
00256 
00257   float        *RenderTimeTable;
00258   vtkVolume   **RenderVolumeTable;
00259   vtkRenderer **RenderRendererTable;
00260   int           RenderTableSize;
00261   int           RenderTableEntries;
00262 
00263   void StoreRenderTime( vtkRenderer *ren, vtkVolume *vol, float t );
00264   float RetrieveRenderTime( vtkRenderer *ren, vtkVolume *vol );
00265 
00266   int           IntermixIntersectingGeometry;
00267 
00268   float        *ZBuffer;
00269   int           ZBufferSize[2];
00270   int           ZBufferOrigin[2];
00271 
00272   float         MinimumViewDistance;
00273   
00274   int           ClipRayAgainstVolume( vtkVolumeRayCastDynamicInfo *dynamicInfo,
00275                                       float bounds[6] );
00276 
00277   void          InitializeClippingPlanes( vtkVolumeRayCastStaticInfo *staticInfo,
00278                                           vtkPlaneCollection *planes );
00279 
00280   int           ClipRayAgainstClippingPlanes( vtkVolumeRayCastDynamicInfo *dynamicInfo,
00281                                               vtkVolumeRayCastStaticInfo *staticInfo);
00282   
00283   // Get the ZBuffer value corresponding to location (x,y) where (x,y)
00284   // are indexing into the ImageInUse image. This must be converted to
00285   // the zbuffer image coordinates. Nearest neighbor value is returned.
00286   double         GetZBufferValue( int x, int y );
00287 
00288 private:
00289   vtkVolumeRayCastMapper(const vtkVolumeRayCastMapper&);  // Not implemented.
00290   void operator=(const vtkVolumeRayCastMapper&);  // Not implemented.
00291 };
00292 
00293 #endif
00294 

Generated by  doxygen 1.7.1