GeomRep
Class Scene

java.lang.Object
  extended by GeomRep.Scene

public class Scene
extends java.lang.Object

Scene class that encapsulates the set of objects constituting the scene.

Scene class is a singleton, since it captures details of all the objects in the view. It contains a list of objects.

Since:
1.0
See Also:
GeomObject

Field Summary
private static Scene mInstance
          Singleton instance of the class.
private  java.util.List<GeomObject> mObjects
          List of objects comprising the scene.
private  OutputPanelInterface mOutPanel
           
 
Constructor Summary
protected Scene()
          Class constructor.
 
Method Summary
 void AddObj(GeomObject obj)
          Method to add object to the list of objects forming the scene.
 void CutAcrossLine(float[] transMatrix, float slope, float intercept)
           
 void CutAcrossPlane(float[] plane_coeff)
           
 boolean DeleteObject(java.lang.String shortFileName)
           
 void DrawCameraImage(DrawingCanvasInterface canvas, java.awt.Graphics g, float[] transMatrix, boolean onlySurface, boolean onlyWireframe)
          Draws the surface model with camera positioned at (X, Y, Z).
 void DrawCrinkleCut(DrawingCanvasInterface canvas, java.awt.Graphics g, float[] plane, float[] transMatrix)
          Draw the face of objects in the scene cut by a specified cutting plane.
 void DrawSurface(DrawingCanvasInterface canvas, java.awt.Graphics g, float[] transMatrix)
          Draw the surface of objects comprising the scene.
 void DrawSurfaceOnly(DrawingCanvasInterface canvas, java.awt.Graphics g, float[] transMatrix)
          Draw only the surface (no edges) of objects comprising the scene.
 void DrawWireFrame(DrawingCanvasInterface canvas, java.awt.Graphics g, float[] transMatrix)
          Draw wire frame picture of the scene.
 GeomObject GetLastObject()
           
 GeomObject GetObj(int indx)
          Get the GeomObject corresponding to a given index number.
 GeomObject GetObjectFromFileName(java.lang.String shortFileName)
          Get the object that was created from a specified file.
static Scene Instance()
          Method to get the instance (singleton) of this class.
 void RemoveAllObj()
          Remove all objects from the scene.
 GeomObject RemoveObj(GeomObject obj)
          Remove an object from the scene.
 GeomObject RemoveObj(int objIndex)
          Remove an object from the scene.
 void SetOutputPanel(OutputPanelInterface outPanel)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mObjects

private java.util.List<GeomObject> mObjects
List of objects comprising the scene.


mInstance

private static Scene mInstance
Singleton instance of the class.


mOutPanel

private OutputPanelInterface mOutPanel
Constructor Detail

Scene

protected Scene()
Class constructor. Constructor is protected (because the class is singleton). It allocates a new list of objects (initially the list is empty).

Method Detail

SetOutputPanel

public void SetOutputPanel(OutputPanelInterface outPanel)

Instance

public static Scene Instance()
Method to get the instance (singleton) of this class.

Returns:
Scene instance.

AddObj

public void AddObj(GeomObject obj)
Method to add object to the list of objects forming the scene.

Parameters:
obj - Instance of object
See Also:
GeomObject

RemoveAllObj

public void RemoveAllObj()
Remove all objects from the scene.


RemoveObj

public GeomObject RemoveObj(GeomObject obj)
Remove an object from the scene.

Parameters:
obj - Instance of the object to remove.
Returns:
Instance of removed object. This is one of a set of two overloaded methods. The other method removes object based on number in list.
See Also:
RemoveObj(int)

RemoveObj

public GeomObject RemoveObj(int objIndex)
Remove an object from the scene.

Parameters:
objIndex - Index of object to remove.
Returns:
Instance of removed object. This is the second of a set of two overloaded methods. The other method removes object based on object instance.
See Also:
RemoveObj(GeomObject)

GetObjectFromFileName

public GeomObject GetObjectFromFileName(java.lang.String shortFileName)
Get the object that was created from a specified file.

Parameters:
shortFileName - Last part of file name, eg: /path/file.gts will have a short file name of file.gts
Returns:
GeomObject instance (first instance found with a matching short file name), null if nothing is found.
See Also:
GeomObject

DeleteObject

public boolean DeleteObject(java.lang.String shortFileName)

GetObj

public GeomObject GetObj(int indx)
                  throws java.lang.IndexOutOfBoundsException
Get the GeomObject corresponding to a given index number.

Parameters:
indx - Index number of a GeomObject in the object list maintained by Scene.
Returns:
GeomObject instance such that mObjects.indexOf(obj) = indx.
Throws:
java.lang.IndexOutOfBoundsException - if the index is out of range (indx < 0 || indx >= size()).
See Also:
mObjects

GetLastObject

public GeomObject GetLastObject()

DrawWireFrame

public void DrawWireFrame(DrawingCanvasInterface canvas,
                          java.awt.Graphics g,
                          float[] transMatrix)
Draw wire frame picture of the scene. Relays the request to individual objects.

Parameters:
canvas - Instance of DrawingCanvas object (needed for converting to screen coordinates).
g - Graphics instance onto which the drawing needs to be done.
transMatrix - Transformation matrix.
See Also:
DrawingCanvas, DrawingCanvasInterface, GeomObject

DrawSurface

public void DrawSurface(DrawingCanvasInterface canvas,
                        java.awt.Graphics g,
                        float[] transMatrix)
Draw the surface of objects comprising the scene. Relays the request to individual objects.

Parameters:
canvas - Instance of DrawingCanvas object (needed for converting to screen coordinates).
g - Graphics instance onto which the drawing needs to be done.
transMatrix - Transformation matrix.
See Also:
DrawingCanvas, DrawingCanvasInterface, GeomObject

DrawSurfaceOnly

public void DrawSurfaceOnly(DrawingCanvasInterface canvas,
                            java.awt.Graphics g,
                            float[] transMatrix)
Draw only the surface (no edges) of objects comprising the scene. Relays the request to individual objects.

Parameters:
canvas - Instance of DrawingCanvas object (needed for converting to screen coordinates).
g - Graphics instance onto which the drawing needs to be done.
transMatrix - Transformation matrix.
See Also:
DrawingCanvas, DrawingCanvasInterface, GeomObject

DrawCameraImage

public void DrawCameraImage(DrawingCanvasInterface canvas,
                            java.awt.Graphics g,
                            float[] transMatrix,
                            boolean onlySurface,
                            boolean onlyWireframe)
Draws the surface model with camera positioned at (X, Y, Z). Camera position, perspective proj etc are all baked into transMatrix (transformation matrix)


DrawCrinkleCut

public void DrawCrinkleCut(DrawingCanvasInterface canvas,
                           java.awt.Graphics g,
                           float[] plane,
                           float[] transMatrix)
Draw the face of objects in the scene cut by a specified cutting plane. Relays the request to individual objects. Cutting plane is defined as plane[0]*x + plane[1]*y + plane[2]*z + plane[3] = 0;

Parameters:
canvas - Instance of DrawingCanvas object (needed for converting to screen coordinates).
g - Graphics instance onto which the drawing needs to be done.
plane - Coefficients in plane equation (Ax+By+Cz+D=0).
transMatrix - Transformation matrix.
See Also:
DrawingCanvas, DrawingCanvasInterface, GeomObject

CutAcrossPlane

public void CutAcrossPlane(float[] plane_coeff)

CutAcrossLine

public void CutAcrossLine(float[] transMatrix,
                          float slope,
                          float intercept)