Class RayCastRenderer
- Direct Known Subclasses:
RayCastColor,RayCastIntensity
The camera coordinate system has eye point is E = (0,0,z). The direction vector is D = (0,0,1), the up vector is U = (0,1,0), and the right vector is R = (1,0,0). Only the eye point is allowed to change. Since the 3D image can be arbitrarily rotated (via a virtual trackball), any portion of the image can be viewed either close up or far away.
The view plane has normal D and origin at E+n*D (n=near). The view frustum is orthogonal and has no far plane. For a perspective camera, the field of view is given as an angle A subtended at the eye point. In camera coordinates, the view port is the square [-e,e]^2 where e = n*tan(A/2). In world coordinates, the corners of the square are E+n*D+s*e*U+t*e*R where |s| = |t| = 1 (four choices on sign). For a parallel camera, there is no field of view.
The mapping between the viewport [-e,e]^2 and the B-by-B render image is the following. If (i,j) is a pixel in the image, then the corresponding viewport point is (r,u) = (-e+2*e*i/(B-1),-e+2*e*j/(B-1)).
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected floatDOCUMENT ME!private booleanBlur the final image to reduce voxel contrast.(package private) floatThe clip plane position in the box.(package private) floatThe clip plane position in the box.(package private) floatDOCUMENT ME!(package private) floatDOCUMENT ME!(package private) floatDOCUMENT ME!(package private) floatDOCUMENT ME!(package private) floatx, y, z delta value.(package private) floatx, y, z delta value.(package private) floatx, y, z delta value.protected floatDOCUMENT ME!protected floatThe inverse delta values are for scaling back to original coordinates for correct interpolation of the image.protected floatThe inverse delta values are for scaling back to original coordinates for correct interpolation of the image.protected floatThe inverse delta values are for scaling back to original coordinates for correct interpolation of the image.private floatthe parameters for clipped rays.private floatthe parameters for clipped rays.protected javax.vecmath.Vector3fOriented bounding box of image, centered at (0,0,0), axes are stored as the columns of a rotation matrix, and half-widths are specified.protected javax.vecmath.Vector3fDOCUMENT ME!protected javax.vecmath.Point3fRay in box (model) coordinates.protected javax.vecmath.Point3fthe intersection points of ray with box.protected javax.vecmath.Point3fthe intersection points of ray with box.protected javax.vecmath.Vector3fDOCUMENT ME!protected javax.vecmath.Vector3fIntersection of ray with view plane.protected javax.vecmath.Vector3fDOCUMENT ME!protected javax.vecmath.Vector3fRay in world coordinates.private final booleanprivate final intprotected ModelLUTDOCUMENT ME!protected ModelLUTDOCUMENT ME!protected floatDOCUMENT ME!private final int[]DOCUMENT ME!protected javax.vecmath.Color3fVertex material diffuse color.protected javax.vecmath.Color3fVertex material specular color.protected float[]Used to store the transfer function points for remapping to the LUT.protected float[]DOCUMENT ME!protected float[]DOCUMENT ME!protected float[]DOCUMENT ME!Fields inherited from class gov.nih.mipav.view.renderer.J3D.volumeview.Renderer
m_aiRImage, m_akAxis, m_akNormal, m_bParallel, m_bReloadInput, m_fAngle, m_fExtreme, m_fFMult, m_fGamma, m_fNear, m_fRScaleX, m_fRScaleY, m_fXTrn, m_fYTrn, m_fZoom, m_iMaxBound, m_iMinBound, m_iRBound, m_iXBound, m_iXBoundM1, m_iXBoundM2, m_iXYProduct, m_iXYZProduct, m_iYBound, m_iYBoundM1, m_iYBoundM2, m_iZBound, m_iZBoundM1, m_iZBoundM2, m_kBackgroundColor, m_kEyeModel, m_kEyeWorld, m_kImage, m_kLightSet, m_kMaterial, m_kRotate -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedRayCastRenderer(ModelImage kImage, int iRBound, int[] aiRImage) The constructor for the ray tracer. -
Method Summary
Modifier and TypeMethodDescriptionprivate booleanclipped(float fDen, float fNum, float[] t) Support for clipping line segments against coordinate planes.voiddisposeLocal(boolean flag) Clean memory.protected voidfinalize()Calls dispose.javax.vecmath.Vector3fgetAxis(int i) Read the current axis at index i.protected final intinterpolate(javax.vecmath.Point3f kP, byte[] acImage) Trilinear interpolation of the image to produce image values at points P that are not at the integer voxel locations.private booleanintersectsBox(javax.vecmath.Vector3f mDir, javax.vecmath.Point3f mOrig, javax.vecmath.Point3f p0, javax.vecmath.Point3f p1) Clip the current ray against the oriented bounding box of the 3D image.protected abstract voidprocessRay(int iIndex, int rayTraceStepSize) Process a ray that has intersected the oriented bounding box of the 3D image.protected abstract voidprocessRay(javax.vecmath.Point3f p0, javax.vecmath.Point3f p1, int iIndex, int rayTraceStepSize) Process a ray that has intersected the oriented bounding box of the 3D image.voidrotateBy(javax.vecmath.AxisAngle4f kAxisAngle) Rotate the oriented bounding box of the 3D image about the specified axis with the specified angle.voidrotateFrameBy(javax.media.j3d.Transform3D transform) Rotate the oriented bounding box of the 3D image about the specified axis with the specified angle.voidsetAxis(int i, javax.vecmath.Vector3f kAxis) Change an axis of the oriented bounding box of the 3D image.voidsetBlurFlag(boolean flag) Blur the resulting image or not.voidsetDiffuse(Color color) Set vertex material diffuse color.voidsetOpacityFunctions(ModelLUT opacityFunctionA, ModelLUT opacityFunctionB) Add here.voidsetSpecular(Color color) Set vertex material specular color.voidsetXBoundNeg(float value) Setup the X Negative clipping plane position.voidsetXBoundPos(float value) Setup the X positive clipping plane position.voidsetYBoundNeg(float value) Setup the Y Negative clipping plane position.voidsetYBoundPos(float value) Setup the Y positive clipping plane position.voidsetZBoundNeg(float value) Setup the Z negative clipping plane position.voidsetZBoundPos(float value) Setup the Z positive clipping plane position.final voidtrace(int rayTraceStepSize, int iSpacing) Ray trace the 3D image in its current orientation as determined by the oriented bounding box.voidtraceBlockRays(int xStart, int xEnd, int yStart, int yEnd, int rayTraceStepSize, int iSpacing) Methods inherited from class gov.nih.mipav.view.renderer.J3D.volumeview.Renderer
computeIntegralNormalizationFactor, convertWorldToModel, disposeLocal, getAngle, getBackgroundColor, getExtreme, getEyeDist, getEyePoint, getGamma, getMaxBound, getMinBound, getNear, getParallel, getXBound, getXTranslate, getYBound, getYTranslate, getZBound, getZoom, hasInputData, hasNormals, orthonormalize, reloadInputData, reloadInputData, setAngle, setBackgroundColor, setExtreme, setEyeDist, setGamma, setLighting, setMaterialShininess, setNear, setNearAndAngle, setNormals, setParallel, setXTranslate, setYTranslate, setZoom, traceInit, usesNormals
-
Field Details
-
m_fInvXDelta
protected float m_fInvXDeltaThe inverse delta values are for scaling back to original coordinates for correct interpolation of the image. -
m_fInvYDelta
protected float m_fInvYDeltaThe inverse delta values are for scaling back to original coordinates for correct interpolation of the image. -
m_fInvZDelta
protected float m_fInvZDeltaThe inverse delta values are for scaling back to original coordinates for correct interpolation of the image. -
m_kExtent
protected javax.vecmath.Vector3f m_kExtentOriented bounding box of image, centered at (0,0,0), axes are stored as the columns of a rotation matrix, and half-widths are specified. -
m_kMDir
protected javax.vecmath.Vector3f m_kMDirDOCUMENT ME! -
m_kMOrig
protected javax.vecmath.Point3f m_kMOrigRay in box (model) coordinates. -
m_kP0
protected javax.vecmath.Point3f m_kP0the intersection points of ray with box. -
m_kP1
protected javax.vecmath.Point3f m_kP1the intersection points of ray with box. -
m_kPDiff
protected javax.vecmath.Vector3f m_kPDiffDOCUMENT ME! -
m_kV
protected javax.vecmath.Vector3f m_kVIntersection of ray with view plane. -
m_kWDir
protected javax.vecmath.Vector3f m_kWDirDOCUMENT ME! -
m_kWOrig
protected javax.vecmath.Vector3f m_kWOrigRay in world coordinates. -
opacityFunctA
DOCUMENT ME! -
opacityFunctB
DOCUMENT ME! -
red
protected float redDOCUMENT ME! -
green
protected float greenDOCUMENT ME! -
blue
protected float blueDOCUMENT ME! -
vertexDiffuse
protected javax.vecmath.Color3f vertexDiffuseVertex material diffuse color. -
vertexSpecular
protected javax.vecmath.Color3f vertexSpecularVertex material specular color. -
xLUTa
protected float[] xLUTaUsed to store the transfer function points for remapping to the LUT. -
xLUTb
protected float[] xLUTbDOCUMENT ME! -
yLUTa
protected float[] yLUTaDOCUMENT ME! -
yLUTb
protected float[] yLUTbDOCUMENT ME! -
clipRegionXNeg
float clipRegionXNegThe clip plane position in the box. -
clipRegionXPos
float clipRegionXPosThe clip plane position in the box. -
clipRegionYNeg
float clipRegionYNegDOCUMENT ME! -
clipRegionYPos
float clipRegionYPosDOCUMENT ME! -
clipRegionZNeg
float clipRegionZNegDOCUMENT ME! -
clipRegionZPos
float clipRegionZPosDOCUMENT ME! -
fXDelta
float fXDeltax, y, z delta value. -
fYDelta
float fYDeltax, y, z delta value. -
fZDelta
float fZDeltax, y, z delta value. -
bluring
private boolean bluringBlur the final image to reduce voxel contrast. -
m_fT0
private float m_fT0the parameters for clipped rays. -
m_fT1
private float m_fT1the parameters for clipped rays. -
tempImage
private final int[] tempImageDOCUMENT ME! -
multiThreadingEnabled
private final boolean multiThreadingEnabled -
nthreads
private final int nthreads
-
-
Constructor Details
-
RayCastRenderer
The constructor for the ray tracer. Currently, the only client of this class is VolumeRenderer.- Parameters:
kImage- the 3D imageiRBound- the dimension of the square 2D renderer imageaiRImage- The rendered image data stored in row-major order. Each integer pixel represents an RGB color in the format B | (G invalid input: '<'invalid input: '<' 8) | (R invalid input: '<'invalid input: '<' 16).
-
-
Method Details
-
disposeLocal
public void disposeLocal(boolean flag) Clean memory.- Parameters:
flag- is true call the super.disposeLocal
-
getAxis
public javax.vecmath.Vector3f getAxis(int i) Read the current axis at index i. -
rotateBy
public void rotateBy(javax.vecmath.AxisAngle4f kAxisAngle) Rotate the oriented bounding box of the 3D image about the specified axis with the specified angle. -
rotateFrameBy
public void rotateFrameBy(javax.media.j3d.Transform3D transform) Rotate the oriented bounding box of the 3D image about the specified axis with the specified angle.- Specified by:
rotateFrameByin classRenderer- Parameters:
transform- the axis and angle formulation for the rotation
-
setAxis
public void setAxis(int i, javax.vecmath.Vector3f kAxis) Change an axis of the oriented bounding box of the 3D image.- Parameters:
i- the axis index (0, 1, or 2)kAxis- the new axis vector at index i
-
setBlurFlag
public void setBlurFlag(boolean flag) Blur the resulting image or not.- Parameters:
flag- true blur the image, false not blur.
-
setDiffuse
Set vertex material diffuse color.- Parameters:
color- true blur the image, false not blur.
-
setOpacityFunctions
Add here.- Parameters:
opacityFunctionA- DOCUMENT ME!opacityFunctionB- DOCUMENT ME!
-
setSpecular
Set vertex material specular color.- Parameters:
color- true blur the image, false not blur.
-
setXBoundNeg
public void setXBoundNeg(float value) Setup the X Negative clipping plane position.- Specified by:
setXBoundNegin classRenderer- Parameters:
value- position of the X negative clip slider.
-
setXBoundPos
public void setXBoundPos(float value) Setup the X positive clipping plane position.- Specified by:
setXBoundPosin classRenderer- Parameters:
value- position of the X positive clip slider.
-
setYBoundNeg
public void setYBoundNeg(float value) Setup the Y Negative clipping plane position.- Specified by:
setYBoundNegin classRenderer- Parameters:
value- position of the Y negative clip slider.
-
setYBoundPos
public void setYBoundPos(float value) Setup the Y positive clipping plane position.- Specified by:
setYBoundPosin classRenderer- Parameters:
value- positin of the Y positve clip slider.
-
setZBoundNeg
public void setZBoundNeg(float value) Setup the Z negative clipping plane position.- Specified by:
setZBoundNegin classRenderer- Parameters:
value- position of the Z negative clip slider.
-
setZBoundPos
public void setZBoundPos(float value) Setup the Z positive clipping plane position.- Specified by:
setZBoundPosin classRenderer- Parameters:
value- position of the Z positive clip slider.
-
trace
public final void trace(int rayTraceStepSize, int iSpacing) Ray trace the 3D image in its current orientation as determined by the oriented bounding box. The rendered image is initialized to the background color. A pixel is overwritten only when a ray intersects the bounding box of the image, that pixel corresponding to the given ray.- Parameters:
rayTraceStepSize- DOCUMENT ME!iSpacing- A positive value indicating how often to sample the rendered image. The typical value is 1 indicating that all rays corresponding to all pixels should be processed. If the value is 2, rays corresponding to pixels (x,y) with (x mod 2) = 0 and (y mod 2) = 0 are processed. The other pixels are assigned values of the modulo 2 neighbor pixel. Similar reduced sampling occurs with larger values of iSpacing. VolumeRenderer sets the spacing to be 2 when the image is being rotated by the virtual track ball. Once the image is finished rotating, a final trace is made with a spacing of 1.
-
traceBlockRays
public void traceBlockRays(int xStart, int xEnd, int yStart, int yEnd, int rayTraceStepSize, int iSpacing) - Parameters:
xStart-xEnd-yStart-yEnd-rayTraceStepSize-iSpacing-
-
processRay
protected abstract void processRay(int iIndex, int rayTraceStepSize) Process a ray that has intersected the oriented bounding box of the 3D image. The method is only called if there is a line segment of intersection. The 'intersectsBox' stores the end points of the line segment in the class members m_kP0 and m_kP1 in image coordinates.The function sets the color of the pixel corresponding to the processed ray. The RGB value is stored as an integer in the format B | (G invalid input: '<'invalid input: '<' 8) | (R invalid input: '<'invalid input: '<' 16). This method always returns a gray scale value (B = G = R). However, the function can be overridden in a subclass to produce other rendering effects. For example, the color can be set to a non-gray value if the ray intersects a level region bounded by a level surface. See SurfaceRayTrace.java for an example.
- Parameters:
iIndex- index of the pixel corresponding to the processed rayrayTraceStepSize- DOCUMENT ME!
-
processRay
protected abstract void processRay(javax.vecmath.Point3f p0, javax.vecmath.Point3f p1, int iIndex, int rayTraceStepSize) Process a ray that has intersected the oriented bounding box of the 3D image. The method is only called if there is a line segment of intersection. The 'intersectsBox' stores the end points of the line segment in the class members P0 and P1 in image coordinates. The local P0 and p1 are used for the multi-theading rendering.The function sets the color of the pixel corresponding to the processed ray. The RGB value is stored as an integer in the format B | (G invalid input: '<'invalid input: '<' 8) | (R invalid input: '<'invalid input: '<' 16). This method always returns a gray scale value (B = G = R). However, the function can be overridden in a subclass to produce other rendering effects. For example, the color can be set to a non-gray value if the ray intersects a level region bounded by a level surface. See SurfaceRayTrace.java for an example.
- Parameters:
p0- Local starting point.p1- Local ending pointiIndex- index of the pixel corresponding to the processed rayrayTraceStepSize- raycast step size.
-
finalize
Calls dispose. -
interpolate
protected final int interpolate(javax.vecmath.Point3f kP, byte[] acImage) Trilinear interpolation of the image to produce image values at points P that are not at the integer voxel locations.- Parameters:
kP- the spatial point to be assigned an interpolated valueacImage- The array of byte values to be interpolated- Returns:
- The interpolated value for the point. If kP is not within the bounding box of the image, a value of -1 is returned.
-
clipped
private boolean clipped(float fDen, float fNum, float[] t) Support for clipping line segments against coordinate planes. The function computes the line segment parameter corresponding to the intersection of the segment with a coordinate plane. However, the expensive division is performed only if in fact there is an intersection. The deferred division speeds up the ray tracing a lot since this method is called up to 6 times per ray.- Parameters:
fDen- the denominator of the line segment parameter of the intersectionfNum- the numerator of the line segment parameter of the intersectiont- [] t[0] for the line starting point intersection parameter, t[1] for the line ending point intersection parameter.- Returns:
- true if the entire line segment is entirely clipped by the current plane (segment is "outside" the plane), false if the segment intersects the plane or is contained "inside" the plane.
-
intersectsBox
private boolean intersectsBox(javax.vecmath.Vector3f mDir, javax.vecmath.Point3f mOrig, javax.vecmath.Point3f p0, javax.vecmath.Point3f p1) Clip the current ray against the oriented bounding box of the 3D image. The trace method sets up the ray in world coordinates. The intersector converts the ray to box coordinates so that the ray is clipped against an axis-aligned box.The end points of the intersecting line segment are stored in class members m_kP0 and m_kP1 as image coordinates. The bounding box is centered at the origin. The image coordinates are just a translation of box coordinates so that the center of the box becomes the center of the image. The class members m_fT0 and m_fT1 are the corresponding line segment parameters. They are class members only because Java does not support call-by-reference semantics. In another language, the parameters can be local and passed to 'clipped' with the potential to be changed by 'clipped'.
- Returns:
- true if and only if the ray intersects the box
-