VTK
dox/VolumeRendering/vtkUnstructuredGridVolumeRayCastMapper.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkUnstructuredGridVolumeRayCastMapper.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 
00031 #ifndef __vtkUnstructuredGridVolumeRayCastMapper_h
00032 #define __vtkUnstructuredGridVolumeRayCastMapper_h
00033 
00034 #include "vtkUnstructuredGridVolumeMapper.h"
00035 
00036 class vtkDoubleArray;
00037 class vtkIdList;
00038 class vtkMultiThreader;
00039 class vtkRayCastImageDisplayHelper;
00040 class vtkRenderer;
00041 class vtkTimerLog;
00042 class vtkUnstructuredGridVolumeRayCastFunction;
00043 class vtkUnstructuredGridVolumeRayCastIterator;
00044 class vtkUnstructuredGridVolumeRayIntegrator;
00045 class vtkVolume;
00046 
00047 class VTK_VOLUMERENDERING_EXPORT vtkUnstructuredGridVolumeRayCastMapper : public vtkUnstructuredGridVolumeMapper
00048 {
00049 public:
00050   static vtkUnstructuredGridVolumeRayCastMapper *New();
00051   vtkTypeMacro(vtkUnstructuredGridVolumeRayCastMapper,vtkUnstructuredGridVolumeMapper);
00052   void PrintSelf( ostream& os, vtkIndent indent );
00053 
00055 
00058   vtkSetClampMacro( ImageSampleDistance, float, 0.1f, 100.0f );
00059   vtkGetMacro( ImageSampleDistance, float );
00061 
00063 
00065   vtkSetClampMacro( MinimumImageSampleDistance, float, 0.1f, 100.0f );
00066   vtkGetMacro( MinimumImageSampleDistance, float );
00068 
00070 
00072   vtkSetClampMacro( MaximumImageSampleDistance, float, 0.1f, 100.0f );
00073   vtkGetMacro( MaximumImageSampleDistance, float );
00075 
00077 
00080   vtkSetClampMacro( AutoAdjustSampleDistances, int, 0, 1 );
00081   vtkGetMacro( AutoAdjustSampleDistances, int );
00082   vtkBooleanMacro( AutoAdjustSampleDistances, int );
00084   
00086 
00088   vtkSetMacro( NumberOfThreads, int );
00089   vtkGetMacro( NumberOfThreads, int );
00091 
00093 
00095   vtkSetClampMacro( IntermixIntersectingGeometry, int, 0, 1 );
00096   vtkGetMacro( IntermixIntersectingGeometry, int );
00097   vtkBooleanMacro( IntermixIntersectingGeometry, int );
00099 
00101 
00102   virtual void SetRayCastFunction(vtkUnstructuredGridVolumeRayCastFunction *f);
00103   vtkGetObjectMacro(RayCastFunction, vtkUnstructuredGridVolumeRayCastFunction);
00105 
00107 
00109   virtual void SetRayIntegrator(vtkUnstructuredGridVolumeRayIntegrator *ri);
00110   vtkGetObjectMacro(RayIntegrator, vtkUnstructuredGridVolumeRayIntegrator);
00112   
00113 //BTX
00116   void Render( vtkRenderer *, vtkVolume * );
00117 
00122   void ReleaseGraphicsResources(vtkWindow *);
00123   
00124   vtkGetVectorMacro( ImageInUseSize, int, 2 );
00125   vtkGetVectorMacro( ImageOrigin, int, 2 );
00126   vtkGetVectorMacro( ImageViewportSize, int , 2 );
00127   
00128 //ETX
00129   
00130   void CastRays( int threadID, int threadCount );
00131 
00132 protected:
00133   vtkUnstructuredGridVolumeRayCastMapper();
00134   ~vtkUnstructuredGridVolumeRayCastMapper();
00135 
00136   float                        ImageSampleDistance;
00137   float                        MinimumImageSampleDistance;
00138   float                        MaximumImageSampleDistance;
00139   int                          AutoAdjustSampleDistances;
00140   
00141   vtkMultiThreader  *Threader;
00142   int               NumberOfThreads;
00143 
00144   vtkRayCastImageDisplayHelper *ImageDisplayHelper;
00145   
00146   // This is how big the image would be if it covered the entire viewport
00147   int            ImageViewportSize[2];
00148   
00149   // This is how big the allocated memory for image is. This may be bigger
00150   // or smaller than ImageFullSize - it will be bigger if necessary to 
00151   // ensure a power of 2, it will be smaller if the volume only covers a
00152   // small region of the viewport
00153   int            ImageMemorySize[2];
00154   
00155   // This is the size of subregion in ImageSize image that we are using for
00156   // the current image. Since ImageSize is a power of 2, there is likely
00157   // wasted space in it. This number will be used for things such as clearing
00158   // the image if necessary.
00159   int            ImageInUseSize[2];
00160   
00161   // This is the location in ImageFullSize image where our ImageSize image
00162   // is located.
00163   int            ImageOrigin[2];
00164   
00165   // This is the allocated image
00166   unsigned char *Image;
00167   
00168   float        *RenderTimeTable;
00169   vtkVolume   **RenderVolumeTable;
00170   vtkRenderer **RenderRendererTable;
00171   int           RenderTableSize;
00172   int           RenderTableEntries;
00173 
00174   void StoreRenderTime( vtkRenderer *ren, vtkVolume *vol, float t );
00175   float RetrieveRenderTime( vtkRenderer *ren, vtkVolume *vol );
00176 
00177   int           IntermixIntersectingGeometry;
00178 
00179   float        *ZBuffer;
00180   int           ZBufferSize[2];
00181   int           ZBufferOrigin[2];
00182 
00183   // Get the ZBuffer value corresponding to location (x,y) where (x,y)
00184   // are indexing into the ImageInUse image. This must be converted to
00185   // the zbuffer image coordinates. Nearest neighbor value is returned.
00186   double         GetZBufferValue( int x, int y );
00187 
00188   double         GetMinimumBoundsDepth( vtkRenderer *ren,
00189                                        vtkVolume   *vol );
00190   
00191   vtkUnstructuredGridVolumeRayCastFunction  *RayCastFunction;
00192   vtkUnstructuredGridVolumeRayCastIterator **RayCastIterators;
00193   vtkUnstructuredGridVolumeRayIntegrator    *RayIntegrator;
00194   vtkUnstructuredGridVolumeRayIntegrator    *RealRayIntegrator;
00195 
00196   vtkIdList      **IntersectedCellsBuffer;
00197   vtkDoubleArray **IntersectionLengthsBuffer;
00198   vtkDataArray   **NearIntersectionsBuffer;
00199   vtkDataArray   **FarIntersectionsBuffer;
00200 
00201   vtkVolume     *CurrentVolume;
00202   vtkRenderer   *CurrentRenderer;
00203 
00204   vtkDataArray *Scalars;
00205   int           CellScalars;
00206   
00207 private:
00208   vtkUnstructuredGridVolumeRayCastMapper(const vtkUnstructuredGridVolumeRayCastMapper&);  // Not implemented.
00209   void operator=(const vtkUnstructuredGridVolumeRayCastMapper&);  // Not implemented.
00210 };
00211 
00212 #endif
00213