00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: $RCSfile: vtkVolumeRayCastFunction.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 00034 #ifndef __vtkVolumeRayCastFunction_h 00035 #define __vtkVolumeRayCastFunction_h 00036 00037 #include "vtkObject.h" 00038 00039 class vtkRenderer; 00040 class vtkVolume; 00041 class vtkVolumeRayCastMapper; 00042 00043 // Define a couple of structures we need to hold all the important information 00044 // This first structure hold the dynamic information - stuff that changes per 00045 // ray 00046 typedef struct 00047 { 00048 // These are the return values - RGBA 00049 float Color[4]; 00050 float ScalarValue; 00051 00052 // Ray information transformed into local coordinates 00053 float TransformedStart[4]; 00054 float TransformedEnd[4]; 00055 float TransformedDirection[4]; 00056 float TransformedIncrement[3]; 00057 00058 // The number of steps we want to take if this is 00059 // a ray caster that takes steps 00060 int NumberOfStepsToTake; 00061 00062 // The number of steps we actually take if this is 00063 // a ray caster that takes steps 00064 int NumberOfStepsTaken; 00065 00066 } vtkVolumeRayCastDynamicInfo; 00067 00068 // This second structure hold the static information - things that don't 00069 // change over the whole image 00070 typedef struct 00071 { 00072 // A pointer to the volume 00073 vtkVolume *Volume; 00074 00075 // A pointer to the renderer 00076 vtkRenderer *Renderer; 00077 00078 // Matrices for switching from view to volume coordinate, and back 00079 float WorldToVoxelsMatrix[16]; 00080 float VoxelsToWorldMatrix[16]; 00081 float ViewToVoxelsMatrix[16]; 00082 00083 float *ClippingPlane; 00084 int NumberOfClippingPlanes; 00085 00086 // The camera thickness (distance between near and far) is necessary 00087 // for computing sampling distance 00088 float CameraThickness; 00089 00090 // The type of the data and a pointer to it, and the information 00091 // about its size, spacing, origin and precomputed increment 00092 int ScalarDataType; 00093 void *ScalarDataPointer; 00094 int DataIncrement[3]; 00095 int DataSize[3]; 00096 float DataSpacing[3]; 00097 float DataOrigin[3]; 00098 00099 // Information from the vtkVolumeProperty 00100 int Shading; 00101 int ColorChannels; 00102 float Color[3]; 00103 int InterpolationType; 00104 00105 // The shading tables from the vtkEncodedGradientShader 00106 // that will be used for shading the volume. 00107 float *RedDiffuseShadingTable; 00108 float *GreenDiffuseShadingTable; 00109 float *BlueDiffuseShadingTable; 00110 float *RedSpecularShadingTable; 00111 float *GreenSpecularShadingTable; 00112 float *BlueSpecularShadingTable; 00113 00114 // Info needed from the gradient estimator 00115 unsigned short *EncodedNormals; 00116 unsigned char *GradientMagnitudes; 00117 00118 // Image information 00119 int ImageInUseSize[2]; 00120 int ImageMemorySize[2]; 00121 int ImageViewportSize[2]; 00122 int ImageOrigin[2]; 00123 unsigned char *Image; 00124 00125 int *RowBounds; 00126 00127 // Is a MIP ray cast function in use? This will control 00128 // how subsegments of the ray are combined when non-subvolume 00129 // cropping is used. If maximize opacity is used, the color[3] 00130 // value is used to find the max othersize the dynamicInfo->ScalarValue 00131 // value is used 00132 int MIPFunction; 00133 int MaximizeOpacity; 00134 } vtkVolumeRayCastStaticInfo; 00135 00136 class VTK_RENDERING_EXPORT vtkVolumeRayCastFunction : public vtkObject 00137 { 00138 public: 00139 vtkTypeRevisionMacro(vtkVolumeRayCastFunction,vtkObject); 00140 virtual void PrintSelf(ostream& os, vtkIndent indent); 00141 00143 00148 void FunctionInitialize( vtkRenderer *ren, 00149 vtkVolume *vol, 00150 vtkVolumeRayCastStaticInfo *staticInfo ); 00152 00153 virtual void CastRay( vtkVolumeRayCastDynamicInfo *dynamicInfo, 00154 vtkVolumeRayCastStaticInfo *staticInfo )=0; 00155 //ETX 00156 00159 virtual float GetZeroOpacityThreshold( vtkVolume *vol )=0; 00160 00161 protected: 00162 vtkVolumeRayCastFunction() {}; 00163 ~vtkVolumeRayCastFunction() {}; 00164 00166 00168 virtual void SpecificFunctionInitialize( vtkRenderer *ren, 00169 vtkVolume *vol, 00170 vtkVolumeRayCastStaticInfo *staticInfo, 00171 vtkVolumeRayCastMapper *mapper )=0; 00173 //ETX 00174 private: 00175 vtkVolumeRayCastFunction(const vtkVolumeRayCastFunction&); // Not implemented. 00176 void operator=(const vtkVolumeRayCastFunction&); // Not implemented. 00177 }; 00178 00179 #endif