j3d.org Code

org.j3d.loaders.obj
Class OBJFileReader

java.lang.Object
  extended by org.j3d.loaders.obj.OBJFileReader

public class OBJFileReader
extends java.lang.Object

Class to read OBJ files. Usage: First create a OBJFileReader object. To obtain the number of objects, name of objects and number of facets for each object use the appropriate methods. Then use the #getNextFacet method repetitively to obtain the geometric data for each facet. Call close() to free the resources.

In case that the file uses the binary OBJ format, no check can be done to assure that the file is in OBJ format. A wrong format will only be recognized if an invalid amount of data is contained in the file.

Version:
$Revision: 1.3 $
Author:
Alan Hudson

Constructor Summary
OBJFileReader(java.io.File file)
          Creates a OBJFileReader object to read a OBJ file from a file.
OBJFileReader(java.io.File file, java.awt.Component parentComponent)
          Creates a OBJFileReader object to read a OBJ file from a file.
OBJFileReader(java.io.File file, java.awt.Component parentComponent, boolean strict)
          Creates a OBJFileReader object to read a OBJ file from a file.
OBJFileReader(java.lang.String fileName)
          Creates a OBJFileReader object to read a OBJ file from a file.
OBJFileReader(java.lang.String fileName, boolean strict)
          Creates a OBJFileReader object to read a OBJ file from a file.
OBJFileReader(java.lang.String fileName, java.awt.Component parentComponent)
          Creates a OBJFileReader object to read a OBJ file from a file.
OBJFileReader(java.lang.String fileName, java.awt.Component parentComponent, boolean strict)
          Creates a OBJFileReader object to read a OBJ file from a file.
OBJFileReader(java.net.URL url)
          Creates a OBJFileReader object to read a OBJ file from an URL.
OBJFileReader(java.net.URL url, boolean strict)
          Creates a OBJFileReader object to read a OBJ file from an URL.
OBJFileReader(java.net.URL url, java.awt.Component parentComponent)
          Creates a OBJFileReader object to read a OBJ file from an URL.
OBJFileReader(java.net.URL url, java.awt.Component parentComponent, boolean strict)
          Creates a OBJFileReader object to read a OBJ file from an URL.
 
Method Summary
 void close()
          Releases used resources.
 GeometryData getNextObject()
          Get the next object in the stream.
 java.util.List<java.lang.String> getParsingMessages()
          Get detailed messages on what was wrong when parsing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OBJFileReader

public OBJFileReader(java.io.File file)
              throws InvalidFormatException,
                     java.io.IOException
Creates a OBJFileReader object to read a OBJ file from a file. The data may be in ASCII or binary format.

Parameters:
file - File object of OBJ file to read.
Throws:
InvalidFormatException - The file was structurally incorrect
java.io.IOException

OBJFileReader

public OBJFileReader(java.lang.String fileName)
              throws InvalidFormatException,
                     java.io.IOException
Creates a OBJFileReader object to read a OBJ file from a file. The data may be in ASCII or binary format.

Parameters:
fileName - Name of OBJ file to read.
Throws:
InvalidFormatException - The file was structurally incorrect
java.io.IOException

OBJFileReader

public OBJFileReader(java.lang.String fileName,
                     boolean strict)
              throws InvalidFormatException,
                     java.io.IOException
Creates a OBJFileReader object to read a OBJ file from a file. The data may be in ASCII or binary format.

Parameters:
fileName - Name of OBJ file to read.
strict - Attempt to deal with crappy data or short downloads. Will try to return any useable geometry.
Throws:
InvalidFormatException - The file was structurally incorrect
java.io.IOException

OBJFileReader

public OBJFileReader(java.net.URL url)
              throws InvalidFormatException,
                     java.io.IOException
Creates a OBJFileReader object to read a OBJ file from an URL. The data may be in ASCII or binary format.

Parameters:
url - URL of OBJ file to read.
Throws:
InvalidFormatException - The file was structurally incorrect
java.io.IOException

OBJFileReader

public OBJFileReader(java.net.URL url,
                     boolean strict)
              throws InvalidFormatException,
                     java.io.IOException
Creates a OBJFileReader object to read a OBJ file from an URL. The data may be in ASCII or binary format.

