Class VoxelDraw

java.lang.Object
  |
  +--VoxelDraw

public class VoxelDraw
extends java.lang.Object


Constructor Summary
VoxelDraw(java.lang.String filename)
          Construct an object with volume origin at 0,0,0 and a field origin specified by fieldMins.
VoxelDraw(java.lang.String filename, float[] fieldSizes, int[] volumeSizes, int tileSize)
          Constrict an object with volume and field sizes with origins at 0,0,0.
 
Method Summary
static void assert(boolean flag, java.lang.String msg)
          Make sure that the condition parameter is true.
 int averageColors(int c1, int c2)
          Average two rgba color values
 void checkDataIntegrity()
          Verifies assertions on the data
 void closeVolume()
          Finalize the volume after rendering.
static int color4f(float r, float g, float b, float a)
          Returns an rgba value specified by the normalized color value (range: 0.0-1.0).
static int color4i(int r, int g, int b, int a)
          Returns an rgba value specified by the given color components (range: 0-255).
 int convertRGB(int argb)
          Convert a java default argb color to a volumetric rgba value.
 void drawMesh(int zOffset)
          Draw the mesh to the voxel canvas.
 void drawTrack(Track t, int sampleRate, int zOffset)
          Draw track line, sampling the vertical slices according the sampleRate.
 void drawTracks(int zOffset)
          Draw the tracks to the voxel canvas.
 void loadConfig()
          Initialize properties from the config file.
static void main(java.lang.String[] args)
          Set up the site bounds and draw the track and mesh objects.
 int mapXValue(float fx)
          Map an x field coordinate to an x volume coordinate.
 int mapYValue(float fy)
          Map a y field coordinate to a y volume coordinate.
 int mapZValue(float fz)
          Map a z field coordinate to a z volume coordinate.
 void openVolume()
          Prepare the volume for rendering.
static void p(java.lang.String msg)
          Provide a shortcut for outputing status messages without newlines.
static void pn(java.lang.String msg)
          Provide a shortcut for outputing status messages with newlines.
 void printFieldBounds()
          Print a list of the field bounds to standard output.
 void printVolumeBounds()
          Print a list of the volume bounds to standard output.
 void renderObjects()
          Render the objects specified in the cfg file.
 void setFieldGeometry(float[] fieldSizes)
          Initialize a field geometry with origin at 0,0,0.
 void setFieldGeometry(float[] fieldMins, float[] fieldMaxs)
          Initialize a field geometry with an origin at fieldMins.
 void setFieldVoxel(float fx, float fy, float fz, int color)
          Set a voxel to the specified color using field values
 void setVolumeGeometry(int[] volumeSizes)
          Initialize a volume geometry with origin at 0,0,0.
 void setVolumeGeometry(int[] volumeMins, int[] volumeMaxs)
          Initialize a volume geometry with an origin at volumeMins (not yet supported).
 void setVolumeSource(java.lang.String filename)
          Specify a source for the volume to be drawn to.
 void setVolumeVoxel(int x, int y, int z, int color)
          Set a voxel to the specified color using volume coordinates
static void testPlanes1(java.lang.String filename)
          Perform a simple unmapped, equi-sampled planar test.
static void testPlanes2(java.lang.String filename)
          Perform a simple mapped, sub-sampled planar test.
static void testPlanes3(java.lang.String filename)
          Perform a mapped, sub-sampled planar test.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VoxelDraw

public VoxelDraw(java.lang.String filename,
                 float[] fieldSizes,
                 int[] volumeSizes,
                 int tileSize)
Constrict an object with volume and field sizes with origins at 0,0,0.
Parameters:
filename - the name of the voxel canvas file
fieldSizes - the dimensions of the field size
volumeSizes - the dimensions of the voxel canvas
tileSize - the size of the 3-D tif tiles

VoxelDraw

public VoxelDraw(java.lang.String filename)
Construct an object with volume origin at 0,0,0 and a field origin specified by fieldMins.
Parameters:
filename - the name of the voxel canvas file
Method Detail

setVolumeSource

public void setVolumeSource(java.lang.String filename)
Specify a source for the volume to be drawn to.
Parameters:
filename - the name of the voxel canvas file

setVolumeGeometry

public void setVolumeGeometry(int[] volumeSizes)
Initialize a volume geometry with origin at 0,0,0.
Parameters:
volumeSizes - the dimensions of the voxel canvas

setFieldGeometry

public void setFieldGeometry(float[] fieldSizes)
Initialize a field geometry with origin at 0,0,0.
Parameters:
fieldSizes - the dimensions of the field size

setVolumeGeometry

public void setVolumeGeometry(int[] volumeMins,
                              int[] volumeMaxs)
