edu.jhu.cs.cisst.algorithms.geometry.surface
Class IsoSurfaceGenerator

java.lang.Object
  extended by edu.jhu.ece.iacl.jist.pipeline.AbstractCalculation
      extended by edu.jhu.cs.cisst.algorithms.geometry.surface.IsoSurfaceGenerator

public class IsoSurfaceGenerator
extends AbstractCalculation

The IsoSurface Generator generates an iso-surface using either the marching-cubes or marching-tetrahedral algorithm. The patent for marching-cubes has expired as of 2005 and is now available for use in the public domain. This implementation is a reimplementation of a C++ version with enhancements that preserve mesh connectivity.

Author:
Cory Bloyd

Nested Class Summary
protected  class IsoSurfaceGenerator.EdgeSplit
          The Class EdgeSplit is a container to describe a level set crossing point.
static class IsoSurfaceGenerator.Method
          The Iso-surface generation method
protected  class IsoSurfaceGenerator.Triangle
          The Class Triangle stores vertex ids.
static class IsoSurfaceGenerator.Winding
          The winding order for triangle vertices.
 
Field Summary
protected static float[][] a2fEdgeDirection
          a2fEdgeDirection lists the direction vector (vertex1-vertex0) for each edge in the cube.
protected static int[][] a2fVertexOffset
          Lists the positions, relative to vertex 0, of each of the 8 vertices of a cube.
protected static int[][] a2iEdgeConnection
          Lists the index of the endpoint vertices for each of the 12 edges of the cube.
protected static int[][] a2iTetrahedronEdgeConnection
          Lists the index of the endpoint vertices for each of the 6 edges of the tetrahedron.
protected static int[][] a2iTetrahedronsInACube
          Lists the index of verticies from a cube that made up each of the six tetrahedrons within the cube.
protected static int[][] a2iTetrahedronTriangles
          For each of the possible vertex states listed in aiTetrahedronEdgeFlags there is a specific triangulation of the edge intersection points.
protected static int[][] a2iTriangleConnectionTable
          For each of the possible vertex states listed in aiCubeEdgeFlags there is a specific triangulation of the edge intersection points.
protected static int[] aiCubeEdgeFlags
          For any edge, if one vertex is inside of the surface and the other is outside of the surface then the edge intersects the surface For each of the 8 vertices of the cube can be two possible states : either inside or outside of the surface For any cube the are 2^8=256 possible sets of vertex states This table lists the edges intersected by the surface for all 256 possible vertex states There are 12 edges.
protected static int[] aiTetrahedronEdgeFlags
          For any edge, if one vertex is inside of the surface and the other is outside of the surface then the edge intersects the surface For each of the 4 vertices of the tetrahedron can be two possible states : either inside or outside of the surface For any tetrahedron the are 2^4=16 possible sets of vertex states This table lists the edges intersected by the surface for all 16 possible vertex states There are 6 edges.
protected  int cols
          The slices.
protected  float isoLevel
          The target iso-level.
protected  IsoSurfaceGenerator.Method method
          The is-surface generation method.
protected  float resX
          The resolution in X.
protected  float resY
          The resolution in Y.
protected  float resZ
          The resolution in Z.
protected  int rows
          The slices.
protected  int slices
          The slices.
protected  boolean useResolutions
          The use image resolutions flag.
protected  int vertCount
          The vertex count.
protected  float[][][] volMat
          The volume matrix
protected  IsoSurfaceGenerator.Winding winding
          The winding order.
 
Fields inherited from class edu.jhu.ece.iacl.jist.pipeline.AbstractCalculation
monitor
 
Constructor Summary
IsoSurfaceGenerator()
          Instantiates a new iso surface generator.
IsoSurfaceGenerator(AbstractCalculation parent)
          Instantiates a new iso surface generator.
 
Method Summary
protected  int clampColumn(int c)
          Clamp column index.
protected  int clampRow(int r)
          Clamp row.
protected  int clampSlice(int s)
          Clamp slice.
protected  float fGetOffset(Point3i v1, Point3i v2)
          Interpolate position along edge.
