VolumeJ
Class VJRenderer

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--VolumeJ.VJRenderer
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
VJIsosurfaceRender, VJRender, VJViewspaceRender

public abstract class VJRenderer
extends java.lang.Thread

VJRenderer class implements the context and support methods for Volume Rendering. Subclasses of VJRenderer have to implement the actual run() method. Available for the run() method by default:

 shader
 classifier
 interpolator
 m and mi, the transformation matrix and its inverse of the required view.
 v the Volume that is to be rendered
 width, height, depth the size of the volume in viewspace.
 ioffset, joffset, koffset the offsets of the volume in viewspace.
 pixels the viewport buffer
 
Copyright (c) 1999-2002, Michael Abramoff. All rights reserved.


Field Summary
protected  VJClassifier classifier
          Voxel classifier.
protected static int COLORINT
          Defines type of image the rendering is output to: color (as int).
protected  VJCutout cutout
           
protected  int depth
          Boundaries of viewspace volume (the viewport) in k,j,i space.
protected  java.lang.String description
           
protected  boolean doDepthCueing
           
protected  boolean doPerspective
           
protected  boolean doPixeltracing
          Pixel tracing variables.
protected static int GRAYBYTE
          Defines type of image the rendering is output to: grayscale.
protected  int height
          Boundaries of viewspace volume (the viewport) in k,j,i space.
protected  VJInterpolator interpolator
          Voxel interpolator.
protected  int ioffset
          Start of rays in viewspace.
protected  int joffset
          Start of rays in viewspace.
protected  int koffset
          Start of rays in viewspace.
protected  VJMatrix m
          Transformation matrix and inverse.
protected  java.lang.String message
           
protected  VJMatrix mi
          Transformation matrix and inverse.
protected  VJMatrix miLight
          Separate transformation matrix and inverse for the light.
protected  VJMatrix mLight
          Separate transformation matrix and inverse for the light.
protected  int outputType
          Type of image output by this renderer: GRAYBYTE or COLORINT.
protected  double pixelms
          Amount of ms per pixel spent in rendering loop.
protected  java.lang.Object pixels
          Image buffer, is a flat array of int's or byte's, dependent on outputType.
protected  boolean running
          Flag indicating whether this renderer is running.
protected  int sequenceNumber
           
protected  VJShader shader
          Surface shader.
protected  int tracei
           
protected  int tracej
           
protected  java.lang.String traceString
           
protected  Volume v
          Volume to be rendered (polymorphic).
protected  int width
          Boundaries of viewspace volume (the viewport) in k,j,i space.
 
Fields inherited from class java.lang.Thread
inheritableThreadLocals, MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY, threadLocals
 
Constructor Summary
VJRenderer(VJInterpolator interpolator, VJShader shader, VJClassifier classifier)
          Create a new default renderer with specified interpolator, shader and classifier.
 
Method Summary
 int[] defaultViewport()
          Get a default viewport automatically.
 VJClassifier getClassifier()
           
 VJInterpolator getInterpolator()
           
 java.lang.Object getPixels()
          Get the viewport pixel buffer.
 VJShader getShader()
           
 double getTimePerPixel()
           
 VJMatrix getTransformation()
           
 int[] getViewport()
          Get the size of the viewport.
 int getViewportHeight()
          Get the height of the viewport.
 int getViewportWidth()
          Get the width of the viewport.
 Volume getVolume()
          Get the volume in this renderer.
 void kill()
          The kill method is called when this renderer is to stop.
protected  void minmax()
          Calculate the extents of the volume to be rendered in view and objectspace.
protected  java.lang.Object newViewportBuffer()
           
protected  boolean onTrace(int i, int j)
           
 void run()
          To be overloaded, does nothing.
 void setClassifier(VJClassifier classifier)
           
 void setCutout(VJCutout cutout)
           
 void setDescription(java.lang.String description)
           
 void setInterpolator(VJInterpolator interpolator)
           
 void setMessage(java.lang.String message)
          Set the rendering message.
 void setOutputColor()
          Set the output to color.
 void setOutputGrayscale()
          Set the output to color.
