1 /*========================================================================= 2 3 Program: Visualization Toolkit 4 Module: vtkVolumeRayCastFunction.h 5 6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 7 All rights reserved. 8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 9 10 This software is distributed WITHOUT ANY WARRANTY; without even 11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 12 PURPOSE. See the above copyright notice for more information. 13 14 =========================================================================*/ 15 16 // .NAME vtkVolumeRayCastFunction - a superclass for ray casting functions 17 18 // .SECTION Description 19 // vtkVolumeRayCastFunction is a superclass for ray casting functions that 20 // can be used within a vtkVolumeRayCastMapper. This includes for example, 21 // vtkVolumeRayCastCompositeFunction, vtkVolumeRayCastMIPFunction, and 22 // vtkVolumeRayCastIsosurfaceFunction. 23 24 // .SECTION See Also 25 // vtkVolumeRayCastCompositeFunction vtkVolumeRayCastMIPFunction 26 // vtkVolumeRayCastIsosurfaceFunction vtkVolumeRayCastMapper 27 28 #ifndef vtkVolumeRayCastFunction_h 29 #define vtkVolumeRayCastFunction_h 30 31 #include "vtkRenderingVolumeModule.h" // For export macro 32 #include "vtkObject.h" 33 34 class vtkRenderer; 35 class vtkVolume; 36 class vtkVolumeRayCastMapper; 37 38 // Define a couple of structures we need to hold all the important information 39 // This first structure hold the dynamic information - stuff that changes per 40 // ray 41 typedef struct 42 { 43 // These are the return values - RGBA 44 float Color[4]; 45 float ScalarValue; 46 47 // Ray information transformed into local coordinates 48 float TransformedStart[4]; 49 float TransformedEnd[4]; 50 float TransformedDirection[4]; 51 float TransformedIncrement[3]; 52 53 // The number of steps we want to take if this is 54 // a ray caster that takes steps 55 int NumberOfStepsToTake; 56 57 // The number of steps we actually take if this is 58 // a ray caster that takes steps 59 int NumberOfStepsTaken; 60 61 } vtkVolumeRayCastDynamicInfo; 62 63 // This second structure hold the static information - things that don't 64 // change over the whole image 65 typedef struct 66 { 67 // A pointer to the volume 68 vtkVolume *Volume; 69 70 // A pointer to the renderer 71 vtkRenderer *Renderer; 72 73 // Matrices for switching from view to volume coordinate, and back 74 float WorldToVoxelsMatrix[16]; 75 float VoxelsToWorldMatrix[16]; 76 float ViewToVoxelsMatrix[16]; 77 78 float *ClippingPlane; 79 int NumberOfClippingPlanes; 80 81 // The camera thickness (distance between near and far) is necessary 82 // for computing sampling distance 83 float CameraThickness; 84 85 // The type of the data and a pointer to it, and the information 86 // about its size, spacing, origin and precomputed increment 87 int ScalarDataType; 88 void *ScalarDataPointer; 89 vtkIdType DataIncrement[3]; 90 int DataSize[3]; 91 double DataSpacing[3]; 92 double DataOrigin[3]; 93 94 // Information from the vtkVolumeProperty 95 int Shading; 96 int ColorChannels; 97 float Color[3]; 98 int InterpolationType; 99 100 // The shading tables from the vtkEncodedGradientShader 101 // that will be used for shading the volume. 102 float *RedDiffuseShadingTable; 103 float *GreenDiffuseShadingTable; 104 float *BlueDiffuseShadingTable; 105 float *RedSpecularShadingTable; 106 float *GreenSpecularShadingTable; 107 float *BlueSpecularShadingTable; 108 109 // Info needed from the gradient estimator 110 unsigned short *EncodedNormals; 111 unsigned char *GradientMagnitudes; 112 113 // Image information 114 int ImageInUseSize[2]; 115 int ImageMemorySize[2]; 116 int ImageViewportSize[2]; 117 int ImageOrigin[2]; 118 unsigned char *Image; 119 120 int *RowBounds; 121 122 // Is a MIP ray cast function in use? This will control 123 // how subsegments of the ray are combined when non-subvolume 124 // cropping is used. If maximize opacity is used, the color[3] 125 // value is used to find the max othersize the dynamicInfo->ScalarValue 126 // value is used 127 int MIPFunction; 128 int MaximizeOpacity; 129 } vtkVolumeRayCastStaticInfo; 130 131 class VTKRENDERINGVOLUME_EXPORT vtkVolumeRayCastFunction : public vtkObject 132 { 133 public: 134 vtkTypeMacro(vtkVolumeRayCastFunction,vtkObject); 135 virtual void PrintSelf(ostream& os, vtkIndent indent); 136 137 //BTX 138 // Description: 139 // Do the basic initialization. This includes saving the parameters 140 // passed in into local variables, as well as grabbing some useful 141 // info from the volume property and normal encoder. This initialize 142 // routine is called once per render. It also calls the 143 // SpecificFunctionInitialize of the subclass function. 144 void FunctionInitialize( vtkRenderer *ren, 145 vtkVolume *vol, 146 vtkVolumeRayCastStaticInfo *staticInfo ); 147 148 virtual void CastRay( vtkVolumeRayCastDynamicInfo *dynamicInfo, 149 vtkVolumeRayCastStaticInfo *staticInfo )=0; 150 //ETX 151 152 // Description: 153 // Get the value below which all scalar values are considered to 154 // have 0 opacity. 155 virtual float GetZeroOpacityThreshold( vtkVolume *vol )=0; 156 157 protected: vtkVolumeRayCastFunction()158 vtkVolumeRayCastFunction() {} ~vtkVolumeRayCastFunction()159 ~vtkVolumeRayCastFunction() {} 160 161 //BTX 162 // Description: 163 // This method gives the subclass a chance to do any special 164 // initialization that it may need to do 165 virtual void SpecificFunctionInitialize( vtkRenderer *ren, 166 vtkVolume *vol, 167 vtkVolumeRayCastStaticInfo *staticInfo, 168 vtkVolumeRayCastMapper *mapper )=0; 169 //ETX 170 private: 171 vtkVolumeRayCastFunction(const vtkVolumeRayCastFunction&); // Not implemented. 172 void operator=(const vtkVolumeRayCastFunction&); // Not implemented. 173 }; 174 175 #endif 176