Class VolumeRayCast

java.lang.Object
gov.nih.mipav.view.renderer.WildMagic.Render.VolumeObject
gov.nih.mipav.view.renderer.WildMagic.Render.VolumeRayCast

public class VolumeRayCast extends VolumeObject
Author:
alexa
  • Field Details

    • m_kVolumeShaderEffect

      private VolumeShaderEffectMultiPass m_kVolumeShaderEffect
      VolumeShaderEffect applied to proxy-geometry:
    • m_spkVertexColor3Shader

      private WildMagic.LibGraphics.Effects.ShaderEffect m_spkVertexColor3Shader
      Vertex-color shader effect used for the polylines and the first-pass rendering of the proxy-geometry:
    • m_fMax

      private float m_fMax
      Normalized volume extents:
    • m_kMaterial

      private WildMagic.LibGraphics.Rendering.MaterialState m_kMaterial
      Material properties for Volume Surface (and Composite Surface) mode
    • m_kMesh

      private WildMagic.LibGraphics.SceneGraph.TriMesh m_kMesh
      Volume proxy-geometry (cube)
    • numPoints

      private final int numPoints
      See Also:
    • centerBox

      private WildMagic.LibFoundation.Mathematics.Vector3f centerBox
    • clippedPoints

      private boolean[] clippedPoints
    • cornerPoints

      private WildMagic.LibFoundation.Mathematics.Vector3f[] cornerPoints
    • rotatedPoints

      private WildMagic.LibFoundation.Mathematics.Vector3f[] rotatedPoints
    • reorderedList

      private int[] reorderedList
    • frontBottomLeftIndex

      private final int frontBottomLeftIndex
      See Also:
    • frontBottomRightIndex

      private final int frontBottomRightIndex
      See Also:
    • frontTopRightIndex

      private final int frontTopRightIndex
      See Also:
    • frontTopLeftIndex

      private final int frontTopLeftIndex
      See Also:
    • backBottomLeftIndex

      private final int backBottomLeftIndex
      See Also:
    • backBottomRightIndex

      private final int backBottomRightIndex
      See Also:
    • backTopRightIndex

      private final int backTopRightIndex
      See Also:
    • backTopLeftIndex

      private final int backTopLeftIndex
      See Also:
    • frontBottomLeft

      private WildMagic.LibFoundation.Mathematics.Vector3f frontBottomLeft
    • frontBottomRight

      private WildMagic.LibFoundation.Mathematics.Vector3f frontBottomRight
    • frontTopRight

      private WildMagic.LibFoundation.Mathematics.Vector3f frontTopRight
    • frontTopLeft

      private WildMagic.LibFoundation.Mathematics.Vector3f frontTopLeft
    • backBottomLeft

      private WildMagic.LibFoundation.Mathematics.Vector3f backBottomLeft
    • backBottomRight

      private WildMagic.LibFoundation.Mathematics.Vector3f backBottomRight
    • backTopRight

      private WildMagic.LibFoundation.Mathematics.Vector3f backTopRight
    • backTopLeft

      private WildMagic.LibFoundation.Mathematics.Vector3f backTopLeft
    • m_kCullPlane

      private WildMagic.LibFoundation.Mathematics.Plane3f m_kCullPlane
    • planeConstant

      private float planeConstant
    • m_kRenderer

      private WildMagic.LibGraphics.Rendering.Renderer m_kRenderer
    • kWorldInv

      private WildMagic.LibFoundation.Mathematics.Matrix4f kWorldInv
    • topFace

      private Vector<WildMagic.LibFoundation.Mathematics.Vector3f> topFace
    • bottomFace

      private Vector<WildMagic.LibFoundation.Mathematics.Vector3f> bottomFace
    • leftFace

      private Vector<WildMagic.LibFoundation.Mathematics.Vector3f> leftFace
    • rightFace

      private Vector<WildMagic.LibFoundation.Mathematics.Vector3f> rightFace
    • frontFace

      private Vector<WildMagic.LibFoundation.Mathematics.Vector3f> frontFace
    • backFace

      private Vector<WildMagic.LibFoundation.Mathematics.Vector3f> backFace
    • hyperStack

      private VolumeImage[] hyperStack
    • hyperstackColormap

      private WildMagic.LibGraphics.Rendering.Texture hyperstackColormap
  • Constructor Details

    • VolumeRayCast

      public VolumeRayCast(VolumeImage kImageA, VolumeImage kImageB)
      Creates a new VolumeRayCast object.
      Parameters:
      kImageA - the VolumeImage containing the data and textures for rendering.
      kVolumeImageB - second VolumeImage.
  • Method Details

    • CheckViewIntersection

      public void CheckViewIntersection(WildMagic.LibGraphics.Rendering.Renderer kRenderer, WildMagic.LibGraphics.SceneGraph.Culler kCuller)
      The volume data is rendered with a fragment (pixel) shader on the GPU. The shader is activated by rendering a volume proxy geometry, which is a cube that matches the volume bounding box. One problem with this technique for rendering volume data is that when the bounding-volume proxy geometry is clipped by the view-frustum near-plane the geometry is no longer rendered on the GPU and therefore the fragment shader is no longer activated. This causes the volume rendering to disappear as the user tries to zoom into it. This function automatically detects clipping of the volume proxy-geometry by the view-frustum near-plane as the camera moves into the volume. When clipping is detected, the algorithm generates a new triangle mesh by intersecting the near-plane with the original bounding-cube. The new triangle mesh serves as the volume proxy geometry. The result is the appearance of moving inside the volume as the user zooms the camera. The default cube is always the starting point for the algorithm, even if a non-cube shape is currently displayed as the volume proxy geometry.
      Parameters:
      kRenderer -
      kCuller -
    • setPlaneConstant

      public void setPlaneConstant(float _constant)
      Set the front the clipping plane constant
      Parameters:
      _constant - contant between 0 to 0.01;
    • CMPMode

      public void CMPMode()
      Display the volume in Composite mode.
    • CreateScene

      public void CreateScene()
      Called by the init() function. Creates and initialized the scene-graph.
      Parameters:
      eFormat - FrameBuffer.FormatType
      eDepth - FrameBuffer.DepthType
      eStencil - FrameBuffer.StencilType
      eBuffering - FrameBuffer.BufferingType
      eMultisampling - FrameBuffer.MultisamplingType
      iWidth - canvas width
      iHeight - canvas height
      arg0 - the GLCanvas
      kRenderer - the OpenGLRenderer.
    • reCreateScene

      public void reCreateScene(VolumeImage image)
    • reCreateScene

      public void reCreateScene(VolumeImage imageA, VolumeImage imageB)
    • dispose

      public void dispose(WildMagic.LibGraphics.Rendering.Renderer kRenderer)
      delete local memory.
      Overrides:
      dispose in class VolumeObject
    • DRRMode

      public void DRRMode()
      Display the volume in DDR mode.
    • getABBlend

      public float getABBlend()
    • GetClipEffect

      public VolumeClipEffect GetClipEffect()
      Return current clipping state.
      Returns:
      current clipping state.
    • GetGradientMagnitude

      public boolean GetGradientMagnitude()
    • GetMaterialState

      public WildMagic.LibGraphics.Rendering.MaterialState GetMaterialState()
      Called from the JPanelDisplay dialog. Gets the material properties for the VolumeShaderSUR (Surface and Composite Surface volume shaders.)
      Returns:
      material properties for the surface mode.
    • getMesh

      public WildMagic.LibGraphics.SceneGraph.TriMesh getMesh()
    • GetShaderEffect

      public VolumeShaderEffectMultiPass GetShaderEffect()
      Returns the VolumeShaderEffect.
      Returns:
      the VolumeShaderEffect.
    • GetTranslate

      public WildMagic.LibFoundation.Mathematics.Vector3f GetTranslate()
      Returns the translation vector.
      Overrides:
      GetTranslate in class VolumeObject
      Returns:
      the translation vector.
    • GetWorld

      public WildMagic.LibFoundation.Mathematics.Matrix4f GetWorld()
    • MIPMode

      public void MIPMode()
      Display the volume in MIP mode.
    • MULTIHISTOMode

      public void MULTIHISTOMode(boolean bOn)
      Display the volume in Multi-histo mode.
    • printProgram

      public void printProgram()
    • setHyperStack

      public void setHyperStack(VolumeImage[] images, WildMagic.LibGraphics.Rendering.Texture colormap)
    • setImageOn

      public void setImageOn(int which, boolean on)
    • getImageOn

      public boolean getImageOn(int which)
    • recreateShaderEffect

      public void recreateShaderEffect(WildMagic.LibGraphics.Rendering.Renderer kRenderer, WildMagic.LibGraphics.Rendering.Texture targetTexture)
    • releaseShaderEffect

      public void releaseShaderEffect(WildMagic.LibGraphics.Rendering.Renderer kRenderer)
    • ReloadVolumeShader

      public void ReloadVolumeShader(WildMagic.LibGraphics.Rendering.Renderer kRenderer)
      Reloads the VolumeShaderEffect current shader program.
      Parameters:
      kRenderer - the OpenGLRenderer object.
    • Render

      public void Render(WildMagic.LibGraphics.Rendering.Renderer kRenderer, WildMagic.LibGraphics.SceneGraph.Culler kCuller, boolean bPreRender, boolean bSolid)
      Render the object.
      Specified by:
      Render in class VolumeObject
      Parameters:
      kRenderer - the OpenGLRenderer object.
      kCuller - the Culler object.
    • SelfShadow

      public void SelfShadow(boolean bShadow)
      Enables/Disables self-shadowing in the Surface mode.
      Parameters:
      bShadow - shadow on/off.
    • setABBlend

      public void setABBlend(float fValue)
      Sets blending between imageA and imageB.
      Parameters:
      fValue - the blend value (0-1)
    • SetBackgroundColor

      public void SetBackgroundColor(WildMagic.LibFoundation.Mathematics.ColorRGBA kColor)
      Sets the background color.
      Parameters:
      kColor - new background color.
    • SetClip

      public void SetClip(int iWhich, float data, boolean bEnable)
      Sets axis-aligned clipping for the VolumeShaderEffect.
      Parameters:
      afClip - the clipping parameters for axis-aligned clipping.
    • SetClipArb

      public void SetClipArb(float[] afEquation, boolean bEnable)
      Sets arbitrary clipping for the VolumeShaderEffect.
      Parameters:
      afEquation - the arbitrary-clip plane equation.
    • SetClipArbInv

      public void SetClipArbInv(float[] afEquation, boolean bEnable)
      Sets arbitrary clipping for the VolumeShaderEffect.
      Parameters:
      afEquation - the arbitrary-clip plane equation.
    • SetClipEye

      public void SetClipEye(float[] afEquation, boolean bEnable)
      Sets eye clipping for the VolumeShaderEffect.
      Parameters:
      afEquation - the eye clipping equation.
    • SetClipEyeInv

      public void SetClipEyeInv(float[] afEquation, boolean bEnable)
      Sets inverse-eye clipping for the VolumeShaderEffect.
      Parameters:
      afEquation - the inverse-eye clipping equation.
    • SetClipSphere

      public void SetClipSphere(WildMagic.LibFoundation.Mathematics.Vector3f center, WildMagic.LibFoundation.Mathematics.Vector3f scale, float radius, boolean bEnable)
    • SetClipOBB

      public void SetClipOBB(WildMagic.LibFoundation.Mathematics.Vector3f center, WildMagic.LibFoundation.Mathematics.Vector3f scale, WildMagic.LibFoundation.Mathematics.Vector3f[] axes, float[] extents, boolean bEnable)
    • SetCustomBlend

      public void SetCustomBlend(int iBlendEquation, int iLogicOp, int iSrcBlend, int iDstBlend, WildMagic.LibFoundation.Mathematics.ColorRGBA kColor)
    • SetGradientMagnitude

      public void SetGradientMagnitude(boolean bShow)
      Enables/Disables Gradient Magnitude filter.
      Parameters:
      bShow - gradient magnitude filter on/off
    • SetLight

      public void SetLight(String kLightType, float[] afType)
      Sets lighting in the VolumeShaderEffect.
      Overrides:
      SetLight in class VolumeObject
      Parameters:
      kLightType - name of the light to set.
      afType - the type of light to set.
    • SetMaterialState

      public void SetMaterialState(WildMagic.LibGraphics.Rendering.MaterialState kMaterial)
      Called from the AdvancedMaterialProperties dialog. Sets the material properties for the VolumeShaderSUR (Surface and Composite Surface volume shaders.)
      Parameters:
      kMaterial - new material properties for the surface mode.
    • setRGBTA

      public void setRGBTA(ModelRGB RGBT)
    • setRGBTB

      public void setRGBTB(ModelRGB RGBT)
    • setVolumeBlend

      public void setVolumeBlend(float fBlend)
      Sets the blend factor for displaying the ray-cast volume with other objects in the scene.
      Parameters:
      fBlend - the blend factor for the ray-cast volume.
    • setVolumeSamples

      public int setVolumeSamples(float fSample)
    • SURFASTMode

      public void SURFASTMode()
      Display the volume in Surface mode.
    • SURMode

      public void SURMode()
      Display the volume in Composite Surface mode.
    • updateLevWidgetState

      public void updateLevWidgetState(Vector<ClassificationWidget> kLWS)
    • Box

      private WildMagic.LibGraphics.SceneGraph.TriMesh Box(int iXBound, int iYBound, int iZBound)
      Called by CreateBox. Creates the bounding-box proxy geometry (VertexBuffer, IndexBuffer).
      Parameters:
      iXBound - image x-extent.
      iYBound - image y-extent.
      iZBound - image z-extent.
      Returns:
      TriMesh, new geometry.
    • reCreateBox

      private WildMagic.LibGraphics.SceneGraph.TriMesh reCreateBox(int iXBound, int iYBound, int iZBound)
    • checkMeshPoints

      private void checkMeshPoints()
      Check that the currently loaded proxy geometry is the default cube, if it is not reload it onto the GPU.
    • computeIntersections

      private void computeIntersections()
      Compute the cube-plane intersection. Remove clipped points from each face of the cube that intersects the clipping-plane. Add the intersection points to clipped faces. This is done while maintaining the counter-clockwise ordering of the points on the cube faces.
    • CreateBox

      private void CreateBox()
      Called by CreateScene. Creates the bounding-box proxy geometry scene node.
    • cullBackBottomLeft

      private void cullBackBottomLeft()
      Creates a re-mapping of the cube corners so the back bottom left corner is at position 0 in the reorderedList. The other points are added to the list based on the cube connectivity.
    • cullBackBottomRight

      private void cullBackBottomRight()
      Creates a re-mapping of the cube corners so the back bottom right corner is at position 0 in the reorderedList. The other points are added to the list based on the cube connectivity.
    • cullBackTopLeft

      private void cullBackTopLeft()
      Creates a re-mapping of the cube corners so the back top left corner is at position 0 in the reorderedList. The other points are added to the list based on the cube connectivity.
    • cullBackTopRight

      private void cullBackTopRight()
      Creates a re-mapping of the cube corners so the back top right corner is at position 0 in the reorderedList. The other points are added to the list based on the cube connectivity.
    • cullFrontBottomLeft

      private void cullFrontBottomLeft()
      Creates a re-mapping of the cube corners so the front bottom left corner is at position 0 in the reorderedList. The other points are added to the list based on the cube connectivity.
    • cullFrontBottomRight

      private void cullFrontBottomRight()
      Creates a re-mapping of the cube corners so the front bottom right corner is at position 0 in the reorderedList. The other points are added to the list based on the cube connectivity.
    • cullFrontTopLeft

      private void cullFrontTopLeft()
      Creates a re-mapping of the cube corners so the front top left corner is at position 0 in the reorderedList. The other points are added to the list based on the cube connectivity.
    • cullFrontTopRight

      private void cullFrontTopRight()
      Creates a re-mapping of the cube corners so the front top right corner is at position 0 in the reorderedList. The other points are added to the list based on the cube connectivity.
    • cullPoints

      private void cullPoints(float[] clippedDistance)
      1. Determine which of the cube corners is the furthest along the negative z-direction (0,0,-1). This corner is clipped by the view-frustum and will serve and the starting corner in creating the new mesh surface.
      Parameters:
      clippedDistance -
    • fillBox

      private void fillBox(WildMagic.LibGraphics.SceneGraph.IndexBuffer pkIB)
      Generates the triangle -index array connectivity for the default cube, stores the index array in the input IndexBuffer.
      Parameters:
      pkIB -
    • fillBox

      private void fillBox(WildMagic.LibGraphics.SceneGraph.VertexBuffer pkVB)
      Fills in the values for the default cube. Writes the values into the input VertexBuffer. Fills in the position, color, and texture coordinates.
      Parameters:
      pkVB -
    • PreRender

      private void PreRender(WildMagic.LibGraphics.Rendering.Renderer kRenderer, WildMagic.LibGraphics.SceneGraph.Culler kCuller)
      PreRender renders the proxy geometry into the PBuffer texture.
      Parameters:
      kRenderer - the OpenGLRenderer object.
      kCuller - the Culler object.
    • retriangulate

      private void retriangulate(Vector<WildMagic.LibFoundation.Mathematics.Vector3f> intersectionPoints)
      Generates the new VertexBuffer and IndexBuffer for the retriangulated faces of the cube based on how the cube intersects with the clipping plane. Each of the faces: top, bottom, front, back, left, right have points listed in counter-clockwise order. Where the clipping plane intersects the face the clipped points have been removed and the new intersection points have been added -- always maintaining the ccw ordering of the points. This way we can automatically generate the triangle mesh by adding up the points and calculating the number of triangles per face. The input list represents the new face -- the one generated by the clip plane intersecting the cube.
      Parameters:
      intersectionPoints -