Parameters:
url - URL of OBJ file to read.
strict - Attempt to deal with crappy data or short downloads. Will try to return any useable geometry.
Throws:
InvalidFormatException - The file was structurally incorrect
java.io.IOException

OBJFileReader

public OBJFileReader(java.net.URL url,
                     java.awt.Component parentComponent)
              throws InvalidFormatException,
                     java.io.IOException
Creates a OBJFileReader object to read a OBJ file from an URL. The data may be in ASCII or binary format. A progress monitor will show the progress during reading.

Parameters:
url - URL of OBJ file to read.
parentComponent - Parent Component of progress monitor. Use null if there is no parent.
Throws:
InvalidFormatException - The file was structurally incorrect
java.io.IOException

OBJFileReader

public OBJFileReader(java.net.URL url,
                     java.awt.Component parentComponent,
                     boolean strict)
              throws InvalidFormatException,
                     java.io.IOException
Creates a OBJFileReader object to read a OBJ file from an URL. The data may be in ASCII or binary format. A progress monitor will show the progress during reading.

Parameters:
url - URL of OBJ file to read.
parentComponent - Parent Component of progress monitor. Use null if there is no parent.
strict - Attempt to deal with crappy data or short downloads. Will try to return any useable geometry.
Throws:
InvalidFormatException - The file was structurally incorrect
java.io.IOException

OBJFileReader

public OBJFileReader(java.io.File file,
                     java.awt.Component parentComponent)
              throws InvalidFormatException,
                     java.io.IOException
Creates a OBJFileReader object to read a OBJ file from a file. The data may be in ASCII or binary format. A progress monitor will show the progress during reading.

Parameters:
file - File object of OBJ file to read.
parentComponent - Parent Component of progress monitor. Use null if there is no parent.
Throws:
InvalidFormatException - The file was structurally incorrect
java.io.IOException

OBJFileReader

public OBJFileReader(java.io.File file,
                     java.awt.Component parentComponent,
                     boolean strict)
              throws InvalidFormatException,
                     java.io.IOException
Creates a OBJFileReader object to read a OBJ file from a file. The data may be in ASCII or binary format. A progress monitor will show the progress during reading.

Parameters:
file - File object of OBJ file to read.
parentComponent - Parent Component of progress monitor. Use null if there is no parent.
strict - Attempt to deal with crappy data or short downloads. Will try to return any useable geometry.
Throws:
InvalidFormatException - The file was structurally incorrect
java.io.IOException

OBJFileReader

public OBJFileReader(java.lang.String fileName,
                     java.awt.Component parentComponent)
              throws InvalidFormatException,
                     java.io.IOException
Creates a OBJFileReader object to read a OBJ file from a file. The data may be in ASCII or binary format. A progress monitor will show the progress during reading.

Parameters:
fileName - Name of OBJ file to read.
parentComponent - Parent Component of progress monitor. Use null if there is no parent.
Throws:
InvalidFormatException - The file was structurally incorrect
java.io.IOException

OBJFileReader

public OBJFileReader(java.lang.String fileName,
                     java.awt.Component parentComponent,
                     boolean strict)
              throws InvalidFormatException,
                     java.io.IOException
Creates a OBJFileReader object to read a OBJ file from a file. The data may be in ASCII or binary format. A progress monitor will show the progress during reading.

Parameters:
fileName - Name of OBJ file to read.
parentComponent - Parent Component of progress monitor. Use null if there is no parent.
strict - Attempt to deal with crappy data or short downloads. Will try to return any useable geometry.
Throws:
InvalidFormatException - The file was structurally incorrect
java.io.IOException
Method Detail

getNextObject

public GeometryData getNextObject()
                           throws java.io.IOException
Get the next object in the stream.

Returns:
The object or null if EOF reached.
Throws:
java.io.IOException

getParsingMessages

public java.util.List<java.lang.String> getParsingMessages()
Get detailed messages on what was wrong when parsing. Only can happen when strictParsing is false. Means things like getNumOfFacets might be larger then reality.


close

public void close()
           throws java.io.IOException
Releases used resources. Must be called after finishing reading.

Throws:
java.io.IOException

j3d.org Code

Latest Info from http://code.j3d.org/
Copyright © 2001 - j3d.org