IsoSurface Rendering of an AR Representation

rlaramee
Class BinaryCubeReader

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

public class BinaryCubeReader
extends java.lang.Object

Description: This program is supposed to read binary cube objects and add them to the Octree

start date Sat 6 May 2000

Version:
2.0
Author:
Robert S Laramee
See Also:

Field Summary
private  ASCIIcubeParser asciiCubeParser
           
private  boolean binaryFormat
          are we reading binary data?
private  boolean breakOut
           
private  byte dataSet
          which data set -either HEAD or KNEE
private  boolean debug
           
private  FileHandler fileHandler
           
private  short finestCubeResolution
           
private  boolean floatFormat
          are we reading float or cube data?
private  FromFloatToCube fromFloatToCube
          to read files of floats only (as opposed to cubes)
private  Octree octree
           
private  short representation
          are we reading an MR or AR representation?
 
Constructor Summary
BinaryCubeReader(short cubeResolution, boolean binaryFormat, boolean floatFormat, short rep, byte dataSet, byte numVariates)
           
 
Method Summary
 boolean addNode(Cube cube, short cubeResolution)
          Called from this.readCubes() and FromFloatToCube.addRowOfCubes()
private  ASCIIcubeParser getASCIIcubeParser()
           
private  boolean getBinaryFormat()
           
private  boolean getBreakOut()
           
 byte getDataSet()
          Called from this class as well as from FromFloatToCube
private  FileHandler getFileHandler()
           
private  short getFinestCubeResolution()
           
private  boolean getFloatFormat()
           
 FromFloatToCube getFromFloatToCube()
           
 Octree getOctree()
           
private  short getRepresentation()
           
static void main(java.lang.String[] args)
          The main() method can be used for testing.
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  Cube readBinaryCube(byte level)
          This
private  int readCubes(short cubeResolution)
           
private  Cube readCubeUsingSerialization()
           
private  int readResolution(short resolution)
          At this point, we already know we are reading only one file's (each resolution is in it's own file) worth of data.
 Octree run()
          The run() function starts the Binary Cube Reader.
private  boolean setASCIIcubeParser(ASCIIcubeParser acp)
           
private  void setBinaryFormat(boolean trueOrFalse)
           
private  void setBreakOut(boolean trueOrFalse)
           
private  void setDataSet(byte set)
           
private  boolean setFileHandler(FileHandler fh)
           
private  void setFinestCubeResolution(short newResolution)
           
private  void setFloatFormat(boolean trueOrFalse)
           
 void setFromFloatToCube(FromFloatToCube fftc)
           
 boolean setOctree(Octree newOctree)
           
private  void setRepresentation(short rep)
           
private  boolean throwAway(Cube cube)
          This method filters out unnecessary cubes.
private  boolean validRange(double value, double min, double max)
           
private  boolean validRange(double value, int min, int max)
           
 
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

fromFloatToCube

private FromFloatToCube fromFloatToCube
to read files of floats only (as opposed to cubes)

asciiCubeParser

private ASCIIcubeParser asciiCubeParser

octree

private Octree octree

breakOut

private boolean breakOut

debug

private boolean debug

finestCubeResolution

private short finestCubeResolution

binaryFormat

private boolean binaryFormat
are we reading binary data?

floatFormat

private boolean floatFormat
are we reading float or cube data?

representation

private short representation
are we reading an MR or AR representation?

dataSet

private byte dataSet
which data set -either HEAD or KNEE
Constructor Detail

BinaryCubeReader

public BinaryCubeReader(short cubeResolution,
                        boolean binaryFormat,
                        boolean floatFormat,
                        short rep,
                        byte dataSet,
                        byte numVariates)
Parameters:
cubeResolution - the finest resolution of cube data we are are reading
binaryFormat - TRUE if we are reading data in binary format
binaryFormat - TRUE if we are reading data as floats (as opposed to cubes)
rep - an AR (or MR) representation of the volume data
dataSet - either Constant.HEAD , Constant.LOBSTER , or Constant.KNEE
numVariates - the number of variates in the data set
Method Detail

getFromFloatToCube

public FromFloatToCube getFromFloatToCube()
Returns:
the object that reads floats and outputs cubes

setFromFloatToCube

public void setFromFloatToCube(FromFloatToCube fftc)
Parameters:
the - object that reads floats and outputs cubes

getOctree

public Octree getOctree()
Returns:
octree -the octree

setOctree

