GeomRep
Class Face

java.lang.Object
  extended by GeomRep.Face

public class Face
extends java.lang.Object

Face class.

This class describes face as an array of vertex numbers. Those vertex numbers are indices of vertices stored in an array at some other location. This design avoids having to store the entire vertex info multiple times because vertices are shared between several faces. The order of face vertices must be counter-clockwise or clockwise.

Since:
1.0

Field Summary
private  boolean bBoundaryFace
          Is the face on boundary?
private  int[] mFaceVertices
          Vertex indices forming the face.
private  float[] mUnitNormal
          Face unit normal.
 
Constructor Summary
Face()
          Class constructor.
Face(int vtNum)
          Class constructor.
 
Method Summary
 void ComputeFaceNormals(Vertex[] vertexArr)
          Compute face normal for the face.
 boolean GetBoundaryFlag()
          Find out if the face is on boundary.
 float[] GetFaceNormal()
          Get face normal (unit vector).
 int GetNumVertices()
          Get the number of vertices in this face.
 int GetVertex(int num)
          Get the face vertex at a position in the face.
 void SetBoundaryFlag(boolean onBdry)
          Set the boundary flag for the face.
 void SetVertex(int num, int vtNum)
          Set the num vertex of face to vtNum.
 void SetVertexNum(int num)
          Set the number of face vertices.
 void SetVertices(int[] vts)
          Set the face vertices.
 void SetVertices(int[] vts, int num)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mFaceVertices

private int[] mFaceVertices
Vertex indices forming the face.


mUnitNormal

private float[] mUnitNormal
Face unit normal.


bBoundaryFace

private boolean bBoundaryFace
Is the face on boundary?

Constructor Detail

Face

public Face()
Class constructor.


Face

public Face(int vtNum)
Class constructor.

Parameters:
vtNum - Number of vertices forming the face.
Method Detail

GetBoundaryFlag

public boolean GetBoundaryFlag()
Find out if the face is on boundary.

Returns:
true if face is on boundary, false otherwise.

SetBoundaryFlag

public void SetBoundaryFlag(boolean onBdry)
Set the boundary flag for the face.

Parameters:
onBdry - true if face on boundary, false otherwise.

GetNumVertices

public int GetNumVertices()
Get the number of vertices in this face.

Returns:
Number of vertices in the face.

ComputeFaceNormals

public void ComputeFaceNormals(Vertex[] vertexArr)
                        throws java.lang.ArrayIndexOutOfBoundsException
Compute face normal for the face. Must be invoked after vertices have been defined because the face only keeps vertex index numbers.

Parameters:
vertexArr - Array of vertices into which the face indexes.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if an array index exceeds the number of elements in vertexArr.

GetFaceNormal

public float[] GetFaceNormal()
Get face normal (unit vector).

Returns:
Unit normal array (3 element, containing direction cosines of the face normal unit vector).

SetVertices

public void SetVertices(int[] vts)
Set the face vertices.

Parameters:
vts - Array of vertex numbers forming the face.

SetVertices

public void SetVertices(int[] vts,
                        int num)

SetVertexNum

public void SetVertexNum(int num)
Set the number of face vertices. Reallocates the face vertex array, clearing previous contents (if any).

Parameters:
num - Number of face vertices.

GetVertex

public int GetVertex(int num)
              throws java.lang.ArrayIndexOutOfBoundsException
Get the face vertex at a position in the face.

Parameters:
num - Index in the vertex array (@see mFaceVertices)
Returns:
Vertex number at num position in the array of vertices forming the face.
Throws:
java.lang.ArrayIndexOutOfBoundsException

SetVertex

public void SetVertex(int num,
                      int vtNum)
               throws java.lang.ArrayIndexOutOfBoundsException
Set the num vertex of face to vtNum.

Parameters:
num - Index in the vertex array (@see mFaceVertices)
vtNum - Vertex number.
Throws:
java.lang.ArrayIndexOutOfBoundsException