GeomRep
Class TriangulatedObject

java.lang.Object
  extended by GeomRep.TriangulatedObject
All Implemented Interfaces:
GeomObject

public class TriangulatedObject
extends java.lang.Object
implements GeomObject

Class for storing meshed objects having a surface mesh.

Object meed not have a triangle surface mesh, the mesh elements could be any convex polygon.

Since:
1.0
See Also:
GeomObject

Field Summary
private  int iNumPoints
           
private  float[] mCentroid
           
private  float[] mColorComponents
           
private  float mDelta
           
private  java.awt.Color mEdgeColor
           
private  Face[] mFaces
          Array of faces forming the surface mesh on the object.
private  java.lang.String mFileName
           
private  float mMaxX
           
private  float mMaxY
           
private  float mMaxZ
           
private  float mMinX
           
private  float mMinY
           
private  float mMinZ
           
private  int[] mOutBuf
          Array used in internal code.
private  OutputPanelInterface mOutPanel
           
private  java.awt.Color mSurfaceColor
           
private  Vertex[] mVertices
          Array of vertices forming the surface mesh on the object.
private  int[] mXPoints
           
private  int[] mYPoints
           
 
Constructor Summary
TriangulatedObject()
          Class constructor (default).
TriangulatedObject(int fcNum, int numVt)
          Class constructor.
 
Method Summary
private  void ApplyTransform(int vertex, float[] transMatrix, float[] transPoint)
          Use the transform to get transformed coordinates of a point.
 void ComputeFaceNormals()
          Compute face normal for the faces.
 void ComputeMaximumDelta()
           
 void CopyFaces(java.util.List<Face> faceList)
           
 void CopyVertices(java.util.List<Vertex> vertexList)
           
 void CutAcrossLine(float[] transMatrix, float slope, float intercept)
           
 void CutAcrossPlane(float[] plane_coeff, boolean retainPositive)
           
 void DrawCameraImage(DrawingCanvasInterface canvas, java.awt.Graphics g, float[] transMatrix, boolean onlySurface)
          Draws the surface model viewed through camera .All camera related information has been baked into transMatrix (transformation matrix).
 void DrawCrinkleCut(DrawingCanvasInterface canvas, java.awt.Graphics g, float[] plane, float[] transMatrix)
          Draws the surface of this object cut by a cutting plane.
 void DrawSurface(DrawingCanvasInterface canvas, java.awt.Graphics g, float[] transMatrix)
          Draws the surface model of this object.
 void DrawSurfaceOnly(DrawingCanvasInterface canvas, java.awt.Graphics g, float[] transMatrix)
          Draws only the surface model (without any edges) for this object.
 void DrawWireFrame(DrawingCanvasInterface canvas, java.awt.Graphics g, float[] transMatrix)
          Draws the wireframe model of this object.
 float[] GetCentroidCoor()
           
 float GetCentroidX()
           
 float GetCentroidY()
           
 float GetCentroidZ()
           
 java.awt.Color GetEdgeColor()
           
 Face GetFace(int num)
          Get the face by index number in face array (@see mFaces).
 java.lang.String GetFileName()
           
 float GetMaxDelta()
           
 float GetMinX()
           
 float GetMinY()
           
 float GetMinZ()
           
 java.awt.Color GetSurfaceColor()
           
 Vertex GetVertex(int num)
          Get the vertex by index number in vertex array (@see mVertices).
 void SetEdgeColor(java.awt.Color col)
           
 void SetFace(Face fc, int fcNum)
           
 void SetFileName(java.lang.String fileName)
           
 void SetNumFaces(int num)
          Set number of faces.
 void SetNumVertices(int num)
          Set number of vertices.
 void SetOutputPanel(OutputPanelInterface outPanel)
           
 void SetSurfaceColor(java.awt.Color col)
           
 void SetVertex(Vertex vt, int vtNum)
           
private  void TransformPoint(float[] coord, float[] transMatrix, float[] transPoint)
           
private  void UpdateTriangulatedObjAfterCut()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mFaces

private Face[] mFaces
Array of faces forming the surface mesh on the object.

See Also:
Face

