GridView
Class GeomDataManager

java.lang.Object
  extended by GridView.GeomDataManager

public class GeomDataManager
extends java.lang.Object

GeomDataManager class provides the interface for interaction with the GeomRep module (package). GeomDataManager class provides methods to perform operations (viewing, transformation etc) needed by Viewer (DrawingCanvas) on geometric data of GeomRep package, thereby acting as a glue between these classes.

Since:
1.0

Field Summary
private  boolean bHome
          Set this flag to true if the next redraw should zoom to the last added object.
private  float[] mBuf
           
private  GeomObject mCurrZoomedObject
           
private  float[] mJavaCoordTransMatrix
          This is the transformation matrix for converting device independent coordinates into java screen (device dependent) coordinates.
It first translates the axes origin from screen center to upper left corner and then flips the Y axes to negative side (this is the java screen coordinate axes).
private  float[] mJavaCoordUserMatrix
          This is the transformation matrix for transforming java screen coordinates in a user specified way.
private  OutputPanel mOutPanel
          Output panel for writing output messages.
private  javax.swing.JProgressBar mProgressBar
           
private  Scene mScene
          Scene consisting of all objects.
private  float[] mTransMatrix
          This is the transformation matrix to convert physical coordinates to java screen coordinates (needed for drawing).
GeomDataManager class has a host of methods available to update / process this matrix.
It is formed from view matrix, user-defined transformation, java coordinate transformation, and user specified java coordinate transformation matrices (eg, zoom on screen etc) as:
mTransMatrix = mViewMatrix * mUserDefinedTransMatrix * mJavaCoordTransMatrix * mJavaCoordUserMatrix
X(screen) = X(physical)*mTransMatrix
private  float[] mTransMatrixBuf
           
private  float[] mUserDefinedTransMatrix
          This is the user-defined component of transformation matrix.
private  float[] mViewMatrix
          This matrix contains the axonometric/perpective transformations.
private  float mZoomFactor
          Factor controlling the zoom level.
 
Constructor Summary
GeomDataManager()
          Class constructor.
 
Method Summary
static void AppendMatrices(float[] appendToMatrix, float[] matrix, int size)
          Concatenate the sizeXsize matrix to the supplied matrix.
 void AppendToUserDefinedTransMatrix(float[] matrix)
          Concatenate the 4X4 matrix passed as argument to the user defined transformation matrix.
 void AppendToViewMatrix(float[] matrix)
          Concatenate the 4X4 view matrix (axonometric, perpective etc transformations) passed as matrix (argument) to the current view matrix.
 void ApplyTransform(float[] coord, float[] outputCoord)
          Transform a point using the current transformation matrix.
 void ConstructArbitRotMatrix(float[] axisDirCosine, float thetaRadian)
          Constructs rotation transformation matrix about an arbitrary axis (using Rodrigues formula) and appends it to the current user defined matrix.
 void ConstructArbitRotMatrix(float[] axisDirCosine, float sine, float cosine)
          Constructs rotation transformation matrix about an arbitrary axis (using Rodrigues formula) and appends it to the current user defined matrix.
private  void ConstructJavaCoordMatrix(float len)
          Convert coordinates from mapped (device independent coordinates) to java coordinates.
 void ConstructOnePtPerspMatrix(float centerProj)
          Constructs a one point perspective transformation matrix from the current transformation matrix.
 void ConstructRotMatrix(Defs.Axis ax, float sine, float cosine)
          Constructs rotation transformation matrix about one of X, Y or Z axes and appends it to the current user defined matrix.
 void ConstructThreePtPerspMatrix(float center1, float center2, float center3)
          Constructs a three point perspective transformation matrix from the current transformation matrix.
 void ConstructTransMatrix()
          Construct the transformation matrix using:
