|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectmr3d.debug.ErrorHandling
mr3d.io.TriangleBasedModelReader
The class TriangleBasedModelReader is an implementation of
mr3d.io.FileReader for reading 3D models from file.
This reader reads triangle based model data according to the
mr3d-standard.
The following example shows a sample file, which
TriangleBasedModelReader
is able to read.
Author: Manuel Rülke
Date: 02.09.2004
Description:
This file is an example to demonstrate the syntax
of the m3rd description language. This file
constructs a triangular pyramid from four points.
{
points
ReferencePoint(25,25,50)
Punkt1(0,0,0)
Punkt2(100,0,0)
Punkt3(0,0,100)
Punkt4(0,100,100)
end
edges
Kante1(Punkt1,Punkt2)
Kante2(Punkt2,Punkt4)
Kante3(Punkt4,Punkt1)
Kante4(Punkt2,Punkt3)
Kante5(Punkt3,Punkt4)
Kante6(Punkt4,Punkt2)
Kante7(Punkt3,Punkt1)
Kante8(Punkt1,Punkt4)
Kante9(Punkt4,Punkt3)
Kante10(Punkt1,Punkt3)
Kante11(Punkt3,Punkt2)
Kante12(Punkt2,Punkt1)
end
colors
Farbe1(16700255)
Farbe2(9956516)
Farbe3(16100878)
Farbe4(10100878)
end
planes
Fläche1(Kante1, Kante2, Kante3) Farbe1
Fläche2(Kante4, Kante5, Kante6) Farbe2
Fläche3(Kante7, Kante8, Kante9) Farbe3
Fläche4(Kante10, Kante11, Kante12) Farbe4
end
}
footnote: This object an example for is the simplest
complete consistent implementation of an 3D model
created with the mr3d-standard.
| Field Summary | |
private int |
colorsAt
Line number of the first line of this data part. |
private DynamicStringArray |
data
Contains the data read from the file. |
private boolean |
debugMode
Is true when debug mode is on. |
private int |
edgesAt
Line number of the first line of this data part. |
private boolean |
errorBreak
Is true when an error occured. |
private java.lang.String |
fileName
Name of the file to be read |
private java.io.InputStream |
inputFile
InputStream created from the file specified in fileName. |
private DynamicIntArray |
linearIndices
Contains the linear index of the first element of each line. |
private int |
planesAt
Line number of the first line of this data part. |
private int |
pointsAt
Line number of the first line of this data part. |
| Fields inherited from class mr3d.debug.ErrorHandling |
|
| Fields inherited from interface mr3d.debug.Debugable |
ERROR_INT, ERROR_STRING |
| Constructor Summary | |
TriangleBasedModelReader(java.lang.String filename)
Creates a new TriangleBasedModelReader. |
|
TriangleBasedModelReader(java.lang.String filename,
java.lang.String debug)
Creates a new TriangleBasedModelReader with
the possibility to set the reader into debug mode. |
|
| Method Summary | |
private void |
checkData()
|
void |
dispose()
Deletes all data aquired from the file. |
private java.lang.String |
get(int line,
int column)
Returns the elements stored in the data vector at the
specified line and column. |
private int |
getColorValue(java.lang.String ColorName)
Returns the color value of the specified color id String |
private java.lang.String |
getEdgeEndPoint(java.lang.String edgeID)
Returns the end point of the edge with the specified id String. |
private java.lang.String |
getEdgeStartPoint(java.lang.String edgeID)
Returns the start point of the edge with the specified id String. |
int |
getNrOfPoints()
Returns the number of points in the object. |
int |
getNrOfTriangles()
Returns the number of triangles in the object. |
int[] |
getPoint(int index)
Returns the point with the specified index. |
private int |
getPointIndex(java.lang.String id)
Returns the linear index of the point within in the data vector having specified identification. |
int[][] |
getTriangle(int nr)
Returns data to construct a 3D triangle from. |
private java.lang.String |
getTriangleID(int index)
Returns the id of the triangle with the specified index. |
boolean |
hasErrors()
Determines if an error occured in processing the object. |
private void |
readFile()
Start the reading process to access the data in the file specified in filename. |
private int |
size()
Returns the number of elements in the data array. |
private void |
stopOnError()
Sets the errorBreak-value to true. hasErrors() returns "true" after this method is called. |
void |
toConsole()
Prints the contents of the object to the Java console. |
void |
toConsole(java.lang.String msgString)
Prints the contents of the object to the Java console together with an information string. |
| Methods inherited from class mr3d.debug.ErrorHandling |
getErrMsg, notifyError |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private int colorsAt
private DynamicStringArray data
private boolean debugMode
private int edgesAt
private boolean errorBreak
private java.lang.String fileName
private java.io.InputStream inputFile
InputStream created from the file specified in fileName.
private DynamicIntArray linearIndices
data-vector.
private int planesAt
private int pointsAt
| Constructor Detail |
public TriangleBasedModelReader(java.lang.String filename)
throws java.io.IOException
TriangleBasedModelReader.
filename - name of the file that should be loaded
public TriangleBasedModelReader(java.lang.String filename,
java.lang.String debug)
throws java.io.IOException
TriangleBasedModelReader with
the possibility to set the reader into debug mode.
filename - name of the file that should be loadeddebug - if this String equals "debug" the reader
will be set into debugging mode.| Method Detail |
private void checkData()
public void dispose()
dispose in interface FileReader
private java.lang.String get(int line,
int column)
data vector at the
specified line and column.
line - line number of the desired entrycolumn - column of the the desired entry
private int getColorValue(java.lang.String ColorName)
String
private java.lang.String getEdgeEndPoint(java.lang.String edgeID)
String.
edgeID - id of the edge as specified in the mr3d-file
String of the end pointprivate java.lang.String getEdgeStartPoint(java.lang.String edgeID)
String.
edgeID - id of the edge as specified in the mr3d-file
String of the start pointpublic int getNrOfPoints()
getNrOfPoints in interface FileReaderpublic int getNrOfTriangles()
getNrOfTriangles in interface FileReaderpublic int[] getPoint(int index)
getPoint in interface FileReaderindex - index of the pointprivate int getPointIndex(java.lang.String id)
ERR_INT
when no point is found with this id.
id - ID-string of the pointpublic int[][] getTriangle(int nr)
FileReaderThe array is constructed as follows:
[0][0] = id of start point of edge 1
[0][1] = id of end point of edge 1
[1][0] = id of start point of edge 2
[1][1] = id of end point of edge 2
[2][0] = id of start point of edge 3
[2][1] = id of end point of edge 3
[3][0] = triangle color
getTriangle in interface FileReadernr - number of the triangle in the file
int containg the point array
indices of the start and end points of the three
edges of a triangle.private java.lang.String getTriangleID(int index)
index - index of the trainglepublic boolean hasErrors()
hasErrors in interface FileReadertrue if an error has occured, false
if everything is ok
private void readFile()
throws java.io.IOException
filename.
java.io.IOExceptionprivate int size()
private void stopOnError()
public void toConsole()
Debugable
toConsole in interface Debugablepublic void toConsole(java.lang.String msgString)
Debugable
toConsole in interface Debugable
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||