Class FlythruRender

  • All Implemented Interfaces:
    com.sun.j3d.utils.behaviors.mouse.MouseBehaviorCallback, FlyThroughRenderInterface, FlyPathBehavior.Callback, ViewImageUpdateInterface, java.awt.event.ActionListener, java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.beans.PropertyChangeListener, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.event.ChangeListener

    public class FlythruRender
    extends SurfaceRender
    implements FlyThroughRenderInterface, FlyPathBehavior.Callback, com.sun.j3d.utils.behaviors.mouse.MouseBehaviorCallback, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener
    Virtual colonoscopy viewer. This class contains the static 'main' method to launch the application. This class is an Applet which means that it can be embedded in a browser or it can be attached to a MainFrame when executed as an application. The Applet contains a Canvas3D used for the 3D rendering of the colon surface data and for using the mouse and keyboard for maneuvering the view of the colon while moving through it.
    See Also:
    Serialized Form
    • Field Detail

      • serialVersionUID

        private static final long serialVersionUID
        Use serialVersionUID for interoperability.
        See Also:
        Constant Field Values
      • buffer

        short[] buffer
        DOCUMENT ME!
      • capScreenWidth

        int capScreenWidth
        DOCUMENT ME!
      • capScreenHeight

        int capScreenHeight
        DOCUMENT ME!
      • directory

        java.lang.String directory
        DOCUMENT ME!
      • extents

        int[] extents
        DOCUMENT ME!
      • fileType

        java.lang.String fileType
        DOCUMENT ME!
      • pixels

        int[] pixels
        DOCUMENT ME!
      • rendererProgressBar

        javax.swing.JProgressBar rendererProgressBar
        A local reference to the volume renderer frame's progress bar.
      • robot

        java.awt.Robot robot
        DOCUMENT ME!
      • imageCounter

        private int imageCounter
        DOCUMENT ME!
      • m_aiBranchIndexUnvisitedMax

        private int[] m_aiBranchIndexUnvisitedMax
        DOCUMENT ME!
      • m_aiBranchIndexUnvisitedMin

        private int[] m_aiBranchIndexUnvisitedMin
        This is the range of path samples for each branch that are unvisited.
      • m_aiMeshConnectivity

        private int[] m_aiMeshConnectivity
        DOCUMENT ME!
      • m_iLastSelectedBranchIndex

        private int m_iLastSelectedBranchIndex
        Keep track of the last branch that was selected (at a branch point).
      • m_kAnnotateList

        private FlyPathAnnotateList m_kAnnotateList
        This is for the collection of annotation points.
      • m_kAnnotatePointGroup

        private javax.media.j3d.Group m_kAnnotatePointGroup
        DOCUMENT ME!
      • m_kBranchConnectShape

        private javax.media.j3d.Shape3D m_kBranchConnectShape
        DOCUMENT ME!
      • m_kBranchPathShape

        private javax.media.j3d.Shape3D m_kBranchPathShape
        This is the Java3D geometry for the path.
      • m_kControlFrame

        private JPanelVirtualEndoscopySetup m_kControlFrame
        This is the control frame which may need to be updated as the view changes.
      • m_kFlyPathBehavior

        private FlyPathBehavior m_kFlyPathBehavior
        Keep track of the FlyPathBehavior because it knows about the view from the path.
      • m_kFlyPathGraphSamples

        private FlyPathGraphSamples m_kFlyPathGraphSamples
        This is the path extracted from the skeletonization.
      • m_kGeodesicGroup

        private javax.media.j3d.Group m_kGeodesicGroup
        DOCUMENT ME!
      • m_kMeanCurvaturesLUT

        private ModelLUT m_kMeanCurvaturesLUT
        DOCUMENT ME!
      • m_kMouseRotateBehavior

        private com.sun.j3d.utils.behaviors.mouse.MouseRotate m_kMouseRotateBehavior
        DOCUMENT ME!
      • m_kNormalColorPathUnvisited

        private javax.vecmath.Color3f m_kNormalColorPathUnvisited
        DOCUMENT ME!
      • m_kNormalColorPathVisited

        private javax.vecmath.Color3f m_kNormalColorPathVisited
        These are the colors to use when rendering the normal/selected branch that is unvisited/visited.
      • m_kOptions

        private FlythruRender.SetupOptions m_kOptions
        These are the setup options passed to the constructor which we need to keep track of in case we need to use them outside the constructor.
      • m_kPickCanvas

        private com.sun.j3d.utils.picking.PickCanvas m_kPickCanvas
        Used for picking.
      • m_kPointLight

        private javax.media.j3d.PointLight m_kPointLight
        DOCUMENT ME!
      • m_kSceneRoot

        private javax.media.j3d.BranchGroup m_kSceneRoot
        These are part of the scene and view.
      • m_kSelectColorPathUnvisited

        private javax.vecmath.Color3f m_kSelectColorPathUnvisited
        DOCUMENT ME!
      • m_kSelectColorPathVisited

        private javax.vecmath.Color3f m_kSelectColorPathVisited
        DOCUMENT ME!
      • m_kSkeleton

        private Skeleton3D m_kSkeleton
        This it skeletonization of the binary volume.
      • m_kSurface

        private ModelTriangleMesh m_kSurface
        This is the surface geometry and its properties.
      • m_kSurfaceGeometry

        private javax.media.j3d.IndexedGeometryArray m_kSurfaceGeometry
        DOCUMENT ME!
      • m_kSurfaceGeometryInfo

        private com.sun.j3d.utils.geometry.GeometryInfo m_kSurfaceGeometryInfo
        This is the Java3D geometry for the surface.
      • m_kSurfaceShape

        private javax.media.j3d.Shape3D m_kSurfaceShape
        DOCUMENT ME!
      • m_kUniverse

        private com.sun.j3d.utils.universe.SimpleUniverse m_kUniverse
        The simple universe contains a single canvas, a viewing platform, and a scene graph. The scene graph will contain all objects involved in the rendering.
      • m_kVolumeLayout

        private ModelImage3DLayout m_kVolumeLayout
        Describes the organization of the volume data in a linear array.
      • saveCounter

        private int saveCounter
        DOCUMENT ME!
      • currEventTime

        long currEventTime
        Current mouse press event time stamp.
      • prevEventTime

        long prevEventTime
        Previous mouse press event time stamp.
      • pressed

        private boolean pressed
        If any of the mouse move button pressed.
      • time

        private long time
        Time to wait for the next mouse event.
      • lookup

        public static int lookup
      • lookdown

        public static int lookdown
      • lookright

        public static int lookright
      • lookleft

        public static int lookleft
    • Constructor Detail

      • FlythruRender

        public FlythruRender​(ModelImage _kImage,
                             java.awt.GraphicsConfiguration _config,
                             ViewJFrameVolumeView _parentFrame)
        View which renders virtual endoscopy fly through of a binarized volume.
        Parameters:
        _kImage - ModelImage Contains the image data and its properties.
        _config - Graphics configuration reference.
        _parentFrame - ViewJFrameVolumeView reference. initial virtual endoscopy view.
    • Method Detail

      • addMesh

        public void addMesh​(ModelTriangleMesh kOld,
                            ModelTriangleMesh kNew)
        ReplaceMesh is used by the Geodesic when a mesh is cut. The original mesh is changed, but not deleted and no new mesh is added. The orginal mesh, kOld, is replced by the new mesh, kNew:
        Parameters:
        kOld - DOCUMENT ME!
        kNew - DOCUMENT ME!
      • dispose

        public void dispose()
        Override called when window is closed.
      • getBranchPathShape

        public javax.media.j3d.Shape3D getBranchPathShape()
        For displaying the Path in the surface renderer:
        Returns:
        Shape3D, the scaled FlyPath
      • getBranchState

        public java.lang.Object getBranchState()
        Specified by:
        getBranchState in interface FlyThroughRenderInterface
        Returns:
        the current BranchState from the FlyPatheBehavior class.
      • getGeodesicGroup

        public javax.media.j3d.Group getGeodesicGroup()
        Return access to the Group data member m_kGeodesicGroup so Geodesic object can draw on the triangle mesh:
        Returns:
        DOCUMENT ME!
      • getMeanCurvaturesLUT

        public ModelLUT getMeanCurvaturesLUT()
        Access the pseudocolor mapping specified to use when rendering the computed mean curvatures values for the specified surface.
        Returns:
        ModelLUT Defines the mapping of mean curvatures values to pseudocolor values.
      • getPathDist

        public float getPathDist()
        DOCUMENT ME!
        Returns:
        DOCUMENT ME!
      • getPickCanvas

        public com.sun.j3d.utils.picking.PickCanvas getPickCanvas()
        Get the pick canvas.
        Returns:
        pickCanvas pick canvas.
      • getPositionScaled

        public javax.vecmath.Point3f getPositionScaled()
        Scaled coordinates for the current position along the path for viewing.
        Returns:
        Point3f A new instance created which contains the path position coordinates, scaled to match the ModelTriangleMesh in JPanelSurface.
      • getSamplePosition

        public javax.vecmath.Point3f getSamplePosition()
        Return the interpolated sample coordinates in the volume of the current position along the path for viewing.
        Returns:
        Point3f A new instance created which contains the interpolated sample coordinates.
      • getSurface

        public ModelTriangleMesh getSurface()
        Access the surface to be rendered when moving along the path.
        Returns:
        ModelTriangleMesh Instance of the surface represented as a triangle mesh as specified in the setSurface method.
      • getSurfaceControl

        public javax.swing.JPanel getSurfaceControl()
        DOCUMENT ME!
        Returns:
        DOCUMENT ME!
      • getSurfaceCurvatures

        public ModelTriangleMeshCurvatures getSurfaceCurvatures()
        Access the computed curvatures for the specified triangle mesh surface.
        Returns:
        ModelTriangleMeshCurvatures Instance of the computed curvatures associated with the triangle mesh specifed in the setSurface method.
      • makeMove

        public void makeMove​(java.lang.String cmd)
        Description copied from interface: FlyThroughRenderInterface
        Passes move command from the JPanelFlythruMove to the FlyPathBehavior class.
        Specified by:
        makeMove in interface FlyThroughRenderInterface
        Parameters:
        cmd - move command.
      • mouseClicked

        public void mouseClicked​(java.awt.event.MouseEvent kMouseEvent)
        Implement MouseInterface abstract method.
        Specified by:
        mouseClicked in interface java.awt.event.MouseListener
        Parameters:
        kMouseEvent - MouseEvent Contains information about the particular mouse event.
      • mouseEntered

        public void mouseEntered​(java.awt.event.MouseEvent kMouseEvent)
        Implement MouseInterface abstract method.
        Specified by:
        mouseEntered in interface java.awt.event.MouseListener
        Parameters:
        kMouseEvent - MouseEvent Contains information about the particular mouse event.
      • mouseExited

        public void mouseExited​(java.awt.event.MouseEvent kMouseEvent)
        Implement MouseInterface abstract method.
        Specified by:
        mouseExited in interface java.awt.event.MouseListener
        Parameters:
        kMouseEvent - MouseEvent Contains information about the particular mouse event.
      • mousePressed

        public void mousePressed​(java.awt.event.MouseEvent event)
        Implement MouseInterface abstract method.
        Specified by:
        mousePressed in interface java.awt.event.MouseListener
        Parameters:
        kMouseEvent - MouseEvent Contains information about the particular mouse event.
      • mouseDragged

        public void mouseDragged​(java.awt.event.MouseEvent event)
        The mouseDragged event is used when the right mouse button press down and dragged to adjust the camera viewing direction.
        Specified by:
        mouseDragged in interface java.awt.event.MouseMotionListener
        Parameters:
        event - MouseEvent right mouse button press down and drag
      • mouseMoved

        public void mouseMoved​(java.awt.event.MouseEvent kMouseEvent)
        Specified by:
        mouseMoved in interface java.awt.event.MouseMotionListener
      • mouseReleased

        public void mouseReleased​(java.awt.event.MouseEvent event)
        Implement MouseInterface abstract method.
        Specified by:
        mouseReleased in interface java.awt.event.MouseListener
        Parameters:
        kMouseEvent - MouseEvent Contains information about the particular mouse event.
      • mouseWheelMoved

        public void mouseWheelMoved​(java.awt.event.MouseWheelEvent event)
        Mouse wheel event invoked from the middle mouse button roller. Rolling forward to track the fly-thru path in forward direction. Rolling backward to track the fly-thru path in backward direction.
        Specified by:
        mouseWheelMoved in interface java.awt.event.MouseWheelListener
        Parameters:
        event - mouse middle mouse roller event.
      • readImage

        public boolean readImage()
        DOCUMENT ME!
        Returns:
        DOCUMENT ME!
      • replaceMesh

        public void replaceMesh​(ModelTriangleMesh kOld,
                                ModelTriangleMesh kNew)
        ReplaceMesh is used by the Geodesic when a mesh is cut. The original mesh is changed, but not deleted and no new mesh is added. The orginal mesh, kOld, is replced by the new mesh, kNew:
        Parameters:
        kOld - DOCUMENT ME!
        kNew - DOCUMENT ME!
      • resetCounter

        public void resetCounter()
        DOCUMENT ME!
      • resetRenderAnnotateList

        public void resetRenderAnnotateList()
        DOCUMENT ME!
      • setCurrentState

        public void setCurrentState​(java.lang.Object _state)
        Set the current traversing branch.
        Specified by:
        setCurrentState in interface FlyThroughRenderInterface
        Parameters:
        _state - Object
      • setMeanCurvaturesLUT

        public void setMeanCurvaturesLUT​(ModelLUT kMeanCurvaturesLUT)
        Use the specified pseudocolors to render the computed mean curvatures for the previously specified mesh surface.
        Parameters:
        kMeanCurvaturesLUT - ModelLUT Defines the mapping of mean curvatures values to pseudocolor values. This may be null which is used to indicated that the mean curvatures are not to be rendered.
      • setRenderSurfaceColors

        public void setRenderSurfaceColors​(java.awt.Color _color)
        If the color LUT defined for mean curvature pseudocolor mapping is defined, then use it to reset the colors.
        Parameters:
        _color - DOCUMENT ME!
      • setSurface

        public void setSurface​(ModelTriangleMesh kSurface)
        Add the specified surface to the rendering.
        Parameters:
        kSurface - ModelTriangleMesh Surface represented as a triagle mesh.
      • setupRender

        public void setupRender​(ModelImage _kImage,
                                FlythruRender.SetupOptions kOptions)
        Setup flythru renderer.
        Parameters:
        _kImage - original model image reference.
        kOptions - setup options reference.
      • setupRenderControl

        public void setupRenderControl​(JPanelVirtualEndoscopySetup _control)
        DOCUMENT ME!
        Parameters:
        _control - DOCUMENT ME!
      • toggleWireframe

        public void toggleWireframe()
        Toggle between wireframe and filled polygon mode:
      • transformChanged

        public void transformChanged​(int iType,
                                     javax.media.j3d.Transform3D kTransform)
        MouseBehaviorCallback override. This method is called whenever any MouseBehavior-derived class causes a change to the transformation which it is controlling.
        Specified by:
        transformChanged in interface com.sun.j3d.utils.behaviors.mouse.MouseBehaviorCallback
        Overrides:
        transformChanged in class SurfaceRender
        Parameters:
        iType - will be one of ROTATE, TRANSLATE or ZOOM
        kTransform - the updated Transform3D controlled by the MouseBehavior
      • viewChanged

        public void viewChanged​(FlyPathBehavior kFlyPathBehavior,
                                int iEvent)
        Implementation of the FlyPathBehavior.Callback interface.
        Specified by:
        viewChanged in interface FlyPathBehavior.Callback
        Parameters:
        kFlyPathBehavior - reference to the MjFlyPathBehavior for which the view changed.
        iEvent - Bitmask identifies the event(s) which caused the view to change. Bitmask created from OR of EVENT_* defintions.
      • getHeight

        public int getHeight()
        Specified by:
        getHeight in interface FlyThroughRenderInterface
        Overrides:
        getHeight in class java.awt.Component
        Returns:
        the frame height.
      • getWidth

        public int getWidth()
        Specified by:
        getWidth in interface FlyThroughRenderInterface
        Overrides:
        getWidth in class java.awt.Component
        Returns:
        the frame width.
      • resetRenderBranchConnect

        protected void resetRenderBranchConnect()
        Called any time a change has been made to a new branch so that the connection between the branch and its parent can be rendered.
      • resetRenderBranchPath

        protected void resetRenderBranchPath()
        Called any time the position along the current curve changes and the color of the curve needs to change to show what has been visited.
      • resetRenderScene

        protected void resetRenderScene()
        Called any time the scene needs to be regenerated.
      • resetRenderSurface

        protected void resetRenderSurface()
        Called whenever any of the rendering properties of the surface are modified.
      • resetRenderSurfaceColors

        protected void resetRenderSurfaceColors()
        If the color LUT defined for mean curvature pseudocolor mapping is defined, then use it to reset the colors.
      • resetRenderSurfaceConnectivity

        protected void resetRenderSurfaceConnectivity()
        Resets the portion of the surface to be rendered based on the current triangle connectivity information.
      • createBranchConnectGeometry

        private javax.media.j3d.LineArray createBranchConnectGeometry​(int iBranch)
        Get the geometry to be used for rendering the connection of the specified branch to its parent branch.
        Parameters:
        iBranch - Index which identifies the branch.
        Returns:
        LineArray instance that can be attached to a Shape3D node for rendering
      • createBranchPathGeometry

        private javax.media.j3d.LineStripArray createBranchPathGeometry​(int iBranch)
        Get the geometry to be used for rendering the path of the specified branch.
        Parameters:
        iBranch - Index which identifies the branch.
        Returns:
        LineStripArray instance that can be attached to a Shape3D node for rendering
      • createBranchPathGeometryScaled

        private javax.media.j3d.LineStripArray createBranchPathGeometryScaled​(int iBranch)
        Get the geometry to be used for rendering the path of the specified branch.
        Parameters:
        iBranch - Index which identifies the branch.
        Returns:
        LineStripArray instance that can be attached to a Shape3D node for rendering.

        The LineStripArray coordinates are scaled to match the ModelTriangleMesh in JPanelSurface.

      • createDirectory

        private void createDirectory()
        Create flythru directory to save the captured images from AVI recorder.