mTransMatrix = mViewMatrix * mUserDefinedTransMatrix * mJavaCoordTransMatrix * mJavaCoordUserMatrix
X(screen) = X(physical)*mTransMatrix
 void ConstructTwoPtPerspMatrix(Defs.Axis ax1, Defs.Axis ax2, float center1, float center2)
          Constructs a two point perspective transformation matrix from the current transformation matrix.
 void CutObject(int x1, int y1, int x2, int y2)
           
 void CutObjectIn3D(int x1, int y1, int x2, int y2)
           
 void DecreaseZoom()
          Decreases the zoom level by a factor of 2.
 boolean DeleteObject(java.lang.String shortFileName)
           
 void DrawCameraImage(DrawingCanvas canvas, java.awt.Graphics g, float[] camera_coor, float[] center_proj, boolean onlySurface, boolean onlyWireframe)
          Draws the surface or wirefrane model with camera positioned at (X, Y, Z) and center of projection at (x1, y1, z1).
 void DrawCrinkleCut(DrawingCanvas canvas, java.awt.Graphics g, float[] plane)
          Draw the face of objects in the scene cut by a specified cutting plane.
 void DrawSurface(DrawingCanvas canvas, java.awt.Graphics g)
          Draw the surface of objects comprising the scene.
 void DrawSurfaceOnly(DrawingCanvas canvas, java.awt.Graphics g)
          Draw only the surface (no edges) of objects comprising the scene.
 void DrawWireFrame(DrawingCanvas canvas, java.awt.Graphics g)
          Draw wire frame picture of the scene.
protected  void finalize()
           
private  void FormCompleteTransformationMatrix(float inset, float screenLen, GeomObject obj)
          Form complete transformation matrix in mTransMatrix.
 GeomObject GetCurrZoomedObject()
          Get the object that is currently focused on the screen (was zoomed to most recently).
 GeomObject GetObjectFromFileName(java.lang.String shortFileName)
          Get the object that was created from a specified file.
 void IncreaseZoom()
          Increases the zoom level by a factor of 2.
 float MeasureDistance(int x1, int y1, int x2, int y2)
          Measure the distance in physical coordinates between two points whose screen coordinates are known.
 void PanDown(float dist)
          Pan to bottom of the currently (drawn) image.
Appends the matrix to current mJavaCoordUserMatrix.
 void PanLeft(float dist)
          Pan to left of the currently (drawn) image.
Appends the matrix to current mJavaCoordUserMatrix.
 void PanRight(float dist)
          Pan to right of the currently (drawn) image.
Appends the matrix to current mJavaCoordUserMatrix.
 void PanUp(float dist)
          Pan upwards of the currently (drawn) image.
private  boolean ReadANSFile(java.lang.String fileName)
          Read a .ans ANSYS generated file.
The file contains header lines in the beginning, followed by a vertex definition block which is followed by a cell definition block.
private  boolean ReadCFEVFile(java.lang.String fileName)
          Parse the file having cell, face, edge, vertex info.
private  boolean ReadDatFile(java.lang.String fileName)
          Parse the file having cell, face, edge, vertex info.
 boolean ReadFromDataFile(java.lang.String fileName)
          Read the data from file (using the reader for specified format).
private  boolean ReadGeomViewFile(java.lang.String fileName)
          Read a geom view file.
private  boolean ReadGTSFile(java.lang.String fileName)
          Parse a GTS file and form an object.
private  boolean ReadPLYFile(java.lang.String fileName)
          Read a .ply data file.
The data file containes header lines in the beginning, until the line "end_header" appears.
private  boolean ReadPMeshFile(java.lang.String fileName)
          Parse a PMesh file and form an object.
PMesh is a file format used at the vision group at University of Edinburgh. These files have a .obj extension.
This file format is as follows:
First line contains an optional comment, beginning with #pmesh Next, the vertices are specified as v coord_x coord_y coord_z Next the faces are specified as f int_1 int_2 int_3 int_4 ...
private  boolean ReadVRMLFile(java.lang.String fileName)
           
 void RegisterProgressBar(javax.swing.JProgressBar progBar)
          Register the progress bar with data manager.
 void RequestZoomToHome(boolean zoom)
          Set a flag to request the screen zoom onto some object.
 void ResetJavaCoordUserMatrix()
          Resets the java coordinate user-specified transformation matrix.
static void ResetMatrixToUnit(float[] matrix, int row, int col)
          Reset a specified matrix to unity (identity matrix).