protected  void setPixel(int pixel, int i, int j)
          Put color into the pixel array at i,j.
protected  void setPixel(VJAlphaColor pixel, int i, int j)
          Put the pixel into the pixel array at i,j.
 void setSequenceNumber(int sequenceNumber)
           
 void setShader(VJShader shader)
          The shader has changed.
 void setTransformation(VJMatrix m)
          Set the transformation matrix of the renderer to m.
 void setTransformation(VJMatrix m, VJMatrix mLight)
          Set the transformation matrix of the renderer to m and the special light transformation matrix to correct the light position (should not be influenced by e.g.
 void setViewport(int width, int height)
          Set the viewport to a specific size.
 void setVolume(Volume v)
          The volume has changed.
 void trace(int i, int j)
          Start pixeltracing for the i,j pixel in the viewport.
protected  void trace(java.lang.String s)
           
protected  void traceWrite()
           
 
Methods inherited from class java.lang.Thread
, activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

GRAYBYTE

protected static final int GRAYBYTE
Defines type of image the rendering is output to: grayscale.

COLORINT

protected static final int COLORINT
Defines type of image the rendering is output to: color (as int).

doPerspective

protected boolean doPerspective

doDepthCueing

protected boolean doDepthCueing

outputType

protected int outputType
Type of image output by this renderer: GRAYBYTE or COLORINT.

pixelms

protected double pixelms
Amount of ms per pixel spent in rendering loop.

sequenceNumber

protected int sequenceNumber

running

protected boolean running
Flag indicating whether this renderer is running.

m

protected VJMatrix m
Transformation matrix and inverse.

mi

protected VJMatrix mi
Transformation matrix and inverse.

mLight

protected VJMatrix mLight
Separate transformation matrix and inverse for the light.

miLight

protected VJMatrix miLight
Separate transformation matrix and inverse for the light.

classifier

protected VJClassifier classifier
Voxel classifier.

interpolator

protected VJInterpolator interpolator
Voxel interpolator.

shader

protected VJShader shader
Surface shader.

pixels

protected java.lang.Object pixels
Image buffer, is a flat array of int's or byte's, dependent on outputType.

cutout

protected VJCutout cutout

v

protected Volume v
Volume to be rendered (polymorphic).

width

protected int width
Boundaries of viewspace volume (the viewport) in k,j,i space.

height

protected int height
Boundaries of viewspace volume (the viewport) in k,j,i space.

depth

protected int depth
Boundaries of viewspace volume (the viewport) in k,j,i space.

ioffset

protected int ioffset
Start of rays in viewspace.

joffset

protected int joffset
Start of rays in viewspace.

koffset

protected int koffset
Start of rays in viewspace.

message

protected java.lang.String message

doPixeltracing

protected boolean doPixeltracing
Pixel tracing variables.

tracei

protected int tracei

tracej

protected int tracej

traceString

protected java.lang.String traceString

description

protected java.lang.String description
Constructor Detail

VJRenderer

public VJRenderer(VJInterpolator interpolator,
                  VJShader shader,
                  VJClassifier classifier)
           throws java.lang.IllegalArgumentException
Create a new default renderer with specified interpolator, shader and classifier. This renderer does nothing, since run() is not implemented.
Parameters:
interpolator - the interpolator that will interpolate VJValues from the voluem to be rendered.
shader - the VJShader that will be used for shading.
classifier - the VJClassifier that will be used for classifying.
Throws:
java.lang.IllegalArgumentException - if parameters not properly defined.
Method Detail

defaultViewport

public int[] defaultViewport()
Get a default viewport automatically.
Returns:
int[2] the width and height of the viewport.

setOutputColor

public void setOutputColor()
Set the output to color.

setOutputGrayscale

public void setOutputGrayscale()
Set the output to color.

setViewport

public void setViewport(int width,
                        int height)
Set the viewport to a specific size.
Parameters:
width - the width of the viewport.
height - the height of the viewport.

newViewportBuffer

protected java.lang.Object newViewportBuffer()

setPixel

protected void setPixel(int pixel,
                        int i,
                        int j)
Put color into the pixel array at i,j.
Parameters:
pixel - an int, which contains the composited pixel value.
i - the i-position in the pixel array.
j - the j-position in the pixel array.

setPixel

protected void setPixel(VJAlphaColor pixel,
                        int i,
                        int j)
Put the pixel into the pixel array at i,j.
Parameters:
pixel - a VJAlphaColor, which contains the composited pixel value.
i - the i-position in the pixel array.
j - the j-position in the pixel array.

setTransformation

public void setTransformation(VJMatrix m)
Set the transformation matrix of the renderer to m. This is used to transform object space coordinates to viewspace coordinates and vice-versa for the desired view. Keep a special transformation matrix and its inverse to compute the light position (which should not be influenced by aspect ratio changes). The volume needs to be set before calling this method. Shader needs to be set before calling this method.
Parameters:
m - the transformation matrix wanted.

setTransformation

public void setTransformation(VJMatrix m,
                              VJMatrix mLight)
Set the transformation matrix of the renderer to m and the special light transformation matrix to correct the light position (should not be influenced by e.g. aspect ratios or other transformations that are in m). This is used to transform object space coordinates to viewspace coordinates and vice-versa for the desired view. The volume needs to be set before calling this method. Shader also needs to be set before calling this method. A relatively expensive method since two inverses are computed.
Parameters:
m - the transformation matrix wanted.
mLight - the transformation matrix wanted for the light.

setMessage

public void setMessage(java.lang.String message)
Set the rendering message.
Parameters:
message - a String used for status updates, error messages etc.

setShader

public void setShader(VJShader shader)
The shader has changed. Reset the shader, objectify the light. Overload if you have to recompute a shading table.
Parameters:
shader - the new shader.

minmax

protected void minmax()
Calculate the extents of the volume to be rendered in view and objectspace. When you call this method, v, m and the viewport need to have been initialized!

run

public void run()
To be overloaded, does nothing. Should set running to true and check it.
Overrides:
run in class java.lang.Thread

kill

public void kill()
The kill method is called when this renderer is to stop. You can add wrapup method calls in this method.

setVolume

public void setVolume(Volume v)
The volume has changed. Reset the volume.
Parameters:
volume - the new volume.

getPixels

public java.lang.Object getPixels()
Get the viewport pixel buffer.
Returns:
pixels a flat array of ibt or byte containing the RGB or monochrome pixel array resepctively.

getViewport

public int[] getViewport()
Get the size of the viewport.
Returns:
an int[2] containg the width and height of the viewport.

getViewportWidth

public int getViewportWidth()
Get the width of the viewport.
Returns:
the width of the viewport.

getViewportHeight

public int getViewportHeight()
Get the height of the viewport.
Returns:
the height of the viewport.

getVolume

public Volume getVolume()
Get the volume in this renderer.
Returns:
v, the Volume to be rendered.

getTransformation

public VJMatrix getTransformation()

setInterpolator

public void setInterpolator(VJInterpolator interpolator)

getInterpolator

public VJInterpolator getInterpolator()

setClassifier

public void setClassifier(VJClassifier classifier)

getClassifier

public VJClassifier getClassifier()

getShader

public VJShader getShader()

setCutout

public void setCutout(VJCutout cutout)

trace

public void trace(int i,
                  int j)
Start pixeltracing for the i,j pixel in the viewport.
Parameters:
i - the x coordinate of the pixel in the viewport buffer
j - the y coordinate of the pixel in the viewport buffer

onTrace

protected boolean onTrace(int i,
                          int j)

trace

protected void trace(java.lang.String s)

traceWrite

protected void traceWrite()

getTimePerPixel

public double getTimePerPixel()

setSequenceNumber

public void setSequenceNumber(int sequenceNumber)

setDescription

public void setDescription(java.lang.String description)