IsoSurface Rendering of an AR Representation

rlaramee
Class FromMRtoARcube

java.lang.Object
  |
  +--rlaramee.FromMRtoARcube

public class FromMRtoARcube
extends java.lang.Object

Description: The idea behind FromMRtoAR.java is to read a set of uniform resolution volume data stored as binary cubes and output in adaptive resolution represented cubes. Note that it is required that the input cubes must be sorted by octant in order for this program to succeed. Run the script FromASCIItoBinarySortCubeScript before running this program. The program fromMRtoAR.c does the same thing as this program but for ASCII files. Since we've increased I/O speed in java by reading binary data and not using serialization, we save time in the long run by skipping past the ASCII files altogether.

start date Mon 19 Mar '01

Version:
1.0
Author:
Robert S Laramee
See Also:

Field Summary
private  FileHandler fileHandler
           
private  short resolution
           
private  float threshold
           
private  int totalNumCubes
           
 
Constructor Summary
FromMRtoARcube()
          constructor
 
Method Summary
private  boolean areAboveThreshold(Cube[] siblingCubes)
          For now, the threshold is set simply by the different between the maximum and minimum scalar values.
private  FileHandler getFileHandler()
           
private  short getResolution()
           
private  float getThreshold()
           
private  int getTotalNumCubes()
           
static void main(java.lang.String[] args)
          Compile the program using:
private  int outputARcubes(java.lang.String inputFileName, java.lang.String outputFileName)
          This function writes the volume data in AR reprepresentation.
private  boolean parseCoordinates(Cube cube)
          This method parses the block number in the X,Y,Z directions It also tells the cube to set its vertices coordinate values
private  boolean parseDataVTK(Cube cube)
          This method parses the 8 data values.
private  boolean parseError(Cube cube)
          This method parses the error measure number
private  int read8Cubes(Cube[] cubes)
          A parent cube has 8 child cubes
private  int readBinaryCube(Cube cube)
           
private  void setFileHandler(FileHandler newFileHandler)
           
private  void setResolution(short newRes)
           
private  void setThreshold(float newVal)
           
private  void setTotalNumCubes(int newTotal)
           
private  boolean validRange(double value, double min, double max)
           
private  boolean validRange(double value, int min, int max)
           
private  int write8Cubes(Cube[] cubes)
           
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

fileHandler

private FileHandler fileHandler

threshold

private float threshold

totalNumCubes

private int totalNumCubes

resolution

private short resolution
Constructor Detail

FromMRtoARcube

public FromMRtoARcube()
constructor
Method Detail

getThreshold

private float getThreshold()
Returns:
the current threshold value

setThreshold

private void setThreshold(float newVal)
Parameters:
the - new threshold value

getTotalNumCubes

private int getTotalNumCubes()
Returns:
the total number of cubes in the volume

setTotalNumCubes

private void setTotalNumCubes(int newTotal)
Parameters:
the - total number of cubes in the volume

getFileHandler

private FileHandler getFileHandler()
Returns:
fileHandler this object's FileHandler

setFileHandler

private void setFileHandler(FileHandler newFileHandler)
Parameters:
newFileHandler - this object's FileHandler

getResolution

private short getResolution()
Returns:
the resolution of this cube

setResolution

private void setResolution(short newRes)
Parameters:
newRes - the resolution of this cube

outputARcubes

private int outputARcubes(java.lang.String inputFileName,
                          java.lang.String outputFileName)
This function writes the volume data in AR reprepresentation. Note, we have to read, test, and write cubes 8 at a time in order to generate a complete AR representation. Eight either stay or leave.

Parameters:
inputFileName - the name of the input file
outputFileName - the name of the output file
Returns:
the total number of cubes output

areAboveThreshold

private boolean areAboveThreshold(Cube[] siblingCubes)
For now, the threshold is set simply by the different between the maximum and minimum scalar values.

Parameters:
cubes - an array of 8 sibling cubes
Returns:
TRUE if they are within the threshold set by the user

read8Cubes

private int read8Cubes(Cube[] cubes)
A parent cube has 8 child cubes

Parameters:
cubes[8] - an array to store a cube structures
Returns:
the number of cubes read (should be 8)

readBinaryCube

private int readBinaryCube(Cube cube)
Parameters:
cube - the cube object we are populating values for
Returns:
1 if 1 cube was read from the input file

parseDataVTK

private boolean parseDataVTK(Cube cube)
                      throws java.io.IOException
This method parses the 8 data values.
             P3_____________P2   This is the cube representation
             /|            /|    for Bob's cube's.  It is the
            / |           / |    same as the VTK's.
   y     P7____________P6/  |    
   ^      |   |         |   |    
   |      |   |         |   |    
   |      |   |         |   |
   |--->  | P0|_________|___|P1
  /    x  |  /          |  /
 /        | /           | /
z         |_____________|/
         P4             P5

 
Parameters:
cube - a pointer to the current cube being read
Returns:
TRUE on success
Throws:
java.io.IOException -  

parseError

private boolean parseError(Cube cube)
                    throws java.io.IOException
This method parses the error measure number
Parameters:
cube - a pointer to the current cube being read
Returns:
TRUE on success
Throws:
java.io.IOException -  

parseCoordinates

private boolean parseCoordinates(Cube cube)
                          throws java.io.IOException
This method parses the block number in the X,Y,Z directions It also tells the cube to set its vertices coordinate values

Parameters:
cube - a pointer to the current cube being read
Returns:
TRUE on success
Throws:
java.io.IOException -  

write8Cubes

private int write8Cubes(Cube[] cubes)
Parameters:
cubes - an array of 8 cubes
Returns:
the total number of cubes output

validRange

private boolean validRange(double value,
                           int min,
                           int max)
Parameters:
value - the value to validate
min - the minimum allowable value
max - the maximum allowable value
Returns:
true if the value is in the proper range

validRange

private boolean validRange(double value,
                           double min,
                           double max)
Parameters:
value - the value to validate
min - the minimum allowable value
max - the maximum allowable value
Returns:
true if the value is in the proper range

main

public static void main(java.lang.String[] args)
Compile the program using:
 % javac -deprecation FromMRtoARcube.java
 

Start the program using:

 % java FromMRtoARcube  [input file] [xDim] [yDim] [zDim] [threshold] \
                   [output file] 
   e.g.
 % java FromMRtoARcube ../data/level6/headRes2cube.bin 2 2 2 0.01 > \
                   ../data/level6/headRes2AR010.ascii
 

Parameters:
args[0] - -the input data file name
args[1] - -the number of cubes along the x dimension
args[2] - -the number of cubes along the y dimension
args[3] - -the number of cubes along the z dimension
args[4] - -the threshold value that determines which cubes are "trimmed" from the representation
args[5] - -the output file name

IsoSurface Rendering of an AR Representation