A[i,j] = 1 if i == j
A[i,j] = 0 if i != j
 void ResetTransMatrix()
          Resets the transformation matrix to identity matrix.
 void ResetUserDefinedTransMatrix()
          Resets the user defined transformation matrix to identity matrix.
 void ResetViewMatrix()
          Resets the view matrix to identity matrix.
private  void ScaleUserDefinedMatrix()
          Scale the user defined matrix by mZoomFactor.
 void SetOutputPanel(OutputPanel outPanel)
          Record the output panel instance, so that error info etc can be dumped onto the panel.
static void TransformPoint(float[] matrix, float[] coord, float[] outputCoord)
          Transform a point using supplied transformation matrix.
 void TranslateMatrix(float[] moveToPos)
          Constructs a translation matrix by translating the axes origin to the specified moveToPos point.
private  void UpdateViewerColorComboBox(java.lang.String fileName)
          Add combo box entries for color selection for new object.
 void ZoomInROI(float roiLen, float screenLen, float x0, float y0)
          Zoom into a drawn region of interest (ROI) on the screen.
 void ZoomOutROI(float roiLen, float screenLen, float x0, float y0)
          Zoom out of a drawn region of interest (ROI).
private  void ZoomToObject(GeomObject obj, float inset, float screenLen)
          Construct the transformation matrix in user defined coordinate transformation matrix (from scratch) so that the object obj is zoomed in (fits in smugly on the screen).
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mTransMatrix

private float[] mTransMatrix
This is the transformation matrix to convert physical coordinates to java screen coordinates (needed for drawing).
GeomDataManager class has a host of methods available to update / process this matrix.
It is formed from view matrix, user-defined transformation, java coordinate transformation, and user specified java coordinate transformation matrices (eg, zoom on screen etc) as:
mTransMatrix = mViewMatrix * mUserDefinedTransMatrix * mJavaCoordTransMatrix * mJavaCoordUserMatrix
X(screen) = X(physical)*mTransMatrix

See Also:
mViewMatrix, mUserDefinedTransMatrix, mJavaCoordTransMatrix, mJavaCoordUserMatrix

mBuf

private float[] mBuf

mCurrZoomedObject

private GeomObject mCurrZoomedObject

mUserDefinedTransMatrix

private float[] mUserDefinedTransMatrix
This is the user-defined component of transformation matrix. We need to keep a separate array for storing user defined transformations (rotation + translation + scaling) because of the update sequence and the multiplication sequence. This matrix is based on a screen centered coordinate axis. The centroid of the focussed object lies on the screen center.


mJavaCoordTransMatrix

private float[] mJavaCoordTransMatrix
This is the transformation matrix for converting device independent coordinates into java screen (device dependent) coordinates.
It first translates the axes origin from screen center to upper left corner and then flips the Y axes to negative side (this is the java screen coordinate axes).


mJavaCoordUserMatrix

private float[] mJavaCoordUserMatrix
This is the transformation matrix for transforming java screen coordinates in a user specified way.


mViewMatrix

private float[] mViewMatrix
This matrix contains the axonometric/perpective transformations.


mScene

private Scene mScene
Scene consisting of all objects.


mOutPanel

private OutputPanel mOutPanel
Output panel for writing output messages.


mProgressBar

private javax.swing.JProgressBar mProgressBar

bHome

private boolean bHome
Set this flag to true if the next redraw should zoom to the last added object.


mTransMatrixBuf

private float[] mTransMatrixBuf

mZoomFactor

private float mZoomFactor
Factor controlling the zoom level.

Constructor Detail

GeomDataManager

public GeomDataManager()
Class constructor. Method initializes the transformation matrix, view matrix, user defined transformation matrix and java coordinate transformation matrices to identity matrix.

See Also:
mTransMatrix, mViewMatrix, mUserDefinedTransMatrix, mJavaCoordTransMatrix, mJavaCoordUserMatrix
Method Detail

RequestZoomToHome

public void RequestZoomToHome(boolean zoom)
Set a flag to request the screen zoom onto some object.

Parameters:
zoom - boolean (true) indicates zoom to object, false no zoom.

IncreaseZoom

public void IncreaseZoom()
Increases the zoom level by a factor of 2.