static java.lang.String getVersion()
           
protected  void marchTetrahedral(java.util.Hashtable<java.lang.Long,IsoSurfaceGenerator.EdgeSplit> splits, java.util.LinkedList<IsoSurfaceGenerator.Triangle> triangles, Point3i[] pasTetrahedronPosition)
          March tetrahedral.
 void setMethod(IsoSurfaceGenerator.Method method)
          Sets the iso-surface generation method.
 void setUseResolutions(boolean value)
          Sets the use image resolutions flag.
 void setWinding(IsoSurfaceGenerator.Winding winding)
          Sets the winding order.
 EmbeddedSurface solve(ImageDataFloat vol, float isoLevel)
          Solve for iso-surface
protected  void triangulateUsingMarchingCubes(java.util.Hashtable<java.lang.Long,IsoSurfaceGenerator.EdgeSplit> splits, java.util.LinkedList<IsoSurfaceGenerator.Triangle> triangles, int x, int y, int z)
          Triangulate using marching cubes.
protected  void triangulateUsingMarchingTetrahedrals(java.util.Hashtable<java.lang.Long,IsoSurfaceGenerator.EdgeSplit> splits, java.util.LinkedList<IsoSurfaceGenerator.Triangle> triangles, int x, int y, int z)
          Triangulate using marching tetrahedrals.
 
Methods inherited from class edu.jhu.ece.iacl.jist.pipeline.AbstractCalculation
add, addTotalUnits, decrementCompletedUnits, decrementCompletedUnits, getCompletedUnits, getCurrentLabel, getCurrentProgress, getLabel, getPerformance, getProgress, getTotalUnits, incrementCompletedUnits, incrementCompletedUnits, isCompleted, markCompleted, reset, setCompletedUnits, setCompletedUnits, setLabel, setMonitor, setTotalUnits
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

method

protected IsoSurfaceGenerator.Method method
The is-surface generation method.


winding

protected IsoSurfaceGenerator.Winding winding
The winding order.


isoLevel

protected float isoLevel
The target iso-level.


vertCount

protected int vertCount
The vertex count.


volMat

protected float[][][] volMat
The volume matrix


rows

protected int rows
The slices.


cols

protected int cols
The slices.


slices

protected int slices
The slices.


resX

protected float resX
The resolution in X.


resY

protected float resY
The resolution in Y.


resZ

protected float resZ
The resolution in Z.


useResolutions

protected boolean useResolutions
The use image resolutions flag.


a2fVertexOffset

protected static final int[][] a2fVertexOffset
Lists the positions, relative to vertex 0, of each of the 8 vertices of a cube.


a2iEdgeConnection

protected static final int[][] a2iEdgeConnection
Lists the index of the endpoint vertices for each of the 12 edges of the cube.


a2fEdgeDirection

protected static final float[][] a2fEdgeDirection
a2fEdgeDirection lists the direction vector (vertex1-vertex0) for each edge in the cube.


a2iTetrahedronEdgeConnection

protected static final int[][] a2iTetrahedronEdgeConnection
Lists the index of the endpoint vertices for each of the 6 edges of the tetrahedron.


a2iTetrahedronsInACube

protected static final int[][] a2iTetrahedronsInACube
Lists the index of verticies from a cube that made up each of the six tetrahedrons within the cube.


aiCubeEdgeFlags

protected static final int[] aiCubeEdgeFlags
For any edge, if one vertex is inside of the surface and the other is outside of the surface then the edge intersects the surface For each of the 8 vertices of the cube can be two possible states : either inside or outside of the surface For any cube the are 2^8=256 possible sets of vertex states This table lists the edges intersected by the surface for all 256 possible vertex states There are 12 edges. For each entry in the table, if edge #n is intersected, then bit #n is set to 1


a2iTriangleConnectionTable

protected static final int[][] a2iTriangleConnectionTable
For each of the possible vertex states listed in aiCubeEdgeFlags there is a specific triangulation of the edge intersection points. a2iTriangleConnectionTable lists all of them in the form of 0-5 edge triples with the list terminated by the invalid value -1. For example: a2iTriangleConnectionTable[3] list the 2 triangles formed when corner[0] and corner[1] are inside of the surface, but the rest of the cube is not. I found this table in an example program someone wrote long ago. It was probably generated by hand


