j3d.org Code

org.j3d.renderer.java3d.loaders
Class STLLoader

java.lang.Object
  extended bycom.sun.j3d.loaders.LoaderBase
      extended byorg.j3d.renderer.java3d.loaders.STLLoader
All Implemented Interfaces:
com.sun.j3d.loaders.Loader

public class STLLoader
extends com.sun.j3d.loaders.LoaderBase

Class to load objects from a STL (Stereolithography) file into Java3D.

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

Version:
$Revision: 1.2 $
Author:
Dipl. Ing. Paul Szawlowski - University of Vienna, Dept. of Medical Computer Sciences

Field Summary
 
Fields inherited from class com.sun.j3d.loaders.LoaderBase
basePath, baseUrl, loadFlags
 
Fields inherited from interface com.sun.j3d.loaders.Loader
LOAD_ALL, LOAD_BACKGROUND_NODES, LOAD_BEHAVIOR_NODES, LOAD_FOG_NODES, LOAD_LIGHT_NODES, LOAD_SOUND_NODES, LOAD_VIEW_GROUPS
 
Constructor Summary
STLLoader()
          Creates a STLLoader object.
STLLoader(java.awt.Component parentComponent)
          Creates a STLLoader object which shows the progress of reading.
 
Method Summary
static com.sun.j3d.loaders.Scene createScene(STLFileReader reader)
          Creates a Scene object with the contents of the STL file.
 com.sun.j3d.loaders.Scene load(java.io.Reader reader)
          Loading from a Reader object not supported.
 com.sun.j3d.loaders.Scene load(java.lang.String fileName)
          Loads a STL file from a file.
 com.sun.j3d.loaders.Scene load(java.net.URL url)
          Loads a STL file from an URL.
 
Methods inherited from class com.sun.j3d.loaders.LoaderBase
getBasePath, getBaseUrl, getFlags, setBasePath, setBaseUrl, setFlags
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

STLLoader

public STLLoader()
Creates a STLLoader object.


STLLoader

public STLLoader(java.awt.Component parentComponent)
Creates a STLLoader object which shows the progress of reading. Effects only load( URL ) and load( String ).

Parameters:
parentComponent - Parent Component of progress monitor. Use null if there is no parent.
Method Detail

load

public com.sun.j3d.loaders.Scene load(java.lang.String fileName)
                               throws java.io.FileNotFoundException,
                                      com.sun.j3d.loaders.IncorrectFormatException,
                                      com.sun.j3d.loaders.ParsingErrorException
Loads a STL file from a file. The data may be in ASCII or binary format.

The getNamedObjects method of the Scene object will return Shape3D objects with no Appearance set.

Returns:
Scene object of the content of fileName or null if user cancelled loading (only possible if progress monitoring is enabled).
Throws:
java.io.FileNotFoundException
com.sun.j3d.loaders.IncorrectFormatException
com.sun.j3d.loaders.ParsingErrorException

load

public com.sun.j3d.loaders.Scene load(java.net.URL url)
                               throws java.io.FileNotFoundException,
                                      com.sun.j3d.loaders.IncorrectFormatException,
                                      com.sun.j3d.loaders.ParsingErrorException
Loads a STL file from an URL. The data may be in ASCII or binary format.

The getNamedObjects method of the Scene object will return Shape3D objects with no Appearance set.

Returns:
Scene object of the content of url or null if user cancelled loading (only possible if progress monitoring is enabled).
Throws:
java.io.FileNotFoundException
com.sun.j3d.loaders.IncorrectFormatException
com.sun.j3d.loaders.ParsingErrorException

load

public com.sun.j3d.loaders.Scene load(java.io.Reader reader)
                               throws java.io.FileNotFoundException,
                                      com.sun.j3d.loaders.IncorrectFormatException,
                                      com.sun.j3d.loaders.ParsingErrorException
Loading from a Reader object not supported.

Returns:
null
Throws:
java.io.FileNotFoundException
com.sun.j3d.loaders.IncorrectFormatException
com.sun.j3d.loaders.ParsingErrorException

createScene

public static com.sun.j3d.loaders.Scene createScene(STLFileReader reader)
                                             throws com.sun.j3d.loaders.IncorrectFormatException,
                                                    com.sun.j3d.loaders.ParsingErrorException
Creates a Scene object with the contents of the STL file. Closes the reader after finishing reading.

Parameters:
reader - STLFileReader object for reading the STL file.
Throws:
com.sun.j3d.loaders.IncorrectFormatException
com.sun.j3d.loaders.ParsingErrorException

j3d.org Code

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