DecreaseZoom

public void DecreaseZoom()
Decreases the zoom level by a factor of 2.


ScaleUserDefinedMatrix

private void ScaleUserDefinedMatrix()
Scale the user defined matrix by mZoomFactor.

See Also:
mZoomFactor

RegisterProgressBar

public void RegisterProgressBar(javax.swing.JProgressBar progBar)
Register the progress bar with data manager. Many jobs performed by data manager need to keep track of job status and progress. This function provides a reference to the progress bar to data manager instance.

Parameters:
progBar - Progress bar instance.

ResetTransMatrix

public void ResetTransMatrix()
Resets the transformation matrix to identity matrix.

See Also:
mTransMatrix

ResetUserDefinedTransMatrix

public void ResetUserDefinedTransMatrix()
Resets the user defined transformation matrix to identity matrix.

See Also:
mUserDefinedTransMatrix

ResetViewMatrix

public void ResetViewMatrix()
Resets the view matrix to identity matrix.

See Also:
mViewMatrix

ResetJavaCoordUserMatrix

public void ResetJavaCoordUserMatrix()
Resets the java coordinate user-specified transformation matrix.

See Also:
mJavaCoordUserMatrix

ResetMatrixToUnit

public static void ResetMatrixToUnit(float[] matrix,
                                     int row,
                                     int col)
Reset a specified matrix to unity (identity matrix).
A[i,j] = 1 if i == j
A[i,j] = 0 if i != j

Parameters:
matrix - Matrix to be reset.
row - Row number of the matrix.
col - Column number of the matrix.

AppendToUserDefinedTransMatrix

public void AppendToUserDefinedTransMatrix(float[] matrix)
Concatenate the 4X4 matrix passed as argument to the user defined transformation matrix.

Parameters:
matrix - 16 element (4X4) array.
See Also:
mUserDefinedTransMatrix

AppendToViewMatrix

public void AppendToViewMatrix(float[] matrix)
Concatenate the 4X4 view matrix (axonometric, perpective etc transformations) passed as matrix (argument) to the current view matrix.

Parameters:
matrix - 16 element (4X4) array containing only view transformation.
See Also:
mViewMatrix

AppendMatrices

public static void AppendMatrices(float[] appendToMatrix,
                                  float[] matrix,
                                  int size)
Concatenate the sizeXsize matrix to the supplied matrix. The appending step is performed by post-multiplication, i.e.
appendToMatrix = appendToMatrix * matrix

Parameters:
appendToMatrix - sizeXsize element matrix to apend another matrix to.
matrix - sizeXsize element array containing the matrix to be appended.
size - size of the matrices (row count = col count = size).

ConstructTransMatrix

public void ConstructTransMatrix()
Construct the transformation matrix using:
mTransMatrix = mViewMatrix * mUserDefinedTransMatrix * mJavaCoordTransMatrix * mJavaCoordUserMatrix
X(screen) = X(physical)*mTransMatrix

See Also:
mViewMatrix, mUserDefinedTransMatrix, mJavaCoordTransMatrix, mJavaCoordUserMatrix, mTransMatrix

ApplyTransform

public void ApplyTransform(float[] coord,
                           float[] outputCoord)
Transform a point using the current transformation matrix.

Parameters:
coord - A 3 element array having X, Y, Z coordinates.
outputCoord - A 3 element array containing output transformed coordinates.
See Also:
mTransMatrix

TransformPoint

public static void TransformPoint(float[] matrix,
                                  float[] coord,
                                  float[] outputCoord)
Transform a point using supplied transformation matrix.

Parameters:
matrix - A 16 (4X4) element array containing the transformation matrix.
coord - A 3 element array having X, Y, Z coordinates.
outputCoord - A 3 element array containing output transformed coordinates.

TranslateMatrix

public void TranslateMatrix(float[] moveToPos)
Constructs a translation matrix by translating the axes origin to the specified moveToPos point. Appens the transform to the existing transformation in mUserDefinedTransMatrix..

Parameters:
moveToPos - Array of 3 float elements specying the X, Y, Z coordinates of the translation point.
See Also:
mUserDefinedTransMatrix