mVertices

private Vertex[] mVertices
Array of vertices forming the surface mesh on the object.

See Also:
Vertex

mOutBuf

private int[] mOutBuf
Array used in internal code. Preallocate it here.


mMaxX

private float mMaxX

mMinX

private float mMinX

mMaxY

private float mMaxY

mMinY

private float mMinY

mMaxZ

private float mMaxZ

mMinZ

private float mMinZ

mDelta

private float mDelta

mCentroid

private float[] mCentroid

mOutPanel

private OutputPanelInterface mOutPanel

mXPoints

private int[] mXPoints

mYPoints

private int[] mYPoints

iNumPoints

private int iNumPoints

mFileName

private java.lang.String mFileName

mSurfaceColor

private java.awt.Color mSurfaceColor

mEdgeColor

private java.awt.Color mEdgeColor

mColorComponents

private float[] mColorComponents
Constructor Detail

TriangulatedObject

public TriangulatedObject(int fcNum,
                          int numVt)
Class constructor.

Parameters:
fcNum - Number of faces.
numVt - Number of vertices.

TriangulatedObject

public TriangulatedObject()
Class constructor (default).

Method Detail

SetOutputPanel

public void SetOutputPanel(OutputPanelInterface outPanel)
Specified by:
SetOutputPanel in interface GeomObject

ComputeFaceNormals

public void ComputeFaceNormals()
Compute face normal for the faces. Must be invoked after vertices have been defined for this object.

See Also:
Face.ComputeFaceNormals(Vertex[])

SetFileName

public void SetFileName(java.lang.String fileName)
Specified by:
SetFileName in interface GeomObject

GetFileName

public java.lang.String GetFileName()
Specified by:
GetFileName in interface GeomObject

SetSurfaceColor

public void SetSurfaceColor(java.awt.Color col)
Specified by:
SetSurfaceColor in interface GeomObject

GetSurfaceColor

public java.awt.Color GetSurfaceColor()
Specified by:
GetSurfaceColor in interface GeomObject

SetEdgeColor

public void SetEdgeColor(java.awt.Color col)
Specified by:
SetEdgeColor in interface GeomObject

GetEdgeColor

public java.awt.Color GetEdgeColor()
Specified by:
GetEdgeColor in interface GeomObject

SetNumFaces

public void SetNumFaces(int num)
Set number of faces.

Parameters:
num - Number of faces.

SetNumVertices

public void SetNumVertices(int num)
Set number of vertices.

Parameters:
num - Number of vertices.

GetFace

public Face GetFace(int num)
Get the face by index number in face array (@see mFaces).

Parameters:
num - Index number of face.
Returns:
Face instance. (@see Face)
Throws:
java.lang.ArrayIndexOutOfBoundsException

SetFace

public void SetFace(Face fc,
                    int fcNum)

GetVertex

public Vertex GetVertex(int num)
Get the vertex by index number in vertex array (@see mVertices).

Parameters:
num - Index number of vertex.
Returns:
Vertex instance. (@see Vertex)
Throws:
java.lang.ArrayIndexOutOfBoundsException

CopyFaces

public void CopyFaces(java.util.List<Face> faceList)

CopyVertices

public void CopyVertices(java.util.List<Vertex> vertexList)

SetVertex

public void SetVertex(Vertex vt,
                      int vtNum)

DrawWireFrame

public void DrawWireFrame(DrawingCanvasInterface canvas,
                          java.awt.Graphics g,
                          float[] transMatrix)
Draws the wireframe model of this object.

