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