ConstructJavaCoordMatrix

private void ConstructJavaCoordMatrix(float len)
Convert coordinates from mapped (device independent coordinates) to java coordinates. In Java, the axes inside a component have their origin at top left corner, wit y axis pointing down. This method converts an existing matrix into a transformation matrix such that the new origin is moved from screen center to upper left-corner with Y axis pointing downwards.

Parameters:
len - Height of screen.
See Also:
mJavaCoordTransMatrix

ConstructRotMatrix

public void ConstructRotMatrix(Defs.Axis ax,
                               float sine,
                               float cosine)
Constructs rotation transformation matrix about one of X, Y or Z axes and appends it to the current user defined matrix.

Parameters:
ax - Axis about which rotation is performed.
sine - sin() of the rotation angle.
cosine - cos() of the rotation angle.
See Also:
mUserDefinedTransMatrix, Defs.Axis

ConstructArbitRotMatrix

public void ConstructArbitRotMatrix(float[] axisDirCosine,
                                    float thetaRadian)
Constructs rotation transformation matrix about an arbitrary axis (using Rodrigues formula) and appends it to the current user defined matrix.

Parameters:
axisDirCosine - Direction cosines of the rotation axis.
thetaRadian - Rotation angle in radians.
See Also:
mUserDefinedTransMatrix

ConstructArbitRotMatrix

public void ConstructArbitRotMatrix(float[] axisDirCosine,
                                    float sine,
                                    float cosine)
Constructs rotation transformation matrix about an arbitrary axis (using Rodrigues formula) and appends it to the current user defined matrix.

Parameters:
axisDirCosine - Direction cosines of the rotation axis.
sine - sin() of the rotation axis.
cosine - cosine of rotation angle.
See Also:
mUserDefinedTransMatrix

ConstructOnePtPerspMatrix

public void ConstructOnePtPerspMatrix(float centerProj)
Constructs a one point perspective transformation matrix from the current transformation matrix.

The vanishing point is X=0, Y=0, Z=-centerProj. Hence r = -1/centerProj.

