IsoSurface Rendering of an AR Representation

rlaramee
Class MarchingCubes

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

public class MarchingCubes
extends java.lang.Object

Description: Marching Cubes is a filter that takes as input a volume [e.g., 3D structured point set] and generates on output one or more isosurfaces. One or more contour values must be specified to generate the isosurface(s). The marching cubes algorithm in The Visualization Toolkit let's you specify a min/max scalar range and the number of contours to generate a series of evenly spaced contour values.

start date Tue 27 April 1999

Version:
1.0
Author:
Robert S Laramee
See Also:

Field Summary
private  Octree octree
           
private  boolean skipBranch
          TRUE if we are to skip a branch in the octree
private  IsoSurface surface
           
 
Constructor Summary
MarchingCubes(Octree tree)
          constructor
 
Method Summary
 IsoSurface execute(float isoValue)
          execute() The basic marching cubes algorithm is this:
 short generateTopologicalIndex(Cube cube, double isoValue)
          Here's a cube that contains the isoValue, so let's compute the topolical index for the Marching Cubes Cases lookup table [Note: Could optimize this function using bitwise OR operator and enumerating a CASE_MASK]
 byte[] getEdgeIntersections(short index)
          This method was written so that only the MarchingCubes object collaborates with the MarchingCubesCases object.
 Octree getOctree()
          This is called from IsoSurface.computeVertex() in order to get a hold of the octree to add a new vertex to the triangle vertex list.
 boolean getSkipBranch()
           
 IsoSurface getSurface()
           
private  void printStats(IsoSurface surface)
           
 boolean processCube(OctreeNode node, double isoValue)
           processCube() is called from MachingCubes.execute() and IsoSurface.inspectNeighbors()
 void setOctree(Octree tree)
           
 boolean setSkipBranch(boolean trueOrFalse)
           
 void setSurface(IsoSurface isoSurface)
           
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

octree

private Octree octree

surface

private IsoSurface surface

skipBranch

private boolean skipBranch
TRUE if we are to skip a branch in the octree
Constructor Detail

MarchingCubes

public MarchingCubes(Octree tree)
constructor

Parameters:
tree - a reference to the Octree
Method Detail

getOctree

public Octree getOctree()
This is called from IsoSurface.computeVertex() in order to get a hold of the octree to add a new vertex to the triangle vertex list.

setOctree

public void setOctree(Octree tree)
Parameters:
tree - a new Octree

getSurface

public IsoSurface getSurface()
Returns:
surface this object's isosurface

setSurface

public void setSurface(IsoSurface isoSurface)
Parameters:
isoSurface - a new isoSurface

getSkipBranch

public boolean getSkipBranch()
Returns:
TRUE if we are to skip a branch in the octree traversal

setSkipBranch

public boolean setSkipBranch(boolean trueOrFalse)
Parameters:
trueOrFalse - TRUE if we are to skip a branch in the octree traversal
Returns:
TRUE if the set() was successful

getEdgeIntersections

public byte[] getEdgeIntersections(short index)
This method was written so that only the MarchingCubes object collaborates with the MarchingCubesCases object.

Parameters:
index - an index into the MarchingCubesCases table
Returns:
-a set of edge intersections, the edges that the isosurface intersects

execute

public IsoSurface execute(float isoValue)
execute() The basic marching cubes algorithm is this:
 FOR EACH CUBE
    Compare isovalue with minimum and maximum cube vertices
    Generate Marching Cube Case index
    Interpolate vertex values
    Generate triangle(s)
 

We have to inspect neighbors as we traverse the octree. If a coarser resolution neighbor is an octree node we've already traversed, we'll have to "back up" to that coarser resolution node (or before). Perhaps back up to their ancestor node. It looks as if all we have to do is go back to the coarser resolution nodes and reset the direction to Constant.FROMABOVE And don't forget, the coarser resolution neighbor may have already produced triangles.

Parameters:
isoValue - the isosurface value to render
Returns:
isoSurface -the new Isosurface (to hand off to the drawing program)

printStats

private void printStats(IsoSurface surface)
Parameters:
surface - the current isosurface object

processCube

public boolean processCube(OctreeNode node,
                           double isoValue)
processCube() is called from MachingCubes.execute() and IsoSurface.inspectNeighbors()

We are only going to process a cube:

 IF the cube is at the level specified by the user AND
 IF the minimum <= isoValue <= maximum
 

Although, we have have to change this procedure because we may want to render non-leaf nodes.

Parameters:
node - the OctreeNode we are deciding on
isoValue - the isosurface value to render
Returns:
TRUE if we are to process this octree node

generateTopologicalIndex

public short generateTopologicalIndex(Cube cube,
                                      double isoValue)
Here's a cube that contains the isoValue, so let's compute the topolical index for the Marching Cubes Cases lookup table [Note: Could optimize this function using bitwise OR operator and enumerating a CASE_MASK]

Parameters:
cube - the cube we are processing
isoValue - the isosurface value to render
Returns:
the topological index used by the MC algorithm

IsoSurface Rendering of an AR Representation