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

graphics/vtkRayCaster.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkRayCaster.h,v $
00005   Language:  C++
00006 
00007 
00008 Copyright (c) 1993-2001 Ken Martin, Will Schroeder, Bill Lorensen 
00009 All rights reserved.
00010 
00011 Redistribution and use in source and binary forms, with or without
00012 modification, are permitted provided that the following conditions are met:
00013 
00014  * Redistributions of source code must retain the above copyright notice,
00015    this list of conditions and the following disclaimer.
00016 
00017  * Redistributions in binary form must reproduce the above copyright notice,
00018    this list of conditions and the following disclaimer in the documentation
00019    and/or other materials provided with the distribution.
00020 
00021  * Neither name of Ken Martin, Will Schroeder, or Bill Lorensen nor the names
00022    of any contributors may be used to endorse or promote products derived
00023    from this software without specific prior written permission.
00024 
00025  * Modified source versions must be plainly marked as such, and must not be
00026    misrepresented as being the original software.
00027 
00028 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
00029 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00030 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00031 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
00032 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00033 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00034 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00035 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00036 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00037 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00038 
00039 =========================================================================*/
00055 #ifndef __vtkRayCaster_h
00056 #define __vtkRayCaster_h
00057 
00058 #include "vtkRenderer.h"
00059 #include "vtkVolume.h"
00060 #include "vtkViewRays.h"
00061 #include "vtkVolumeMapper.h"
00062 #include "vtkMultiThreader.h"
00063 
00064 #define VTK_MAX_VIEW_RAYS_LEVEL 4
00065 
00066 class VTK_EXPORT vtkRayCaster : public vtkObject
00067 {
00068 public:
00069   static vtkRayCaster *New();
00070   vtkTypeMacro(vtkRayCaster,vtkObject);
00071   void PrintSelf(ostream& os, vtkIndent indent);
00072 
00075   float *GetPerspectiveViewRays();
00076 
00078   void GetViewRaysSize( int size[2] );
00079 
00080 
00083   float *GetParallelStartPosition( void );
00084 
00087   float *GetParallelIncrements( void );
00088 
00089   
00092   void SetImageScale(int level, float scale); 
00093   float GetImageScale(int level); 
00094 
00096   int GetImageScaleCount( void ) { return VTK_MAX_VIEW_RAYS_LEVEL; };
00097 
00100   vtkSetClampMacro(SelectedImageScaleIndex, int, 0, VTK_MAX_VIEW_RAYS_LEVEL-1);
00101   vtkGetMacro( SelectedImageScaleIndex, int );
00102 
00105   void SetViewRaysStepSize(int level, float scale); 
00106   float GetViewRaysStepSize(int level); 
00107 
00109   vtkGetMacro( AutomaticScaleAdjustment, int );
00110   
00112   void AutomaticScaleAdjustmentOn( void );
00113 
00115   void AutomaticScaleAdjustmentOff( void );
00116 
00120   vtkSetClampMacro( AutomaticScaleLowerLimit, float, 0.0, 1.0 );
00121   vtkGetMacro( AutomaticScaleLowerLimit, float );
00122 
00124   vtkSetMacro( BilinearImageZoom, int );
00125   vtkGetMacro( BilinearImageZoom, int );
00126   vtkBooleanMacro( BilinearImageZoom, int );
00127 
00129   vtkGetMacro( TotalRenderTime, float );
00130  
00132   vtkSetMacro( NumberOfThreads, int );
00133   vtkGetMacro( NumberOfThreads, int );
00134 
00138   int GetNumberOfSamplesTaken();
00139 
00140   int **RowBounds;
00141   int *RowBoundsSize;
00142   
00143   vtkProp **SoftwareProps;
00144   vtkProp **RayCastProps;
00145 
00146 //BTX
00147 
00151   vtkSetObjectMacro(Renderer,vtkRenderer);
00152   vtkGetObjectMacro(Renderer,vtkRenderer);
00153 
00159   void Render(vtkRenderer *, int, vtkProp **, int, vtkProp **);
00160 
00168   float GetViewportScaleFactor( vtkRenderer *ren );
00169 
00173   float GetViewportStepSize( );
00174   
00175 
00178   float *GetCurrentZBuffer()
00179   {
00180     if ( this->FirstBlend )
00181       {
00182       return NULL;
00183       }
00184     else
00185       {
00186       return this->ZImage;
00187       }
00188   };
00189 
00190 //ETX
00191 
00192 protected:
00193   vtkRayCaster();
00194   ~vtkRayCaster();
00195   vtkRayCaster(const vtkRayCaster&) {};
00196   void operator=(const vtkRayCaster&) {};
00197 
00200   void NearestNeighborZoom(float *smallImage, float *largeImage,
00201             int smallDims[2], int largeDims[2] );
00202 
00204   void BilinearZoom(float *smallImage, float *largeImage,
00205             int smallDims[2], int largeDims[2] );
00206 
00207 
00211   void RescaleImage( );
00212 
00213   void RenderFrameBufferVolumes( vtkRenderer *ren );
00214   void InitializeRenderBuffers( vtkRenderer *ren );
00215   void InitializeRayCasting( vtkRenderer *ren );
00216 
00217 //BTX
00218   void ComputeRowBounds( vtkRenderer *ren, vtkProp *prop, int index );
00219 //ETX
00220 
00221   friend VTK_THREAD_RETURN_TYPE RayCast_RenderImage( void *arg );
00222 
00223   vtkMultiThreader *Threader;
00224 
00225   int              NumberOfThreads;
00226 
00227   int              NumberOfSamplesTaken[VTK_MAX_THREADS];
00228 
00229   vtkRenderer   *Renderer;
00230 
00231   // These are the variables necessary for adjusting the image
00232   // size during ray casting to achieve a desired update rate
00233   vtkViewRays   *ViewRays[VTK_MAX_VIEW_RAYS_LEVEL+1];
00234   float         *SelectedViewRays;
00235   float         ImageScale[VTK_MAX_VIEW_RAYS_LEVEL+1];
00236   int           ImageSize[2];
00237   int           FullImageSize[2];
00238   int    BilinearImageZoom;
00239   int           SelectedImageScaleIndex;
00240   int           StableImageScaleCounter;
00241   float         PreviousAllocatedTime;
00242   int           AutomaticScaleAdjustment;
00243   float         AutomaticScaleLowerLimit;
00244   float         ImageRenderTime[2];
00245   float         ViewRaysStepSize[VTK_MAX_VIEW_RAYS_LEVEL];
00246   float         TotalRenderTime;
00247 
00248   // The working color and depth image
00249   float         *RGBAImage;
00250   float         *ZImage;
00251 
00252 
00253   // Hang on to a pointer to each volume with a ray cast mapper.
00254   // We'll also need some information for each of these volumes
00255   vtkVolume     **RayCastVolumes;
00256   //BTX
00257   struct VolumeRayCastVolumeInfoStruct *VolumeInfo;
00258   //ETX
00259   int           RayCastPropCount;
00260   int           SoftwareBufferPropCount;
00261   vtkTransform  *ViewToWorldTransform;
00262   float         CameraClippingRange[2];
00263   float         ViewToWorldMatrix[4][4];
00264   int           FirstBlend;
00265   float         CameraInverse22;
00266   float         CameraInverse23;
00267   float         CameraInverse32;
00268   float         CameraInverse33;
00269   float         CameraPosition[3];
00270   float         *ParallelStartPosition;
00271   float         *ParallelIncrements;
00272   int           ParallelProjection;
00273   int           NeedBackgroundBlend;
00274   float         Background[3];
00275 };
00276 
00277 #endif
00278 
00279 

Generated on Wed Nov 21 12:27:02 2001 for VTK by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001