Parameters:
centerProj - Center of projection (observer's eye) along the negative Z axis. centerProj is given as a signed quantity.
See Also:
mViewMatrix

ConstructTwoPtPerspMatrix

public void ConstructTwoPtPerspMatrix(Defs.Axis ax1,
                                      Defs.Axis ax2,
                                      float center1,
                                      float center2)
Constructs a two point perspective transformation matrix from the current transformation matrix. The 2 vanishing points are: -center1 along ax1 and -center2 along ax2

Parameters:
ax1 - Axis for center of projection 1
ax2 - Axis for center of projection 2
center1 - Center of projection along ax1.
center2 - Center of projection along ax2.
See Also:
Defs.Axis, mViewMatrix

ConstructThreePtPerspMatrix

public void ConstructThreePtPerspMatrix(float center1,
                                        float center2,
                                        float center3)
Constructs a three point perspective transformation matrix from the current transformation matrix. The three vanishing points are -center1 (X axis), -center2 (Y axis), -center3 (Z axis).

Parameters:
center1 - Center of projection along the X axis.
center2 - Center of projection along the Y axis.
center3 - Center of projection along the Z axis.
See Also:
mViewMatrix

SetOutputPanel

public void SetOutputPanel(OutputPanel outPanel)
Record the output panel instance, so that error info etc can be dumped onto the panel.

Parameters:
outPanel - Instance of OutputPanel used on the main viewer.
See Also:
OutputPanel

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

ZoomToObject

private void ZoomToObject(GeomObject obj,
                          float inset,
                          float screenLen)
Construct the transformation matrix in user defined coordinate transformation matrix (from scratch) so that the object obj is zoomed in (fits in smugly on the screen).

Parameters:
obj - object to zoom to.
inset - Inset for drawing area on the drawing canvas.
screenLen - Length of the screen (minimum of length and width of drawing area, namely the DrawingCanvas).
See Also:
mUserDefinedTransMatrix

ZoomInROI

public void ZoomInROI(float roiLen,
                      float screenLen,
                      float x0,
                      float y0)
Zoom into a drawn region of interest (ROI) on the screen. Screen is square, and so is ROI to prevent any distortion due to unequal scaling along X and Y axes.
Appends the matrix to current mJavaCoordUserMatrix.

For this case screenLen >= roiLen

Parameters:
roiLen - Length of region of interest (square)
screenLen - Length of screen
x0 - X Coordinate of upper left corner of ROI
y0 - Y Coordinate of upper left corner of ROI (region of interest).
See Also:
mJavaCoordUserMatrix

ZoomOutROI

public void ZoomOutROI(float roiLen,
                       float screenLen,
                       float x0,
                       float y0)
Zoom out of a drawn region of interest (ROI). Screen is square, and so is ROI to prevent any distortion due to unequal scaling along X and Y axes.
Appends the matrix to current mJavaCoordUserMatrix.

For this case screenLen >= roiLen

Parameters:
roiLen - Length of region of interest (square)
screenLen - Length of screen
x0 - X Coordinate of upper left corner of ROI
y0 - Y Coordinate of upper left corner of ROI (region of interest).
See Also:
mJavaCoordUserMatrix

PanRight

public void PanRight(float dist)
Pan to right of the currently (drawn) image.
Appends the matrix to current mJavaCoordUserMatrix.

Parameters:
dist - Distance by which to transpose.
See Also:
mJavaCoordUserMatrix

PanLeft

public void PanLeft(float dist)
Pan to left of the currently (drawn) image.
Appends the matrix to current mJavaCoordUserMatrix.

Parameters:
dist - Distance by which to transpose.
See Also:
mJavaCoordUserMatrix

PanDown

public void PanDown(float dist)
Pan to bottom of the currently (drawn) image.
Appends the matrix to current mJavaCoordUserMatrix.

Parameters:
dist - Distance by which to transpose.
See Also:
mJavaCoordUserMatrix

PanUp

public void PanUp(float dist)
Pan upwards of the currently (drawn) image.

Parameters:
dist - Distance by which to transpose.
See Also:
mJavaCoordUserMatrix

FormCompleteTransformationMatrix

private void FormCompleteTransformationMatrix(float inset,
                                              float screenLen,
                                              GeomObject obj)
Form complete transformation matrix in mTransMatrix.

Parameters:
inset - insets inside the drawing area.
screenLen - length of the drawing area (canvas).
obj - Object to focus the screen to.
See Also:
mTransMatrix

GetCurrZoomedObject

public GeomObject GetCurrZoomedObject()
Get the object that is currently focused on the screen (was zoomed to most recently).

Returns:
GeomObject that was zoomed to last on the screen, or null if no object has been loaded.
See Also:
GeomObject

MeasureDistance

public float MeasureDistance(int x1,
                             int y1,
                             int x2,
                             int y2)
Measure the distance in physical coordinates between two points whose screen coordinates are known. Z coordinate of both these points is assumed to be 0 (screen is located at z = 0).

Parameters:
x1 - x coordinate of point 1 (in screen units, i.e. pixels)
y1 - y coordinate of point 1 (in screen units, i.e. pixels)
x2 - x coordinate of point 2 (in screen units, i.e. pixels)
y2 - y coordinate of point 2 (in screen units, i.e. pixels)
Returns:
distance in physical coordinates.

CutObjectIn3D

public void CutObjectIn3D(int x1,
                          int y1,
                          int x2,
                          int y2)

CutObject

public void CutObject(int x1,
                      int y1,
                      int x2,
                      int y2)

DrawWireFrame

public void DrawWireFrame(DrawingCanvas canvas,
                          java.awt.Graphics g)
Draw wire frame picture of the scene. Relays the request to scene, after adding transformation matrix.

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

DrawSurface

public void DrawSurface(DrawingCanvas canvas,
                        java.awt.Graphics g)
Draw the surface of objects comprising the scene. Relays the request to scene, after adding transformation matrix.

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

DrawSurfaceOnly

public void DrawSurfaceOnly(DrawingCanvas canvas,
                            java.awt.Graphics g)
Draw only the surface (no edges) of objects comprising the scene. Relays the request to scene, after adding transformation matrix.

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

DrawCrinkleCut

public void DrawCrinkleCut(DrawingCanvas canvas,
                           java.awt.Graphics g,
                           float[] plane)
Draw the face of objects in the scene cut by a specified cutting plane. Relays the request to scene, after adding transformation matrix.
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).
See Also:
DrawingCanvas, Scene

