com.sun.j3d.utils.geometry.compression
Class GeneralizedStrip

java.lang.Object
  extended by com.sun.j3d.utils.geometry.compression.GeneralizedStrip

 class GeneralizedStrip
extends java.lang.Object

This class provides static methods to support topological transformations on generalized strips. This is used by the GeometryDecompressor. These methods only need to look at the vertex replacement flags to determine how the vertices in the strip are connected. The connections are rearranged in different ways to transform generalized strips to GeometryArray representations.

See Also:
GeneralizedStripFlags, GeneralizedVertexList, GeometryDecompressor

Nested Class Summary
(package private) static class GeneralizedStrip.IntList
          The IntList is like an ArrayList, but avoids the Integer object wrapper and accessor overhead for simple lists of ints.
(package private) static class GeneralizedStrip.StripArray
          The StripArray class is used as the output of some conversion methods in the GeneralizedStrip class.
 
Field Summary
private static int CCW
           
private static int CW
           
private static boolean debug
           
private static int REPLACE_MIDDLE
           
private static int REPLACE_OLDEST
           
private static int RESTART_CCW
           
private static int RESTART_CW
           
 
Constructor Summary
GeneralizedStrip()
           
 
Method Summary
private static void addFan(GeneralizedStrip.IntList fanVerts, GeneralizedStrip.IntList fanCounts, int start, int length, int frontFace, int winding, boolean transition)
           
private static void addStrip(GeneralizedStrip.IntList stripVerts, GeneralizedStrip.IntList stripCounts, int start, int length, int frontFace, int winding)
           
(package private) static int[] fansToTriangles(int[] stripCounts)
          Breaks up triangle fans into separate triangles.
private static int fansToTriangles(int tstart, int[] tbuff, int vstart, int[] vertices, int stripStart, int[] stripCounts, int stripCount)
           
(package private) static GeneralizedStrip.StripArray fanToStrips(int v, int length, int[] fans, boolean convexPlanar)
          Takes a fan and converts it to one or more strips.
private static void fanToStrips(int v, int length, int[] fans, GeneralizedStrip.IntList stripVerts, GeneralizedStrip.IntList stripCounts, boolean convexPlanar)
           
(package private) static int getLineCount(int[] stripCounts)
          Counts the number of lines defined by arrays of line strips.
(package private) static int getTriangleCount(GeneralizedStrip.IntList stripCounts)
          Counts the number of triangles defined by arrays of triangle strips or fans.
(package private) static int getTriangleCount(int[] stripCounts)
          Counts the number of triangles defined by arrays of triangle strips or fans.
(package private) static int[] stripsToTriangles(int[] stripCounts)
          Breaks up triangle strips into separate triangles.
private static int stripsToTriangles(int tstart, int[] tbuff, int vstart, int[] vertices, int stripStart, int[] stripCounts, int stripCount)
           
(package private) static GeneralizedStrip.StripArray toLineStrips(GeneralizedStripFlags vertices)
          Interprets the vertex flags associated with a class implementing GeneralizedStripFlags, constructing and returning a StripArray.
(package private) static GeneralizedStrip.StripArray[] toStripsAndFans(GeneralizedStripFlags vertices, int frontFace)
          Interprets the vertex flags associated with a class implementing GeneralizedStripFlags, constructing and returning a 2-element array of StripArray objects.
private static void toStripsAndFans(GeneralizedStripFlags vertices, int frontFace, GeneralizedStrip.IntList stripVerts, GeneralizedStrip.IntList stripCounts, GeneralizedStrip.IntList fanVerts, GeneralizedStrip.IntList fanCounts)
           
(package private) static GeneralizedStrip.StripArray[] toStripsAndTriangles(GeneralizedStripFlags vertices, int frontFace, int shortStripSize, int maxShortStrips)
          Interprets the vertex flags associated with a class implementing GeneralizedStripFlags, constructing and returning a 2-element array of StripArray objects.
