com.sun.j3d.utils.geometry
Class Triangulator

java.lang.Object
  extended by com.sun.j3d.utils.geometry.Triangulator

public class Triangulator
extends java.lang.Object

Triangulator is a utility for turning arbitrary polygons into triangles so they can be rendered by Java 3D. Polygons can be concave, nonplanar, and can contain holes.

See Also:
GeometryInfo

Field Summary
(package private)  boolean ccwLoop
           
(package private)  int[] chains
           
(package private)  java.lang.Object[] colors
           
private static int DEBUG
           
(package private)  Distance[] distances
           
(package private) static int EARS_RANDOM
           
(package private) static int EARS_SEQUENCE
           
(package private) static int EARS_SORTED
           
(package private)  boolean earsRandom
           
(package private)  boolean earsSorted
           
(package private)  double epsilon
           
(package private)  int[] faces
           
(package private)  int firstNode
           
(package private)  GeometryInfo gInfo
           
(package private)  HeapNode[] heap
           
(package private)  int identCntr
           
(package private) static int INC_DIST_BK
           
(package private) static int INC_LIST_BK
           
(package private) static int INC_LOOP_BK
           
(package private) static int INC_POINT_BK
           
(package private) static int INC_TRI_BK
           
(package private)  Left[] leftMost
           
(package private)  ListNode[] list
           
(package private)  int loopMax
           
(package private)  int loopMin
           
(package private)  int[] loops
           
(package private)  int maxNumChains
           
(package private)  int maxNumDist
           
(package private)  int maxNumHeap
           
(package private)  int maxNumLeftMost
           
(package private)  int maxNumList
           
(package private)  int maxNumLoops
           
(package private)  int maxNumPoints
           
(package private)  int maxNumPolyArea
           
(package private)  int maxNumPUnsorted
           
(package private)  int maxNumTriangles
           
(package private)  boolean noHashingEdges
           
(package private)  boolean noHashingPnts
           
(package private)  Vector3f[] normals
           
(package private)  int numChains
           
(package private)  int numFaces
           
(package private)  int numHeap
           
(package private)  int numList
           
(package private)  int numLoops
           
(package private)  int numPoints
           
(package private)  int numReflex
           
(package private)  int numTexSets
           
(package private)  int numTriangles
           
(package private)  int numVtxList
           
(package private)  int numZero
           
(package private)  Point2f[] points
           
(package private)  double[] polyArea
           
(package private)  Point2f[] pUnsorted
           
(package private)  java.util.Random randomGen
           
(package private)  int reflexVertices
           
(package private)  int[] stripCounts
           
(package private)  Triangle[] triangles
           
(package private)  int[] vertexIndices
           
(package private)  Point3f[] vertices
           
(package private)  PntNode[] vtxList
           
(package private) static double ZERO
           
 
Constructor Summary
Triangulator()
          Deprecated. This class is created automatically when needed in GeometryInfo and never needs to be used directly. Putting data into a GeometryInfo with primitive POLYGON_ARRAY automatically causes the triangulator to be created and used.
Triangulator(int earOrder)
          Deprecated. This class is created automatically when needed in GeometryInfo and never needs to be used directly. Putting data into a GeometryInfo with primitive POLYGON_ARRAY automatically causes the triangulator to be created and used.
 
Method Summary
(package private)  void deleteHook(int currLoop)
           
(package private)  void deleteLinks(int ind)
          Deletes node ind from list (with destroying its data fields)
(package private)  int fetchData(int ind1)
          obtains the data store at ind1
(package private)  int fetchNextData(int ind1)
          Returns pointer to the successor of ind1.
(package private)  int fetchPrevData(int ind1)
          returns pointer to the successor of ind1.
(package private)  int getAngle(int ind)
           
(package private)  int getNextChain(boolean[] done)
           
(package private)  int getNode()
           
(package private)  void initPnts(int number)
           
(package private)  boolean inLoopList(int loop)
           
(package private)  boolean inPointsList(int index)
           
(package private)  boolean inPolyList(int ind)
           
(package private)  void insertAfter(int ind1, int ind2)
          Inserts node ind2 after node ind1.
(package private)  int makeHook()
          Allocates storage for a dummy list node; pointers are set to itself.
(package private)  int makeLoopHeader()
           
(package private)  int makeNode(int index)
          Allocates storage for a new list node, and stores the index of the point at this node.
(package private)  void preProcessList(int i1)
           
(package private)  void printListData()
           
(package private)  void printVtxList()
           
(package private)  void resetPolyList(int ind)
           
(package private)  void rotateLinks(int ind1, int ind2)
           
(package private)  void setAngle(int ind, int convex)
           
(package private)  void setEpsilon(double eps)
           
(package private)  void splitSplice(int ind1, int ind2, int ind3, int ind4)
           
(package private)  void storeChain(int ind)
           
(package private)  int storePoint(double x, double y)
           
(package private)  void storeTriangle(int i, int j, int k)
           
(package private)  void swapLinks(int ind1)
          swap the list pointers in order to change the orientation.
 void triangulate(GeometryInfo gi)
          This routine converts the GeometryInfo object from primitive type POLYGON_ARRAY to primitive type TRIANGLE_ARRAY using polygon decomposition techniques.
(package private)  void updateIndex(int ind, int index)
           
(package private)  void writeTriangleToGeomInfo()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

gInfo

GeometryInfo gInfo

faces

int[] faces

loops

int[] loops

chains

int[] chains

points

Point2f[] points

triangles