DrawCameraImage

public void DrawCameraImage(DrawingCanvas canvas,
                            java.awt.Graphics g,
                            float[] camera_coor,
                            float[] center_proj,
                            boolean onlySurface,
                            boolean onlyWireframe)
Draws the surface or wirefrane model with camera positioned at (X, Y, Z) and center of projection at (x1, y1, z1). 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 and for drawing perspective views


The center of projection is at (x1, y1, z1). This method always points the camera along +Z direction.

Parameters:
canvas - Instance of DrawingCanvas on which drawing is drawn.
g - Graphics instance used in drawing.
camera_coor - (X, Y, Z) coordinates of the camera (observation) point Coordinates are in physical dimensions (not transformed)
center_proj - (x1, y1, z1) center of projection
onlySurface - true if only surface (no edges) are to be drawn, false otherwise (surface and edges drawn). If this field is true, onlyWireframe must be false.
onlyWireframe - true if only wireframe model needed, else false
See Also:
DrawingCanvasInterface, DrawingCanvas

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)

UpdateViewerColorComboBox

private void UpdateViewerColorComboBox(java.lang.String fileName)
Add combo box entries for color selection for new object.

Parameters:
fileName - Name of file.
See Also:
ViewerInterface.AddToColorComboBox(String)

ReadFromDataFile

public boolean ReadFromDataFile(java.lang.String fileName)
Read the data from file (using the reader for specified format).

Parameters:
fileName - Name of the file
Returns:
boolean true if file reading and parsing was successful, false otherwise.

ReadPMeshFile

private boolean ReadPMeshFile(java.lang.String fileName)
                       throws java.io.FileNotFoundException,
                              java.io.IOException
Parse a PMesh file and form an object.
PMesh is a file format used at the vision group at University of Edinburgh. These files have a .obj extension.
This file format is as follows:
First line contains an optional comment, beginning with #pmesh Next, the vertices are specified as v coord_x coord_y coord_z Next the faces are specified as f int_1 int_2 int_3 int_4 ... The integer indices are vertex indices (vertices ordered in the order they are listed). The numbering starts at 1.
For example:
#pmesh file
v 12 1.2 4.1
...
v 4 5 6
f 1 2 3 5 8
...

Parameters:
fileName - Name of file.
Returns:
true if file read successfully, false otherwise.
Throws:
java.io.FileNotFoundException
java.io.IOException
See Also:
TriangulatedObject

ReadGeomViewFile

private boolean ReadGeomViewFile(java.lang.String fileName)
                          throws java.io.FileNotFoundException,
                                 java.io.IOException
Read a geom view file. GeomView format:
OFF
# comment lines begin with # sign
number_of_vertices number_of_faces number
vertex_1_X vertex_1_Y vertex_1_Z
...
vertex_last_X vertex_last_Y vertex_last_Z
face_1_num_vertices face_1_vertex_1_index ... face_1_vertex_last_index color_red color_green color_blue
...
face_last_num_vertices face_last_vertex_1_index ... face_last_vertex_last_index Color_red Color_green Color_blue
Vertex indices start from 0. Currently, the face color is ignored.

Parameters:
fileName - Name of file.
Returns:
true if file read successfully, false otherwise.
Throws:
java.io.FileNotFoundException
java.io.IOException

ReadANSFile

private boolean ReadANSFile(java.lang.String fileName)
                     throws java.io.FileNotFoundException,
                            java.io.IOException
Read a .ans ANSYS generated file.
The file contains header lines in the beginning, followed by a vertex definition block which is followed by a cell definition block. Vertex block consists of lines like:
 N,vertex_number,vert_x,vert_y,vert_z
 

The face definition block consists of lines like:
 EN,cell_number,cell_vert_1,cell_vert_2,...,cell_vert_n
 

The cells can be tetrahedron, cube, or hexahedron. Currently this file reader supports only terahedron elements. Faces of this tetrahedron can be inferred (4 triplets).