public boolean setOctree(Octree newOctree)
Parameters:
newOctree - a new octree

getFinestCubeResolution

private short getFinestCubeResolution()
Returns:
finestCubeResolution the finest resolution of cube data we are reading

setFinestCubeResolution

private void setFinestCubeResolution(short newResolution)
Parameters:
the - level of cubes we are reading
Returns:
TRUE if set() was successful

getFileHandler

private FileHandler getFileHandler()
Returns:
fileHander -the FileHandler object

setFileHandler

private boolean setFileHandler(FileHandler fh)
Parameters:
fh - a FileHandler object
Returns:
TRUE if set() was successful.

getASCIIcubeParser

private ASCIIcubeParser getASCIIcubeParser()
Returns:
asciiCubeParser the ASCIIcubeParser object

setASCIIcubeParser

private boolean setASCIIcubeParser(ASCIIcubeParser acp)
Parameters:
acp - an ASCIIcubeParser object
Returns:
TRUE if set() was successful.

getBreakOut

private boolean getBreakOut()
Returns:
TRUE if we are to break out of a loop

setBreakOut

private void setBreakOut(boolean trueOrFalse)
Parameters:
TRUE - if we are to break out of a loop

getBinaryFormat

private boolean getBinaryFormat()
Returns:
TRUE if we are reading the data in binary format

setBinaryFormat

private void setBinaryFormat(boolean trueOrFalse)
Parameters:
TRUE - if we are reading the data in binary format

getFloatFormat

private boolean getFloatFormat()
Returns:
TRUE if we are reading the data as a set of floats (as opposed to cubes)

setFloatFormat

private void setFloatFormat(boolean trueOrFalse)
Parameters:
TRUE - if we are reading the data as a set of floats (as opposed to cubes)

getDataSet

public byte getDataSet()
Called from this class as well as from FromFloatToCube

Returns:
the data set we are reading

setDataSet

private void setDataSet(byte set)
Parameters:
dataSet - either Constant.HEAD , Constant.KNEE , Constant.LOBSTER , or Constant.TEST .

getRepresentation

private short getRepresentation()
Returns:
the representation we are reading

setRepresentation

private void setRepresentation(short rep)
Parameters:
the - representation we are reading

run

public Octree run()
The run() function starts the Binary Cube Reader.

We have to decide which file to read:

  1. How many files are we reading?
    1 for MR, < 1 for AR
  2. Which representation are we reading?
    Just pass this along to the file handler.
  3. Which data set are we reading?
    Just pass this along to the file handler
  4. Are we reading a file full of floats or cubes?
    Must be cubes for AR, just pass this along to the file handler.
  5. Are we reading a binary or ASCII file?
    Just pass that along to the file handler.

Returns:
octree -a reference to the Octree [null on failure]

readResolution

private int readResolution(short resolution)
At this point, we already know we are reading only one file's (each resolution is in it's own file) worth of data.

Parameters:
the - resolution we are reading
Returns:
readCount the number of cubes (or floats) read

readCubes

private int readCubes(short cubeResolution)
Parameters:
cubeResolution - the resolution of data we are reading

addNode

public boolean addNode(Cube cube,
                       short cubeResolution)
Called from this.readCubes() and FromFloatToCube.addRowOfCubes()

Parameters:
cube - the cube we are adding to the octree
Returns:
TRUE if the cube was added

throwAway

private boolean throwAway(Cube cube)
This method filters out unnecessary cubes. We are going to throw away all cube at the finest level of resolution that have 8 equal scalar vertex values. An isosurface cannot pass through these cubes so they do no make any contribution and take up memory we need.

This is an attempt to level a full MR representation of a 128^3 data set.

We put in a test for an MR representation only since these cubes could be present in a complete AR representation. In a complete AR representation cubes can only come in groups of 8.

However, this will not work as implemented since Octree.addNodeFromBottom() counts on cubes being read in, in sorted order.

Parameters:
the - cube that we are checking
Returns:
TRUE if we should throwAway the given cube

readBinaryCube

private Cube readBinaryCube(byte level)
This
Returns:
cube -the cube read from the 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 -  

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

readCubeUsingSerialization

private Cube readCubeUsingSerialization()
Returns:
cube -the cube read from the file

main

public static void main(java.lang.String[] args)
The main() method can be used for testing.

Parameters:
inputFile - an input file name to read binary cube data from
level - the level of resolution the cubes are

IsoSurface Rendering of an AR Representation