1 /*=========================================================================
3 Program: Visualization Toolkit
4 Module: $RCSfile: vtkVolumeRayCastFunction.h,v $
6 Date: $Date: 2002/10/28 21:33:01 $
7 Version: $Revision: 1.29 $
9 Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen
11 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notice for more information.
17 =========================================================================*/
19 // .NAME vtkVolumeRayCastFunction - a superclass for ray casting functions
21 // .SECTION Description
22 // vtkVolumeRayCastFunction is a superclass for ray casting functions that
23 // can be used within a vtkVolumeRayCastMapper. This includes for example,
24 // vtkVolumeRayCastCompositeFunction, vtkVolumeRayCastMIPFunction, and
25 // vtkVolumeRayCastIsosurfaceFunction.
28 // vtkVolumeRayCastCompositeFunction vtkVolumeRayCastMIPFunction
29 // vtkVolumeRayCastIsosurfaceFunction vtkVolumeRayCastMapper
31 #ifndef __vtkVolumeRayCastFunction_h
32 #define __vtkVolumeRayCastFunction_h
34 #include "vtkObject.h"
38 class vtkVolumeRayCastMapper;
40 // Define a couple of structures we need to hold all the important information
41 // This first structure hold the dynamic information - stuff that changes per
45 // These are the return values - RGBA
49 // Ray information transformed into local coordinates
50 float TransformedStart[4];
51 float TransformedEnd[4];
52 float TransformedDirection[4];
53 float TransformedIncrement[3];
55 // The number of steps we want to take if this is
56 // a ray caster that takes steps
57 int NumberOfStepsToTake;
59 // The number of steps we actually take if this is
60 // a ray caster that takes steps
61 int NumberOfStepsTaken;
63 } vtkVolumeRayCastDynamicInfo;
65 // This second structure hold the static information - things that don't
66 // change over the whole image
69 // A pointer to the volume
72 // A pointer to the renderer
73 vtkRenderer *Renderer;
75 // Matrices for switching from view to volume coordinate, and back
76 float WorldToVoxelsMatrix[16];
77 float VoxelsToWorldMatrix[16];
78 float ViewToVoxelsMatrix[16];
81 int NumberOfClippingPlanes;
83 // The camera thickness (distance between near and far) is necessary
84 // for computing sampling distance
85 float CameraThickness;
87 // The type of the data and a pointer to it, and the information
88 // about its size, spacing, origin and precomputed increment
90 void *ScalarDataPointer;
96 // Information from the vtkVolumeProperty
100 int InterpolationType;
102 // The shading tables from the vtkEncodedGradientShader
103 // that will be used for shading the volume.
104 float *RedDiffuseShadingTable;
105 float *GreenDiffuseShadingTable;
106 float *BlueDiffuseShadingTable;
107 float *RedSpecularShadingTable;
108 float *GreenSpecularShadingTable;
109 float *BlueSpecularShadingTable;
111 // Info needed from the gradient estimator
112 unsigned short *EncodedNormals;
113 unsigned char *GradientMagnitudes;
116 int ImageInUseSize[2];
117 int ImageMemorySize[2];
118 int ImageViewportSize[2];
120 unsigned char *Image;
124 // Is a MIP ray cast function in use? This will control
125 // how subsegments of the ray are combined when non-subvolume
126 // cropping is used. If maximize opacity is used, the color[3]
127 // value is used to find the max othersize the dynamicInfo->ScalarValue
131 } vtkVolumeRayCastStaticInfo;
133 class VTK_RENDERING_EXPORT vtkVolumeRayCastFunction : public vtkObject
136 vtkTypeRevisionMacro(vtkVolumeRayCastFunction,vtkObject);
137 virtual void PrintSelf(ostream& os, vtkIndent indent);
140 // Do the basic initialization. This includes saving the parameters
141 // passed in into local variables, as well as grabbing some useful
142 // info from the volume property and normal encoder. This initialize
143 // routine is called once per render. It also calls the
144 // SpecificFunctionInitialize of the subclass function.
146 void FunctionInitialize( vtkRenderer *ren,
148 vtkVolumeRayCastStaticInfo *staticInfo );
150 virtual void CastRay( vtkVolumeRayCastDynamicInfo *dynamicInfo,
151 vtkVolumeRayCastStaticInfo *staticInfo )=0;
155 // Get the value below which all scalar values are considered to
157 virtual float GetZeroOpacityThreshold( vtkVolume *vol )=0;
160 vtkVolumeRayCastFunction() {};
161 ~vtkVolumeRayCastFunction() {};
164 // This method gives the subclass a chance to do any special
165 // initialization that it may need to do
167 virtual void SpecificFunctionInitialize( vtkRenderer *ren,
169 vtkVolumeRayCastStaticInfo *staticInfo,
170 vtkVolumeRayCastMapper *mapper )=0;
173 vtkVolumeRayCastFunction(const vtkVolumeRayCastFunction&); // Not implemented.
174 void operator=(const vtkVolumeRayCastFunction&); // Not implemented.