(package private) static int[] toTriangles(GeneralizedStripFlags vertices, int frontFace)
          Interprets the vertex flags associated with a class implementing GeneralizedStripFlags, constructing and returning an array of vertex references representing the original generalized strip as individual triangles.
(package private) static GeneralizedStrip.StripArray toTriangleStrips(GeneralizedStripFlags vertices, int frontFace)
          Interprets the vertex flags associated with a class implementing GeneralizedStripFlags, constructing and returning a StripArray containing exclusively strips.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

debug

private static final boolean debug
See Also:
Constant Field Values

CW

private static final int CW
See Also:
Constant Field Values

CCW

private static final int CCW
See Also:
Constant Field Values

RESTART_CW

private static final int RESTART_CW
See Also:
Constant Field Values

RESTART_CCW

private static final int RESTART_CCW
See Also:
Constant Field Values

REPLACE_MIDDLE

private static final int REPLACE_MIDDLE
See Also:
Constant Field Values

REPLACE_OLDEST

private static final int REPLACE_OLDEST
See Also:
Constant Field Values
Constructor Detail

GeneralizedStrip

GeneralizedStrip()
Method Detail

toStripsAndFans

static GeneralizedStrip.StripArray[] toStripsAndFans(GeneralizedStripFlags vertices,
                                                     int frontFace)
Interprets the vertex flags associated with a class implementing GeneralizedStripFlags, constructing and returning a 2-element array of StripArray objects. The first StripArray will contain triangle strips and the second will contain triangle fans.

Parameters:
vertices - an object implementing GeneralizedStripFlags
frontFace - a flag, either GeneralizedStripFlags.FRONTFACE_CW or GeneralizedStripFlags.FRONTFACE_CCW, indicating front face winding
Returns:
a 2-element array containing strips in 0 and fans in 1

toStripsAndFans

private static void toStripsAndFans(GeneralizedStripFlags vertices,
                                    int frontFace,
                                    GeneralizedStrip.IntList stripVerts,
                                    GeneralizedStrip.IntList stripCounts,
                                    GeneralizedStrip.IntList fanVerts,
                                    GeneralizedStrip.IntList fanCounts)

addStrip

private static void addStrip(GeneralizedStrip.IntList stripVerts,
                             GeneralizedStrip.IntList stripCounts,
                             int start,
                             int length,
                             int frontFace,
                             int winding)

addFan

private static void addFan(GeneralizedStrip.IntList fanVerts,
                           GeneralizedStrip.IntList fanCounts,
                           int start,
                           int length,
                           int frontFace,
                           int winding,
                           boolean transition)

toTriangleStrips

static GeneralizedStrip.StripArray toTriangleStrips(GeneralizedStripFlags vertices,
                                                    int frontFace)
Interprets the vertex flags associated with a class implementing GeneralizedStripFlags, constructing and returning a StripArray containing exclusively strips.

Parameters:
vertices - an object implementing GeneralizedStripFlags
frontFace - a flag, either GeneralizedStripFlags.FRONTFACE_CW or GeneralizedStripFlags.FRONTFACE_CCW, indicating front face winding
Returns:
a StripArray containing the converted strips

fanToStrips

private static void fanToStrips(int v,
                                int length,
                                int[] fans,
                                GeneralizedStrip.IntList stripVerts,
                                GeneralizedStrip.IntList stripCounts,
                                boolean convexPlanar)

toTriangles

static int[] toTriangles(GeneralizedStripFlags vertices,
                         int frontFace)
Interprets the vertex flags associated with a class implementing GeneralizedStripFlags, constructing and returning an array of vertex references representing the original generalized strip as individual triangles. Each sequence of three consecutive vertex references in the output defines a single triangle.

Parameters:
vertices - an object implementing GeneralizedStripFlags
frontFace - a flag, either GeneralizedStripFlags.FRONTFACE_CW or GeneralizedStripFlags.FRONTFACE_CCW, indicating front face winding
Returns:
an array of indices into the original vertex array

