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