|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectGridView.GeomDataManager
public class GeomDataManager
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.
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 |
---|
private float[] mTransMatrix
mViewMatrix
,
mUserDefinedTransMatrix
,
mJavaCoordTransMatrix
,
mJavaCoordUserMatrix
private float[] mBuf
private GeomObject mCurrZoomedObject
private float[] mUserDefinedTransMatrix
private float[] mJavaCoordTransMatrix
private float[] mJavaCoordUserMatrix
private float[] mViewMatrix
private Scene mScene
private OutputPanel mOutPanel
private javax.swing.JProgressBar mProgressBar
private boolean bHome
private float[] mTransMatrixBuf
private float mZoomFactor
Constructor Detail |
---|
public GeomDataManager()
mTransMatrix
,
mViewMatrix
,
mUserDefinedTransMatrix
,
mJavaCoordTransMatrix
,
mJavaCoordUserMatrix
Method Detail |
---|
public void RequestZoomToHome(boolean zoom)
zoom
- boolean (true) indicates zoom to object, false no zoom.public void IncreaseZoom()
public void DecreaseZoom()
private void ScaleUserDefinedMatrix()
mZoomFactor
public void RegisterProgressBar(javax.swing.JProgressBar progBar)
progBar
- Progress bar instance.public void ResetTransMatrix()
mTransMatrix
public void ResetUserDefinedTransMatrix()
mUserDefinedTransMatrix
public void ResetViewMatrix()
mViewMatrix
public void ResetJavaCoordUserMatrix()
mJavaCoordUserMatrix
public static void ResetMatrixToUnit(float[] matrix, int row, int col)
matrix
- Matrix to be reset.row
- Row number of the matrix.col
- Column number of the matrix.public void AppendToUserDefinedTransMatrix(float[] matrix)
matrix
- 16 element (4X4) array.mUserDefinedTransMatrix
public void AppendToViewMatrix(float[] matrix)
matrix
- 16 element (4X4) array containing only view
transformation.mViewMatrix
public static void AppendMatrices(float[] appendToMatrix, float[] matrix, int size)
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).public void ConstructTransMatrix()
mViewMatrix
,
mUserDefinedTransMatrix
,
mJavaCoordTransMatrix
,
mJavaCoordUserMatrix
,
mTransMatrix
public void ApplyTransform(float[] coord, float[] outputCoord)
coord
- A 3 element array having X, Y, Z coordinates.outputCoord
- A 3 element array containing output
transformed coordinates.mTransMatrix
public static void TransformPoint(float[] matrix, float[] coord, float[] outputCoord)
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.public void TranslateMatrix(float[] moveToPos)
moveToPos
- Array of 3 float elements specying the X, Y, Z coordinates of the translation point.mUserDefinedTransMatrix
private void ConstructJavaCoordMatrix(float len)
len
- Height of screen.mJavaCoordTransMatrix
public void ConstructRotMatrix(Defs.Axis ax, float sine, float cosine)
ax
- Axis about which rotation is performed.sine
- sin() of the rotation angle.cosine
- cos() of the rotation angle.mUserDefinedTransMatrix
,
Defs.Axis
public void ConstructArbitRotMatrix(float[] axisDirCosine, float thetaRadian)
axisDirCosine
- Direction cosines of the rotation axis.thetaRadian
- Rotation angle in radians.mUserDefinedTransMatrix
public void ConstructArbitRotMatrix(float[] axisDirCosine, float sine, float cosine)
axisDirCosine
- Direction cosines of the rotation axis.sine
- sin() of the rotation axis.cosine
- cosine of rotation angle.mUserDefinedTransMatrix
public void ConstructOnePtPerspMatrix(float centerProj)
The vanishing point is X=0, Y=0, Z=-centerProj. Hence r = -1/centerProj.
centerProj
- Center of projection (observer's eye) along the negative Z axis. centerProj is given as a signed quantity.mViewMatrix
public void ConstructTwoPtPerspMatrix(Defs.Axis ax1, Defs.Axis ax2, float center1, float center2)
ax1
- Axis for center of projection 1ax2
- Axis for center of projection 2center1
- Center of projection along ax1.center2
- Center of projection along ax2.Defs.Axis
,
mViewMatrix
public void ConstructThreePtPerspMatrix(float center1, float center2, float center3)
center1
- Center of projection along the X axis.center2
- Center of projection along the Y axis.center3
- Center of projection along the Z axis.mViewMatrix
public void SetOutputPanel(OutputPanel outPanel)
outPanel
- Instance of OutputPanel used on the main viewer.OutputPanel
protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
private void ZoomToObject(GeomObject obj, float inset, float screenLen)
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).mUserDefinedTransMatrix
public void ZoomInROI(float roiLen, float screenLen, float x0, float y0)
For this case screenLen >= roiLen
roiLen
- Length of region of interest (square)screenLen
- Length of screenx0
- X Coordinate of upper left corner of ROIy0
- Y Coordinate of upper left corner of ROI (region of
interest).mJavaCoordUserMatrix
public void ZoomOutROI(float roiLen, float screenLen, float x0, float y0)
For this case screenLen >= roiLen
roiLen
- Length of region of interest (square)screenLen
- Length of screenx0
- X Coordinate of upper left corner of ROIy0
- Y Coordinate of upper left corner of ROI (region of
interest).mJavaCoordUserMatrix
public void PanRight(float dist)
dist
- Distance by which to transpose.mJavaCoordUserMatrix
public void PanLeft(float dist)
dist
- Distance by which to transpose.mJavaCoordUserMatrix
public void PanDown(float dist)
dist
- Distance by which to transpose.mJavaCoordUserMatrix
public void PanUp(float dist)
dist
- Distance by which to transpose.mJavaCoordUserMatrix
private void FormCompleteTransformationMatrix(float inset, float screenLen, GeomObject obj)
inset
- insets inside the drawing area.screenLen
- length of the drawing area (canvas).obj
- Object to focus the screen to.mTransMatrix
public GeomObject GetCurrZoomedObject()
GeomObject
public float MeasureDistance(int x1, int y1, int x2, int y2)
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)
public void CutObjectIn3D(int x1, int y1, int x2, int y2)
public void CutObject(int x1, int y1, int x2, int y2)
public void DrawWireFrame(DrawingCanvas canvas, java.awt.Graphics g)
canvas
- Instance of DrawingCanvas object (needed for converting to screen coordinates).g
- Graphics instance onto which the drawing needs to be done.DrawingCanvas
,
Scene
public void DrawSurface(DrawingCanvas canvas, java.awt.Graphics g)
canvas
- Instance of DrawingCanvas object (needed for converting to screen coordinates).g
- Graphics instance onto which the drawing needs to be done.DrawingCanvas
,
Scene
public void DrawSurfaceOnly(DrawingCanvas canvas, java.awt.Graphics g)
canvas
- Instance of DrawingCanvas object (needed for converting to screen coordinates).g
- Graphics instance onto which the drawing needs to be done.DrawingCanvas
,
Scene
public void DrawCrinkleCut(DrawingCanvas canvas, java.awt.Graphics g, float[] plane)
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).DrawingCanvas
,
Scene
public void DrawCameraImage(DrawingCanvas canvas, java.awt.Graphics g, float[] camera_coor, float[] center_proj, boolean onlySurface, boolean onlyWireframe)
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
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 projectiononlySurface
- 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 falseDrawingCanvasInterface
,
DrawingCanvas
public GeomObject GetObjectFromFileName(java.lang.String shortFileName)
shortFileName
- Last part of file name, eg: /path/file.gts
will have a short file name of file.gts
GeomObject
public boolean DeleteObject(java.lang.String shortFileName)
private void UpdateViewerColorComboBox(java.lang.String fileName)
fileName
- Name of file.ViewerInterface.AddToColorComboBox(String)
public boolean ReadFromDataFile(java.lang.String fileName)
fileName
- Name of the file
private boolean ReadPMeshFile(java.lang.String fileName) throws java.io.FileNotFoundException, java.io.IOException
fileName
- Name of file.
java.io.FileNotFoundException
java.io.IOException
TriangulatedObject
private boolean ReadGeomViewFile(java.lang.String fileName) throws java.io.FileNotFoundException, java.io.IOException
fileName
- Name of file.
java.io.FileNotFoundException
java.io.IOException
private boolean ReadANSFile(java.lang.String fileName) throws java.io.FileNotFoundException, java.io.IOException
N,vertex_number,vert_x,vert_y,vert_z
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).
fileName
- Name of file.
java.io.FileNotFoundException
java.io.IOException
private boolean ReadPLYFile(java.lang.String fileName) throws java.io.FileNotFoundException, java.io.IOException
fileName
- Name of file.
java.io.FileNotFoundException
java.io.IOException
private boolean ReadVRMLFile(java.lang.String fileName) throws java.io.FileNotFoundException, java.io.IOException
java.io.FileNotFoundException
java.io.IOException
private boolean ReadDatFile(java.lang.String fileName) throws java.io.FileNotFoundException, java.io.IOException
fileName
- Name of file.
java.io.FileNotFoundException
java.io.IOException
private boolean ReadGTSFile(java.lang.String fileName) throws java.io.FileNotFoundException, java.io.IOException
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
fileName
- Name of file.
java.io.FileNotFoundException
java.io.IOException
private boolean ReadCFEVFile(java.lang.String fileName) throws java.io.FileNotFoundException, java.io.IOException
fileName
- Name of file.
java.io.FileNotFoundException
java.io.IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |