GridView
Class MeshFileReader

java.lang.Object
  extended by GridView.MeshFileReader

public class MeshFileReader
extends java.lang.Object

Class for reading various file formats.

This class contains public static methods for reading and parsing mesh information from files of different format.

Since:
1.0
See Also:
GeomObject

Constructor Summary
MeshFileReader()
           
 
Method Summary
private static boolean FaceSeenBefore(int[] triangleVert, java.util.Map<java.lang.String,java.lang.Integer> fcMap, StringWrapper fcMapKey)
           
static TriangulatedObject ReadANSFile(java.lang.String fileName, OutputPanel outPanel, javax.swing.JProgressBar progressBar)
          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.
static TriangulatedObject ReadCFEVFile(java.lang.String fileName, OutputPanel outPanel, javax.swing.JProgressBar progressBar)
          Parse the file having cell, face, edge, vertex info.
static TriangulatedObject ReadDatFile(java.lang.String fileName, OutputPanel outPanel, javax.swing.JProgressBar progressBar)
          Parse the file having cell, face, edge, vertex info.
static TriangulatedObject ReadGeomViewFile(java.lang.String fileName, OutputPanel outPanel, javax.swing.JProgressBar progressBar)
          Read a geom view file.
static TriangulatedObject ReadGTSFile(java.lang.String fileName, OutputPanel outPanel, javax.swing.JProgressBar progressBar)
          Parse a GTS file and form an object.
static TriangulatedObject ReadPLYFile(java.lang.String fileName, OutputPanel outPanel, javax.swing.JProgressBar progressBar)
          Read a .ply data file.
The data file containes header lines in the beginning, until the line "end_header" appears.
static TriangulatedObject ReadPMeshFile(java.lang.String fileName, OutputPanel outPanel, javax.swing.JProgressBar progressBar)
          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 ...
static TriangulatedObject ReadVRMLFile(java.lang.String fileName, OutputPanel outPanel, javax.swing.JProgressBar progressBar)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MeshFileReader

public MeshFileReader()
Method Detail

ReadPMeshFile

public static TriangulatedObject ReadPMeshFile(java.lang.String fileName,
                                               OutputPanel outPanel,
                                               javax.swing.JProgressBar progressBar)
                                        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.
outPanel - output panel for writing messages
progressBar - for indicating progress of file-reading
Returns:
trObj if file read successfully, false otherwise.
Throws:
java.io.FileNotFoundException
java.io.IOException
See Also:
TriangulatedObject

ReadGeomViewFile

public static TriangulatedObject ReadGeomViewFile(java.lang.String fileName,
                                                  OutputPanel outPanel,
                                                  javax.swing.JProgressBar progressBar)
                                           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.
outPanel - output panel for writing messages
progressBar - for indicating progress of file-reading
Returns:
trObj if file read successfully, false otherwise.
Throws:
java.io.FileNotFoundException
java.io.IOException

ReadANSFile

public static TriangulatedObject ReadANSFile(java.lang.String fileName,
                                             OutputPanel outPanel,
                                             javax.swing.JProgressBar progressBar)
                                      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.
outPanel - output panel for writing messages
progressBar - for indicating progress of file-reading
Returns:
TriangulatedObject if file read successful, null otherwise.
Throws:
java.io.FileNotFoundException
java.io.IOException

ReadPLYFile

public static TriangulatedObject ReadPLYFile(java.lang.String fileName,
                                             OutputPanel outPanel,
                                             javax.swing.JProgressBar progressBar)
                                      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.
outPanel - output panel for writing messages
progressBar - for indicating progress of file-reading
Returns:
TriangulatedObject if file read successful, null otherwise.
Throws:
java.io.FileNotFoundException
java.io.IOException

ReadVRMLFile

public static TriangulatedObject ReadVRMLFile(java.lang.String fileName,
                                              OutputPanel outPanel,
                                              javax.swing.JProgressBar progressBar)
                                       throws java.io.FileNotFoundException,
                                              java.io.IOException
Throws:
java.io.FileNotFoundException
java.io.IOException

ReadDatFile

public static TriangulatedObject ReadDatFile(java.lang.String fileName,
                                             OutputPanel outPanel,
                                             javax.swing.JProgressBar progressBar)
                                      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.
outPanel - output panel for writing messages
progressBar - for indicating progress of file-reading
Returns:
TriangulatedObject if file read successful, null otherwise
Throws:
java.io.FileNotFoundException
java.io.IOException

ReadGTSFile

public static TriangulatedObject ReadGTSFile(java.lang.String fileName,
                                             OutputPanel outPanel,
                                             javax.swing.JProgressBar progressBar)
                                      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.
outPanel - output panel for writing messages
progressBar - for indicating progress of file-reading
Returns:
TriangulatedObject if file read successful, null otherwise
Throws:
java.io.FileNotFoundException
java.io.IOException

ReadCFEVFile

public static TriangulatedObject ReadCFEVFile(java.lang.String fileName,
                                              OutputPanel outPanel,
                                              javax.swing.JProgressBar progressBar)
                                       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.
outPanel - output panel for writing messages
progressBar - for indicating progress of file-reading
Returns:
TriangulatedObject if file read successful, null otherwise
Throws:
java.io.FileNotFoundException
java.io.IOException

FaceSeenBefore

private static boolean FaceSeenBefore(int[] triangleVert,
                                      java.util.Map<java.lang.String,java.lang.Integer> fcMap,
                                      StringWrapper fcMapKey)