All numbering begins at 1.

Parameters:
fileName - Name of file.
Returns:
true if file read successfully, false otherwise.
Throws:
java.io.FileNotFoundException
java.io.IOException

ReadPLYFile

private boolean ReadPLYFile(java.lang.String fileName)
                     throws java.io.FileNotFoundException,
                            java.io.IOException
Read a .ply data file.
The data file containes header lines in the beginning, until the line "end_header" appears. Beyond this line, there are lines equal to the number of vertices containing the three vertex coordinates. After this, there are lines equal to the number of faces describing the faces. Each face line follows the pattern:
number_of_vertices_in_face face_vertex_1 face_vertex_2 ... example ply format file
ply
comment comment line
comment file written by tool ...
comment ...
end_header
vertex_1_coor_x vertex_1_coor_y vertex_1_coor_z ... face_1_num_vertices face_1_vertex_1_index ... face_1_vertex_last_index color_red color_green color_blue
...
face_last_num_vertices face_last_vertex_1_index ... face_last_vertex_last_index
Vertex indices start from 0.

Parameters:
fileName - Name of file.
Returns:
true if file read successfully, false otherwise.
Throws:
java.io.FileNotFoundException
java.io.IOException

ReadVRMLFile

private boolean ReadVRMLFile(java.lang.String fileName)
                      throws java.io.FileNotFoundException,
                             java.io.IOException
Throws:
java.io.FileNotFoundException
java.io.IOException

ReadDatFile

private boolean ReadDatFile(java.lang.String fileName)
                     throws java.io.FileNotFoundException,
                            java.io.IOException
Parse the file having cell, face, edge, vertex info. Format of the file is:
Cell num:
  fc_1_num fc_2_num ...
Face num:
  edge_1_num edge_2_num ...
Edge num:
  vertex_1_num vertex_2_num
Vertex num:
  x_coor y_coor z_coor
The routine keeps all (internal and external) faces.

Parameters:
fileName - Name of file.
Returns:
true if file read successfully, false otherwise.
Throws:
java.io.FileNotFoundException
java.io.IOException

ReadGTSFile

private boolean ReadGTSFile(java.lang.String fileName)
                     throws java.io.FileNotFoundException,
                            java.io.IOException
Parse a GTS file and form an object. (@see GeomRep.TriangulatedObject) Format of a GTS file is:

The first line contains three unsigned integers separated by spaces. The first integer is the number of vertices (let us denote it by nv), the second is the number of edges, ne, and the third is the number of faces, nf. The following nv lines contain the x, y and z coordinates for each of the nv vertices. The next ne lines contain the two indices (starting from 1) of the vertices forming an edge. The third part of the file contains nf lines with ordered (clockwise or anticlockwise, but vertices must be contiguous in face) indices (also starting from 1) of the edges for each of the faces.

int_num_vertices int_num_edges int_num_faces
X1 Y1 Z1
...
Xnum_vertices Ynum_vertices Znum_vertices
edge_1_vertex_1 edge_1_vertex_2
...
edge_num_edges_vertex_1 edge_num_edges_vertex_2
face_1_edge_1 ... face_1_edge_n
...
face_num_faces_edge_1 ... face_num_edges_edge_n

Parameters:
fileName - Name of file.
Returns:
true if file read successfully, false otherwise.
Throws:
java.io.FileNotFoundException
java.io.IOException

ReadCFEVFile

private boolean ReadCFEVFile(java.lang.String fileName)
                      throws java.io.FileNotFoundException,
                             java.io.IOException
Parse the file having cell, face, edge, vertex info. This file reader will eliminate all internal faces. To keep internal faces, use the ReadDATFile reader Format of the file is:
Cell num:
  fc_1_num fc_2_num ...
Face num:
  edge_1_num edge_2_num ...
Edge num:
  vertex_1_num vertex_2_num
Vertex num:
  x_coor y_coor z_coor
The routine finds the boundary faces (which is what gets drawn)

Parameters:
fileName - Name of file.
Returns:
true if file read successfully, false otherwise.
Throws:
java.io.FileNotFoundException
java.io.IOException