Specified by:
DrawWireFrame in interface GeomObject
Parameters:
canvas - Instance of DrawingCanvas (@see GridView#DrawingCanvas) on which drawing is drawn.
g - Graphics instance used in drawing.
transMatrix - Transformatin matrix.
See Also:
DrawingCanvasInterface

DrawSurface

public void DrawSurface(DrawingCanvasInterface canvas,
                        java.awt.Graphics g,
                        float[] transMatrix)
Draws the surface model of this object.

Specified by:
DrawSurface in interface GeomObject
Parameters:
canvas - Instance of DrawingCanvas on which drawing is drawn.
g - Graphics instance used in drawing.
transMatrix - Transformatin matrix.
See Also:
DrawingCanvasInterface, DrawingCanvas

DrawSurfaceOnly

public void DrawSurfaceOnly(DrawingCanvasInterface canvas,
                            java.awt.Graphics g,
                            float[] transMatrix)
Draws only the surface model (without any edges) for this object.

Specified by:
DrawSurfaceOnly in interface GeomObject
Parameters:
canvas - Instance of DrawingCanvas on which drawing is drawn.
g - Graphics instance used in drawing.
transMatrix - Transformatin matrix.
See Also:
DrawingCanvasInterface, DrawingCanvas

DrawCameraImage

public void DrawCameraImage(DrawingCanvasInterface canvas,
                            java.awt.Graphics g,
                            float[] transMatrix,
                            boolean onlySurface)
Draws the surface model viewed through camera .All camera related information has been baked into transMatrix (transformation matrix). Positions the camera at specified point, pointing it along positive Z axis and draws the view in front of the camera screen.

The screen is along XY plane. Features behind the screen are not drawn. This function is useful for trajectory based internal visualization


The center of projection is assumed to be 10 units behind the screen. This method uses one-direction perspective view (Z dir)

Specified by:
DrawCameraImage in interface GeomObject
Parameters:
canvas - Instance of DrawingCanvas on which drawing is drawn.
g - Graphics instance used in drawing.
transMatrix - Transformatin matrix. Coordinates are in physical dimensions (not transformed)
onlySurface - true if only surface (no edges) are to be drawn, false otherwise
See Also:
DrawingCanvasInterface, DrawingCanvas

DrawCrinkleCut

public void DrawCrinkleCut(DrawingCanvasInterface canvas,
                           java.awt.Graphics g,
                           float[] plane,
                           float[] transMatrix)
Draws the surface of this object cut by a cutting plane.

Specified by:
DrawCrinkleCut in interface GeomObject
Parameters:
canvas - Instance of DrawingCanvas (@see GridView#DrawingCanvas) on which drawing is drawn.
g - Graphics instance used in drawing.
plane - Coefficient matrix defining the cuting plane.
transMatrix - Transformatin matrix.
See Also:
DrawingCanvasInterface

ApplyTransform

private void ApplyTransform(int vertex,
                            float[] transMatrix,
                            float[] transPoint)
Use the transform to get transformed coordinates of a point.

Parameters:
vertex - Vertex number in the array (@see mVertices).
transMatrix - Transformation matrix.
transPoint - Transformed coordinates of the vertex (output).

TransformPoint

private void TransformPoint(float[] coord,
                            float[] transMatrix,
                            float[] transPoint)

UpdateTriangulatedObjAfterCut

private void UpdateTriangulatedObjAfterCut()

ComputeMaximumDelta

public void ComputeMaximumDelta()
Specified by:
ComputeMaximumDelta in interface GeomObject

CutAcrossPlane

public void CutAcrossPlane(float[] plane_coeff,
                           boolean retainPositive)
Specified by:
CutAcrossPlane in interface GeomObject

CutAcrossLine

public void CutAcrossLine(float[] transMatrix,
                          float slope,
                          float intercept)
Specified by:
CutAcrossLine in interface GeomObject

GetMinX

public float GetMinX()
Specified by:
GetMinX in interface GeomObject

GetMinY

public float GetMinY()
Specified by:
GetMinY in interface GeomObject

GetMinZ

public float GetMinZ()
Specified by:
GetMinZ in interface GeomObject

GetMaxDelta

public float GetMaxDelta()
Specified by:
GetMaxDelta in interface GeomObject

GetCentroidX

public float GetCentroidX()
Specified by:
GetCentroidX in interface GeomObject

GetCentroidY

public float GetCentroidY()
Specified by:
GetCentroidY in interface GeomObject

GetCentroidZ

public float GetCentroidZ()
Specified by:
GetCentroidZ in interface GeomObject

GetCentroidCoor

public float[] GetCentroidCoor()
Specified by:
GetCentroidCoor in interface GeomObject