aiTetrahedronEdgeFlags

protected static final int[] aiTetrahedronEdgeFlags
For any edge, if one vertex is inside of the surface and the other is outside of the surface then the edge intersects the surface For each of the 4 vertices of the tetrahedron can be two possible states : either inside or outside of the surface For any tetrahedron the are 2^4=16 possible sets of vertex states This table lists the edges intersected by the surface for all 16 possible vertex states There are 6 edges. For each entry in the table, if edge #n is intersected, then bit #n is set to 1


a2iTetrahedronTriangles

protected static final int[][] a2iTetrahedronTriangles
For each of the possible vertex states listed in aiTetrahedronEdgeFlags there is a specific triangulation of the edge intersection points. a2iTetrahedronTriangles lists all of them in the form of 0-2 edge triples with the list terminated by the invalid value -1.

Constructor Detail

IsoSurfaceGenerator

public IsoSurfaceGenerator()
Instantiates a new iso surface generator.


IsoSurfaceGenerator

public IsoSurfaceGenerator(AbstractCalculation parent)
Instantiates a new iso surface generator.

Parameters:
parent - the parent
Method Detail

getVersion

public static java.lang.String getVersion()

clampColumn

protected int clampColumn(int c)
Clamp column index.

Parameters:
c - the column
Returns:
the column

clampRow

protected int clampRow(int r)
Clamp row.

Parameters:
r - the row
Returns:
the row

clampSlice

protected int clampSlice(int s)
Clamp slice.

Parameters:
s - the slice
Returns:
the slice

fGetOffset

protected float fGetOffset(Point3i v1,
                           Point3i v2)
Interpolate position along edge.

Parameters:
v1 - the lower grid point
v2 - the upper grid point
Returns:
the position

marchTetrahedral

protected void marchTetrahedral(java.util.Hashtable<java.lang.Long,IsoSurfaceGenerator.EdgeSplit> splits,
                                java.util.LinkedList<IsoSurfaceGenerator.Triangle> triangles,
                                Point3i[] pasTetrahedronPosition)
March tetrahedral.

Parameters:
splits - the edge splits
triangles - the triangles
pasTetrahedronPosition - the tetrahedron positions

setMethod

public void setMethod(IsoSurfaceGenerator.Method method)
Sets the iso-surface generation method.

Parameters:
method - the iso-surface generation method.

setUseResolutions

public void setUseResolutions(boolean value)
Sets the use image resolutions flag.

Parameters:
value - the if true, algorithm will use image resolutions

setWinding

public void setWinding(IsoSurfaceGenerator.Winding winding)
Sets the winding order.

Parameters:
winding - the winding order

solve

public EmbeddedSurface solve(ImageDataFloat vol,
                             float isoLevel)
Solve for iso-surface

Parameters:
vol - the volume
isoLevel - the target iso-level
Returns:
the iso-surface

triangulateUsingMarchingCubes

protected void triangulateUsingMarchingCubes(java.util.Hashtable<java.lang.Long,IsoSurfaceGenerator.EdgeSplit> splits,
                                             java.util.LinkedList<IsoSurfaceGenerator.Triangle> triangles,
                                             int x,
                                             int y,
                                             int z)
Triangulate using marching cubes.

Parameters:
splits - the edge splits
triangles - the triangles
x - the x position
y - the y position
z - the z position

triangulateUsingMarchingTetrahedrals

protected void triangulateUsingMarchingTetrahedrals(java.util.Hashtable<java.lang.Long,IsoSurfaceGenerator.EdgeSplit> splits,
                                                    java.util.LinkedList<IsoSurfaceGenerator.Triangle> triangles,
                                                    int x,
                                                    int y,
                                                    int z)
Triangulate using marching tetrahedrals.

Parameters:
splits - the edge splits
triangles - the triangles
x - the x position
y - the y position
z - the z position