IsoSurface Rendering of an AR Representation

rlaramee
Class FromASCIItoBinarySortCube

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

public class FromASCIItoBinarySortCube
extends java.lang.Object

Description The FromASCIItoBinarySortCube object reads the input file. The input file stores cubes of data in ASCII representing 3D volume data. The reader sorts and saves the input data in binary format to a file.

start date Tue 20 Feb 01

Version:
2.0
Author:
Robert S Laramee
See Also:


Field Summary
private  ASCIIcubeParser asciiCubeParser
           
private  Cube[] cubeArray
           
private  boolean debug
           
private  FileHandler fileHandler
           
private  Memory memory
           
private  byte sortLevel
           
 
Constructor Summary
FromASCIItoBinarySortCube(byte level)
           
 
Method Summary
private  int computeArrayIndexOfOneLevelByOctant(Cube cube, int currentOffset)
           
private  ASCIIcubeParser getASCIIcubeParser()
           
private  Cube[] getCubeArray()
           
private  Cube getCubeAtArrayIndex(int i)
           
private  FileHandler getFileHandler()
           
private  byte getSortLevel()
           
static void main(java.lang.String[] args)
          The main() method is what starts the sorting
 boolean run(java.lang.String inputFileName, java.lang.String outputFileName, int dimensionLength)
          The run() function starts the ASCII Cubes Reader.
private  boolean setASCIIcubeParser(ASCIIcubeParser acp)
           
private  boolean setCubeArray(Cube[] ca)
           
private  boolean setCubeArrayIndex(Cube cube, int i)
           
private  boolean setFileHandler(FileHandler newFileHandler)
           
private  boolean setSortLevel(byte newLevel)
           
private  boolean sortCubeByOctant(Cube cube)
           
private  int thisLevelOffsetByOctant(byte level, byte octant)
          The cube array is ordered by octants within levels.
private  boolean writeBinaryCube(Cube cube)
           
private  int writeCubeArray(java.lang.String outputFileName)
          This writes out all the cubes in the array to the given output file
private  boolean writeCubeUsingSerialization(Cube cube)
           
 
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

asciiCubeParser

private ASCIIcubeParser asciiCubeParser

memory

private Memory memory

cubeArray

private Cube[] cubeArray

debug

private boolean debug

sortLevel

private byte sortLevel
Constructor Detail

FromASCIItoBinarySortCube

public FromASCIItoBinarySortCube(byte level)
Parameters:
level - the level of the cubes we are saving
Method Detail

getSortLevel

private byte getSortLevel()
Returns:
sortLevel the level of cubes being sorted

setSortLevel

private boolean setSortLevel(byte newLevel)
Parameters:
sortLevel - the level of cubes being sorted

getFileHandler

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

setFileHandler

private boolean setFileHandler(FileHandler newFileHandler)
Parameters:
newFileHandler - this object's FileHandler
Returns:
TRUE if the set was successful

getASCIIcubeParser

private ASCIIcubeParser getASCIIcubeParser()
Returns:
asciiCubeParser this object's ASCIIcubeParser

setASCIIcubeParser

private boolean setASCIIcubeParser(ASCIIcubeParser acp)
Parameters:
acp - this object's ASCIIcubeParser
Returns:
TRUE if the set was successful

getCubeArray

private Cube[] getCubeArray()
Returns:
cubeArray the array that stores the cubes

setCubeArray

private boolean setCubeArray(Cube[] ca)
Parameters:
ca - an array that stores the cubes
Returns:
TRUE if successful

getCubeAtArrayIndex

private Cube getCubeAtArrayIndex(int i)
Parameters:
index - an index into the cube array
Returns:
Cube the cube object at the given array index

setCubeArrayIndex

private boolean setCubeArrayIndex(Cube cube,
                                  int i)
Parameters:
cube - the cube being stored in the array
i - an array index
Returns:
TRUE if the cube array was set

run

public boolean run(java.lang.String inputFileName,
                   java.lang.String outputFileName,
                   int dimensionLength)
The run() function starts the ASCII Cubes Reader.

Parameters:
inputFileName - the name of the input file to read
outputFileName - the name of the output file to write
dimensionLength - the length of each x,y,z dimension (should be improved)
Returns:
TRUE on success

sortCubeByOctant

private boolean sortCubeByOctant(Cube cube)
Parameters:
cube - the cube to do our sorting on
Returns:
TRUE if the cube was sorted successfully

computeArrayIndexOfOneLevelByOctant

private int computeArrayIndexOfOneLevelByOctant(Cube cube,
                                                int currentOffset)
Parameters:
cube - the cube whose array index we are computing
currentOffset - the offset into the array of cubes thus far
Returns:
index the correct offset into the array of cubes

thisLevelOffsetByOctant

private int thisLevelOffsetByOctant(byte level,
                                    byte octant)
The cube array is ordered by octants within levels. For example, all of the cubes that lie in octant 0 at level 6 are in array indices
 [0 to (64^3 - 1)].
 
all of the cubes that lie in octant 1 at level 5 are in and are children of child 0 at level 6 are in array indices
 [ (0 * (64^3 - 1)) +  
   (1 * 32^3 to 2 * (32^3 - 1) ]
 
etc.
        dimensions in    dimensions in  
 level   block space    coordinate space   level scale
 -----  -------------   -----------------  -----------
  7       1 x 1 x 1     128 x 128 x 128    128^3
  6       2 x 2 x 2      64 x 64 x 64       64^3
  5       4 x 4 x 4      32 x 32 x 32       32^3
  4       8 x 8 x 8      16 x 16 x 16       16^3
  3      16 x 16 x 16     8 x 8 x 8          8^3
  2      32 x 32 x 32     4 x 4 x 4          4^3 
  1      64 x 64 x 64     2 x 2 x 2          2^3
  0     128 x 128 x 128   1 x 1 x 1          1^3
 

Parameters:
level - level in the octree
octant - the octant at that level
Returns:
int the index into the sorted array that the cube belongs in

writeCubeArray

private int writeCubeArray(java.lang.String outputFileName)
This writes out all the cubes in the array to the given output file

Parameters:
outputFileName - the name of the file to write the cubes too
Returns:
writeCount the number of cubes actaully printed

writeBinaryCube

private boolean writeBinaryCube(Cube cube)
Parameters:
cube - the cube being saved
Returns:
TRUE if the cube was written

writeCubeUsingSerialization

private boolean writeCubeUsingSerialization(Cube cube)
Parameters:
cube - the cube being saved
Returns:
TRUE if the cube was written

main

public static void main(java.lang.String[] args)
The main() method is what starts the sorting

Parameters:
inputFileName - the name of the input file
level - the level that the cubes are in

IsoSurface Rendering of an AR Representation