Initialize a volume geometry with an origin at volumeMins (not yet supported).
Parameters:
volumeMins - the volume origin
volumeMaxs - the maximum coordinates of the volume space

setFieldGeometry

public void setFieldGeometry(float[] fieldMins,
                             float[] fieldMaxs)
Initialize a field geometry with an origin at fieldMins.
Parameters:
fieldMins - the field origin
fieldMaxs - the maximum field values

printFieldBounds

public void printFieldBounds()
Print a list of the field bounds to standard output.

printVolumeBounds

public void printVolumeBounds()
Print a list of the volume bounds to standard output.

checkDataIntegrity

public void checkDataIntegrity()
Verifies assertions on the data

mapXValue

public final int mapXValue(float fx)
Map an x field coordinate to an x volume coordinate.
Parameters:
fx - the x field value

mapYValue

public final int mapYValue(float fy)
Map a y field coordinate to a y volume coordinate.
Parameters:
fy - the y field value

mapZValue

public final int mapZValue(float fz)
Map a z field coordinate to a z volume coordinate.
Parameters:
fz - the z field value

assert

public static final void assert(boolean flag,
                                java.lang.String msg)
Make sure that the condition parameter is true.
Parameters:
flag - result of the condition
message - to print, if the flag is false

pn

public static final void pn(java.lang.String msg)
Provide a shortcut for outputing status messages with newlines.
Parameters:
msg - the msg to print to stderr

p

public static final void p(java.lang.String msg)
Provide a shortcut for outputing status messages without newlines.
Parameters:
msg - the msg to print with no newline

openVolume

public final void openVolume()
                      throws java.io.IOException
Prepare the volume for rendering.
Throws:
java.io.IOException - if the file cannot be opening for reading and writing

closeVolume

public final void closeVolume()
                       throws java.io.IOException
Finalize the volume after rendering.
Throws:
java.io.IOException - if the file cannot be closed

setFieldVoxel

public final void setFieldVoxel(float fx,
                                float fy,
                                float fz,
                                int color)
                         throws java.lang.Exception
Set a voxel to the specified color using field values
Parameters:
fx - the x field coordinate
fy - the y field coordinate
fx - the x field coordinate
color - the rgba color value to set at the mapped volume location
Throws:
java.lang.Exception - if the voxel cannot be set

setVolumeVoxel

public final void setVolumeVoxel(int x,
                                 int y,
                                 int z,
                                 int color)
                          throws java.lang.Exception
Set a voxel to the specified color using volume coordinates
Parameters:
x - the x volume coordinate
y - the y volume coordinate
z - the z volume coordinate
color - the rgba color value to set at the given volume location
Throws:
java.lang.Exception - if the voxel cannot be set

color4f

public static final int color4f(float r,
                                float g,
                                float b,
                                float a)
Returns an rgba value specified by the normalized color value (range: 0.0-1.0).
Parameters:
r - - the red value
g - - the green value
b - - the blue value
a - - the alpha value

color4i

public static final int color4i(int r,
                                int g,
                                int b,
                                int a)
Returns an rgba value specified by the given color components (range: 0-255).
Parameters:
r - - the red value
g - - the green value
b - - the blue value
a - - the alpha value

testPlanes1

public static final void testPlanes1(java.lang.String filename)
                              throws java.lang.Exception
Perform a simple unmapped, equi-sampled planar test.

testPlanes2

public static final void testPlanes2(java.lang.String filename)
                              throws java.lang.Exception
Perform a simple mapped, sub-sampled planar test.

testPlanes3

public static final void testPlanes3(java.lang.String filename)
                              throws java.lang.Exception
Perform a mapped, sub-sampled planar test.

drawTrack

public final void drawTrack(Track t,
                            int sampleRate,
                            int zOffset)
                     throws java.lang.Exception
Draw track line, sampling the vertical slices according the sampleRate.
Parameters:
t - the track to draw
sampleRate - rate to sample the track at
Throws:
java.lang.Exception - if the track can't be drawn

drawTracks

public final void drawTracks(int zOffset)
Draw the tracks to the voxel canvas.

drawMesh

public final void drawMesh(int zOffset)
Draw the mesh to the voxel canvas.

averageColors

public int averageColors(int c1,
                         int c2)
Average two rgba color values
Parameters:
c1 - a rgba color value
c2 - a rgba color value

convertRGB

public final int convertRGB(int argb)
Convert a java default argb color to a volumetric rgba value.
Parameters:
the - argb value to convert

loadConfig

public void loadConfig()
Initialize properties from the config file.

renderObjects

public void renderObjects()
Render the objects specified in the cfg file.

main

public static void main(java.lang.String[] args)
Set up the site bounds and draw the track and mesh objects.
Parameters:
args - the command lines args