stripsToTriangles

private static int stripsToTriangles(int tstart,
                                     int[] tbuff,
                                     int vstart,
                                     int[] vertices,
                                     int stripStart,
                                     int[] stripCounts,
                                     int stripCount)

fansToTriangles

private static int fansToTriangles(int tstart,
                                   int[] tbuff,
                                   int vstart,
                                   int[] vertices,
                                   int stripStart,
                                   int[] stripCounts,
                                   int stripCount)

toStripsAndTriangles

static GeneralizedStrip.StripArray[] toStripsAndTriangles(GeneralizedStripFlags vertices,
                                                          int frontFace,
                                                          int shortStripSize,
                                                          int maxShortStrips)
Interprets the vertex flags associated with a class implementing GeneralizedStripFlags, constructing and returning a 2-element array of StripArray objects. The first StripArray will contain triangle strips and the second will contain individual triangles in the vertices field. Short strips will be converted to individual triangles.

Parameters:
vertices - an object implementing GeneralizedStripFlags
frontFace - a flag, either GeneralizedStripFlags.FRONTFACE_CW or GeneralizedStripFlags.FRONTFACE_CCW, indicating front face winding
shortStripSize - strips this size or less will be converted to individual triangles if there are more than maxShortStrips of them
maxShortStrips - maximum number of short strips allowed before creating individual triangles
Returns:
a 2-element array containing strips in 0 and triangles in 1

toLineStrips

static GeneralizedStrip.StripArray toLineStrips(GeneralizedStripFlags vertices)
Interprets the vertex flags associated with a class implementing GeneralizedStripFlags, constructing and returning a StripArray. RESTART_CW and RESTART_CCW are treated as equivalent, as are REPLACE_MIDDLE and REPLACE_OLDEST.

Parameters:
vertices - an object implementing GeneralizedStripFlags
Returns:
a StripArray representing an array of line strips

getLineCount

static int getLineCount(int[] stripCounts)
Counts the number of lines defined by arrays of line strips.

Parameters:
stripCounts - array of strip counts, as used by the GeometryStripArray object
Returns:
number of lines in the strips

getTriangleCount

static int getTriangleCount(int[] stripCounts)
Counts the number of triangles defined by arrays of triangle strips or fans.

Parameters:
stripCounts - array of strip counts, as used by the GeometryStripArray object
Returns:
number of triangles in the strips or fans

getTriangleCount

static int getTriangleCount(GeneralizedStrip.IntList stripCounts)
Counts the number of triangles defined by arrays of triangle strips or fans.

Parameters:
stripCounts - IntList of strip counts
Returns:
number of triangles in the strips or fans

stripsToTriangles

static int[] stripsToTriangles(int[] stripCounts)
Breaks up triangle strips into separate triangles.

Parameters:
stripCounts - array of strip counts, as used by the GeometryStripArray object
Returns:
array of ints which index into the original vertex array; each set of three consecutive vertex indices defines a single triangle

fansToTriangles

static int[] fansToTriangles(int[] stripCounts)
Breaks up triangle fans into separate triangles.

Parameters:
stripCounts - array of strip counts, as used by the GeometryStripArray object
Returns:
array of ints which index into the original vertex array; each set of three consecutive vertex indices defines a single triangle

fanToStrips

static GeneralizedStrip.StripArray fanToStrips(int v,
                                               int length,
                                               int[] fans,
                                               boolean convexPlanar)
Takes a fan and converts it to one or more strips.

Parameters:
v - index into the fans array of the first vertex in the fan
length - number of vertices in the fan
fans - array of vertex indices representing one or more fans
convexPlanar - if true indicates that the fan is convex and planar; such fans will always be converted into a single strip
Returns:
a StripArray containing the converted strips


Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved. Use is subject to license terms.