Class ShearWarpRenderer

  • Direct Known Subclasses:
    ShearWarpColor, ShearWarpIntensity

    public abstract class ShearWarpRenderer
    extends Renderer
    The base class renderer to support shear-warp rendering. See the document ShearWarpRendering.pdf for a detailed description of the renderer architecture.
    • Field Detail

      • m_aaaasEncode

        protected short[][][][] m_aaaasEncode
        encoding of voxels based on transparent runs.
      • m_aaasVolumeEncode

        protected short[][][] m_aaasVolumeEncode
        DOCUMENT ME!
      • m_aafBox

        protected float[][] m_aafBox
        DOCUMENT ME!
      • m_aafM

        protected float[][] m_aafM
        DOCUMENT ME!
      • m_aaiIndex

        protected int[][] m_aaiIndex
        permutations that just store voxel indices.
      • m_aasSliceEncode

        protected short[][] m_aasSliceEncode
        DOCUMENT ME!
      • m_afA

        protected float[] m_afA
        DOCUMENT ME!
      • m_afB

        protected float[] m_afB
        DOCUMENT ME!
      • m_afShear

        protected float[] m_afShear
        for resampling a slice.
      • m_afOffset

        protected float[] m_afOffset
        for resampling a slice.
      • m_aiBound

        protected int[] m_aiBound
        Parallel viewing model. Camera direction is always (0,0,1). The volume image and bounding box axes, center at origin, columns are direction, up, right. The matrix m_aafM[][] is for inverse warping.
      • m_iQuantity

        protected int m_iQuantity
        Parallel viewing model. Camera direction is always (0,0,1). The volume image and bounding box axes, center at origin, columns are direction, up, right. The matrix m_aafM[][] is for inverse warping.
      • m_aiClipMin

        protected int[] m_aiClipMin
        for clipping.
      • m_aiClipMax

        protected int[] m_aiClipMax
        for clipping.
      • m_aiCurrentI

        protected int[] m_aiCurrentI
        DOCUMENT ME!
      • m_aiInterC

        protected int[] m_aiInterC
        intermediate image indicating that the number of times each pixels is processed.
      • m_aiSliceBound

        protected int[] m_aiSliceBound
        DOCUMENT ME!
      • m_aiSliceMin

        protected int[] m_aiSliceMin
        DOCUMENT ME!
      • m_aiSliceMax

        protected int[] m_aiSliceMax
        DOCUMENT ME!
      • m_asSkip

        protected short[] m_asSkip
        support for skipping opaque intermediate pixels.
      • m_bDoEncodeSkip

        protected boolean m_bDoEncodeSkip
        flag set by derived class that uses encoding and skipping.
      • m_fInv255

        protected float m_fInv255
        DOCUMENT ME!
      • m_iI0

        protected int m_iI0
        Temporary quantities used in the inner loop of resampleSingle(). These exist since Java does not allow you to pass references to variables to allow more than one to change on return from a function call.
      • m_iSIndex

        protected int m_iSIndex
        Temporary quantities used in the inner loop of resampleSingle(). These exist since Java does not allow you to pass references to variables to allow more than one to change on return from a function call.
      • m_iInterIndex

        protected int m_iInterIndex
        Temporary quantities used in the inner loop of resampleSingle(). These exist since Java does not allow you to pass references to variables to allow more than one to change on return from a function call.
      • m_iPixel

        protected int m_iPixel
        Temporary quantities used in the inner loop of resampleSingle(). These exist since Java does not allow you to pass references to variables to allow more than one to change on return from a function call.
      • m_iInterBound

        protected int m_iInterBound
        intermediate 2D image supporting quantities.
      • m_iInterBoundM1

        protected int m_iInterBoundM1
        intermediate 2D image supporting quantities.
      • m_iInterQuantity

        protected int m_iInterQuantity
        intermediate 2D image supporting quantities.
      • m_iInterOffset

        protected int m_iInterOffset
        DOCUMENT ME!
      • m_iPermute

        protected int m_iPermute
        the current permutation of the voxel indices (0, 1, or 2).
      • m_iSliceQuantity

        protected int m_iSliceQuantity
        DOCUMENT ME!
      • m_iSlice

        protected int m_iSlice
        DOCUMENT ME!
      • m_kP00

        protected javax.vecmath.Point3f m_kP00
        To avoid memory reallocations. These are used in the bilinearly interpolation of a 2x2 block of voxels in the current slice. The Pij are vertex positions. The MatColorij are the material colors of the voxels. The Cij are the final dynamically lit colors of the voxels.
      • m_kP01

        protected javax.vecmath.Point3f m_kP01
        DOCUMENT ME!
      • m_kP10

        protected javax.vecmath.Point3f m_kP10
        DOCUMENT ME!
      • m_kP11

        protected javax.vecmath.Point3f m_kP11
        DOCUMENT ME!
      • m_kPosition

        protected javax.vecmath.Point3f m_kPosition
        DOCUMENT ME!
    • Constructor Detail

      • ShearWarpRenderer

        public ShearWarpRenderer​(ModelImage kImage,
                                 int iRBound,
                                 int[] aiRImage)
        Create a renderer.
        Parameters:
        kImage - the 3D image
        iRBound - the dimension of the square 2D renderer image
        aiRImage - The rendered image data stored in row-major order. Each integer pixel represents an RGB color in the format B | (G .
    • Method Detail

      • composite

        public void composite​(int iDS)
        The top level rendering call. This function calls beforeResampleAll, resampleAll, and mapIntermediateToFinal, all virtual functions that are implemented in derived classes.
        Parameters:
        iDS - The number of slices to increment during the resampling phase. The value should be one or larger. If one, all slices of the volume data are resampled. If two, only every other slice is resampled. An input larger than one is used to allow fast rendering during rotation of the volume data. Once the rotation terminates, a composite with input of one should be called.
      • disposeLocal

        public void disposeLocal()
        Disposes of image memory and associated objects.
        Overrides:
        disposeLocal in class Renderer
      • getAxis

        public javax.vecmath.Vector3f getAxis​(int i)
        Read the current axis at index i.
        Specified by:
        getAxis in class Renderer
        Parameters:
        i - the axis index (0, 1, or 2)
        Returns:
        the current axis vector at index i
      • getAxis

        public void getAxis​(int i,
                            javax.vecmath.Vector3f kAxis)
        Read the current axis at index i.
        Parameters:
        i - the axis index (0, 1, or 2)
        kAxis - the new axis vector 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.
        Specified by:
        rotateBy in class Renderer
        Parameters:
        kAxisAngle - the axis and angle formulation for the rotation
      • 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:
        rotateFrameBy in class Renderer
        Parameters:
        transform - The transform and its matrix by which to rotate the image.
      • 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
      • setParallel

        public void setParallel​(boolean bParallel)
        Change the camera model.
        Overrides:
        setParallel in class Renderer
        Parameters:
        bParallel - true for a parallel camera, false for a perspective camera
      • setXBoundNeg

        public void setXBoundNeg​(float value)
        Setup the X Negative clipping plane position.
        Specified by:
        setXBoundNeg in class Renderer
        Parameters:
        value - position of the X negative clip slider.
      • setXBoundPos

        public void setXBoundPos​(float value)
        Setup the X positive clipping plane position.
        Specified by:
        setXBoundPos in class Renderer
        Parameters:
        value - position of the X positive clip slider.
      • setYBoundNeg

        public void setYBoundNeg​(float value)
        Setup the Y Negative clipping plane position.
        Specified by:
        setYBoundNeg in class Renderer
        Parameters:
        value - position of the Y negative clip slider.
      • setYBoundPos

        public void setYBoundPos​(float value)
        Setup the Y positive clipping plane position.
        Specified by:
        setYBoundPos in class Renderer
        Parameters:
        value - positin of the Y positve clip slider.
      • setZBoundNeg

        public void setZBoundNeg​(float value)
        Setup the Z negative clipping plane position.
        Specified by:
        setZBoundNeg in class Renderer
        Parameters:
        value - position of the Z negative clip slider.
      • setZBoundPos

        public void setZBoundPos​(float value)
        Setup the Z positive clipping plane position.
        Specified by:
        setZBoundPos in class Renderer
        Parameters:
        value - position of the Z positive clip slider.
      • mapIntermediateToFinal

        protected abstract void mapIntermediateToFinal()
        Map the intermediate images to the final color image. This is a stub for derived classes. This function must be implemented in at least one class in a derivation chain in order for that class to be considered non-abstract.
      • fromFloat

        protected static final byte fromFloat​(float fValue)
        Convert a 32-bit float to a 'byte' that represents an unsigned 8-bit integer (uint8). This is provided to allow 'byte' to represent a color in [0,255], the latter range not supported by Java since it has no unsigned integer types.
        Parameters:
        fValue - a float value in [0.0f,256.0f)
        Returns:
        the corresponding uint8 value
      • fromInt

        protected static final byte fromInt​(int iValue)
        Convert a 32-bit integer (int32) to a 'byte' that represents an unsigned 8-bit integer (uint8). This is provided to allow 'byte' to represent a color in [0,255], the latter range not supported by Java since it has no unsigned integer types.
        Parameters:
        iValue - an int32 value
        Returns:
        the corresponding uint8 value
      • toFloat

        protected static final float toFloat​(byte cValue)
        Convert a 'byte' that represents an unsigned 8-bit integer (uint8) to a 32-bit float. This is provided to allow 'byte' to represent a color in [0,255], the latter range not supported by Java since it has no unsigned integer types.
        Parameters:
        cValue - a uint8 value
        Returns:
        the corresponding float value in [0.0f,255.0f]
      • toInt

        protected static final int toInt​(byte cValue)
        Convert a 'byte' that represents an unsigned 8-bit integer (uint8) to a signed 32-bit integer (int32). This is provided to allow 'byte' to represent a color in [0,255], the latter range not supported by Java since it has no unsigned integer types.
        Parameters:
        cValue - a uint8 value
        Returns:
        the corresponding int32 value
      • beforeResampleAll

        protected void beforeResampleAll​(int k0,
                                         int k1,
                                         int k2)
        This is a callback to be executed before resampleAll is executed. The idea is to initialize the necessary parameters needed for the shear warp resampling of the volume data. The actual shear parameters are computed based on the orientation of the bounding box of the volume data. The permuted slice bounds, index set, and encoding table are selected based on the input permutation. The skip array is initialized to zero since before rendering, all intermediate pixels are transparent. Derived classes may provide additional initializations as needed.

        Each one of the indices is a permutation; either one of (0,1,2), (1,2,0), (2,0,1).

        Parameters:
        k0 - Index to m_aiBound, a value of 0, 1 or 2.
        k1 - Index to m_aiBound, a value of 0, 1 or 2.
        k2 - Index to m_aiBound, a value of 0, 1 or 2.
      • beforeResampleSingle

        protected void beforeResampleSingle()
        This is a callback to be executed before resampleSingle is executed. The bilinear interpolation coefficients are computed here and vary with the single, active slice. The offset into the intermediate image is also computed since this also varies with the active slice. If encoding of transparent data has occurred in the renderer constructor, then the current slice of the encoding table is initialized for use by resampleSingle.
      • computeEncode

        protected void computeEncode​(int k0,
                                     int k1,
                                     int k2,
                                     byte[] acChannel)
        Calculate the encoding table for the specified permutation. See the comments for initializeEncodeSkip. Because bilinear interpolation is used, 2x2 blocks of voxels in the current slice must be analyzed for transparency. The 2x2 block is tagged as non-transparent if and only if at least one of the voxels is non-transparent.

        Each one of the indices is a permutation; either one of (0,1,2), (1,2,0), (2,0,1).

        Parameters:
        k0 - Index to m_aiBound, a value of 0, 1 or 2.
        k1 - Index to m_aiBound, a value of 0, 1 or 2.
        k2 - Index to m_aiBound, a value of 0, 1 or 2.
        acChannel - The blue channel for intensity renderers or the alpha channel for color renderers.
      • computePositions

        protected final void computePositions​(int i0,
                                              int i1,
                                              int i2)
        Compute the vertex positions for the four voxels in the current slice to be bilinearly interpolated.
        Parameters:
        i0 - the current permuted indices of the upper left voxel in the 2x2 block of voxels in the slice
        i1 - DOCUMENT ME!
        i2 - DOCUMENT ME!
      • finalize

        protected void finalize()
                         throws java.lang.Throwable
        Calls disposeLocal of this class to ensure this class nulls the references to global class variables so that memory will be recovered.
        Overrides:
        finalize in class Renderer
        Throws:
        java.lang.Throwable - DOCUMENT ME!
      • initializeEncodeSkip

        protected void initializeEncodeSkip​(byte[] acChannel)
        Calculate the encoding of the specified channel. The tables calculated by this function is used to skip transparent voxels during the resampling phase. This leads to a significant performance improvement for data sets that have a relatively large number of transparent voxels. Each table corresponds to one of the three permutations of the image indices. The active permutation is determined by the composite function based on the orientation of the bounding box of the volume data.
        Parameters:
        acChannel - the blue channel for intensity renderers or the alpha channel for color renderers
      • resampleAll

        protected void resampleAll​(int iDS)
        Resample all the slices for the current permuted volume data. This is a stub for derived classes. This function must be implemented by at least one class in a derivation chain in order for that class to be considered non-abstract.
        Parameters:
        iDS - The number of slices to increment during the resampling phase. The value should be one or larger. If one, all slices of the volume data are resampled. If two, only every other slice is resampled. An input larger than one is used to allow fast rendering during rotation of the volume data. Once the rotation terminates, a composite with input of one should be called.
      • resampleSingle

        protected void resampleSingle()
        Resample a single slice of the permuted volume data. This is a stub for derived classes. This function must be implemented in at least one class in a derivation chain in order for that class to be considered non-abstract.
      • skipToNonopaque

        protected boolean skipToNonopaque​(int i1,
                                          short[] asIndex)
        An array is maintained that keeps track of opaque intermediate pixels during the resampling phase. Whenever pixels become opaque, they can be skipped if revisited later in the resampling. As runs of pixels become opaque on a scan line, skipping the run can greatly increase the speed of rendering. This function is called in resampleSingle by all the renderer classes taking advantage of opacity skipping.
        Parameters:
        i1 - the current slice index of the current permuted index set
        asIndex - the skip array for the current scan line of the slice
        Returns:
        The return value is 'true' if and only if there is another nonopaque pixel to be processed. If 'true', then m_iI0, m_iInterIndex, and m_iPixel contain values that are needed for later calculations in resampleSingle. The variable m_iInterIndex stores the offset into the intermediate and skip arrays for the current nonopaque pixel. The variable m_iPixel stores the offset into the volume data for the current nonopaque voxel. The variable m_iI0 is one of the indices for the volume data and is only needed in the MjLightingRenderer class for computing the voxel position from the permuted indices.
      • updateSkip

        protected void updateSkip()
        After the compositing step in resampleSingle, the intensity (for gray scale) or alpha value (for color) might become its maximum value. In this case, the intermediate pixel is opaque. The skip array must be updated so that this pixel is skipped if revisited later.