Triangle[] triangles

list

ListNode[] list

randomGen

java.util.Random randomGen

numPoints

int numPoints

maxNumPoints

int maxNumPoints

numList

int numList

maxNumList

int maxNumList

numLoops

int numLoops

maxNumLoops

int maxNumLoops

numTriangles

int numTriangles

maxNumTriangles

int maxNumTriangles

numFaces

int numFaces

numTexSets

int numTexSets

firstNode

int firstNode

numChains

int numChains

maxNumChains

int maxNumChains

pUnsorted

Point2f[] pUnsorted

maxNumPUnsorted

int maxNumPUnsorted

noHashingEdges

boolean noHashingEdges

noHashingPnts

boolean noHashingPnts

loopMin

int loopMin

loopMax

int loopMax

vtxList

PntNode[] vtxList

numVtxList

int numVtxList

numReflex

int numReflex

reflexVertices

int reflexVertices

distances

Distance[] distances

maxNumDist

int maxNumDist

leftMost

Left[] leftMost

maxNumLeftMost

int maxNumLeftMost

heap

HeapNode[] heap

numHeap

int numHeap

maxNumHeap

int maxNumHeap

numZero

int numZero

maxNumPolyArea

int maxNumPolyArea

polyArea

double[] polyArea

stripCounts

int[] stripCounts

vertexIndices

int[] vertexIndices

vertices

Point3f[] vertices

colors

java.lang.Object[] colors

normals

Vector3f[] normals

ccwLoop

boolean ccwLoop

earsRandom

boolean earsRandom

earsSorted

boolean earsSorted

identCntr

int identCntr

epsilon

double epsilon

ZERO

static final double ZERO
See Also:
Constant Field Values

EARS_SEQUENCE

static final int EARS_SEQUENCE
See Also:
Constant Field Values

EARS_RANDOM

static final int EARS_RANDOM
See Also:
Constant Field Values

EARS_SORTED

static final int EARS_SORTED
See Also:
Constant Field Values

INC_LIST_BK

static final int INC_LIST_BK
See Also:
Constant Field Values

INC_LOOP_BK

static final int INC_LOOP_BK
See Also:
Constant Field Values

INC_TRI_BK

static final int INC_TRI_BK
See Also:
Constant Field Values

INC_POINT_BK

static final int INC_POINT_BK
See Also:
Constant Field Values

INC_DIST_BK

static final int INC_DIST_BK
See Also:
Constant Field Values

DEBUG

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

Triangulator

public Triangulator()
Deprecated. This class is created automatically when needed in GeometryInfo and never needs to be used directly. Putting data into a GeometryInfo with primitive POLYGON_ARRAY automatically causes the triangulator to be created and used.

Creates a new instance of the Triangulator.


Triangulator

public Triangulator(int earOrder)
Deprecated. This class is created automatically when needed in GeometryInfo and never needs to be used directly. Putting data into a GeometryInfo with primitive POLYGON_ARRAY automatically causes the triangulator to be created and used.

Creates a new instance of a Triangulator.

Method Detail

triangulate

public void triangulate(GeometryInfo gi)
This routine converts the GeometryInfo object from primitive type POLYGON_ARRAY to primitive type TRIANGLE_ARRAY using polygon decomposition techniques.

 Example of usage:
   Triangulator tr = new Triangulator();
   tr.triangulate(ginfo); // ginfo contains the geometry.
   shape.setGeometry(ginfo.getGeometryArray()); // shape is a Shape3D.

Parameters:
gi - Geometry to be triangulated

printVtxList

void printVtxList()

printListData

void printListData()

preProcessList

void preProcessList(int i1)

writeTriangleToGeomInfo

void writeTriangleToGeomInfo()

setEpsilon

void setEpsilon(double eps)

inPolyList

boolean inPolyList(int ind)

updateIndex

void updateIndex(int ind,
                 int index)

getAngle

int getAngle(int ind)

setAngle

void setAngle(int ind,
              int convex)

resetPolyList

void resetPolyList(int ind)

getNode

int getNode()

inLoopList

boolean inLoopList(int loop)

deleteHook

void deleteHook(int currLoop)

deleteLinks

void deleteLinks(int ind)
Deletes node ind from list (with destroying its data fields)


rotateLinks

void rotateLinks(int ind1,
                 int ind2)

storeChain

void storeChain(int ind)

getNextChain

int getNextChain(boolean[] done)

splitSplice

void splitSplice(int ind1,
                 int ind2,
                 int ind3,
                 int ind4)

makeHook

int makeHook()
Allocates storage for a dummy list node; pointers are set to itself.

Returns:
pointer to node

makeLoopHeader

int makeLoopHeader()

makeNode

int makeNode(int index)
Allocates storage for a new list node, and stores the index of the point at this node. Pointers are set to -1.

Returns:
pointer to node

insertAfter

void insertAfter(int ind1,
                 int ind2)
Inserts node ind2 after node ind1.


fetchNextData

int fetchNextData(int ind1)
Returns pointer to the successor of ind1.


fetchData

int fetchData(int ind1)
obtains the data store at ind1


fetchPrevData

int fetchPrevData(int ind1)
returns pointer to the successor of ind1.


swapLinks

void swapLinks(int ind1)
swap the list pointers in order to change the orientation.


storeTriangle

void storeTriangle(int i,
                   int j,
                   int k)

initPnts

void initPnts(int number)

inPointsList

boolean inPointsList(int index)

storePoint

int storePoint(double x,
               double y)


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