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