org.smurn.jply
Class PlyReaderFile

java.lang.Object
  extended by org.smurn.jply.PlyReaderFile
All Implemented Interfaces:
PlyReader

public final class PlyReaderFile
extends Object
implements PlyReader

Reads meshes in the PLY file format.


Constructor Summary
PlyReaderFile(File file)
          Opens a PLY file.
PlyReaderFile(InputStream stream)
          Opens a PLY file.
PlyReaderFile(String file)
          Opens a PLY file.
 
Method Summary
 void close()
          Closes the file.
 int getElementCount(String elementType)
          Gets the number of elements for a given element type.
 List<ElementType> getElementTypes()
          Gets all element types in this PLY file.
 ElementReader nextElementReader()
          Returns the reader to read the first group of elements.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PlyReaderFile

public PlyReaderFile(File file)
              throws IOException
Opens a PLY file.

If the file name ends with .gz the file will be decompressed automatically.

Parameters:
file - File to open.
Throws:
NullPointerException - if file is null.
IOException - if an error occurs during opening or reading.

PlyReaderFile

public PlyReaderFile(String file)
              throws IOException
Opens a PLY file.

Parameters:
file - Path to the file to open.
Throws:
NullPointerException - if file is null.
IOException - if an error occurs during opening or reading.

PlyReaderFile

public PlyReaderFile(InputStream stream)
              throws IOException
Opens a PLY file.

Parameters:
stream - InputStream from which to read the file.
Throws:
NullPointerException - if stream is null.
IOException - if an error occurs during opening or reading.
Method Detail

getElementTypes

public List<ElementType> getElementTypes()
Gets all element types in this PLY file.

The order of the list is the same in which the corresponding readers are returned by nextElementReader().

Specified by:
getElementTypes in interface PlyReader
Returns:
Immutable list with all element types.

getElementCount

public int getElementCount(String elementType)
Gets the number of elements for a given element type.

Specified by:
getElementCount in interface PlyReader
Parameters:
elementType - Name of the element type.
Returns:
Number of elements of the given type.
Throws:
NullPointerException - if elementType is null.
IllegalArgumentException - if there is no such type in this file.

nextElementReader

public ElementReader nextElementReader()
                                throws IOException
Returns the reader to read the first group of elements.

Each group corresponds to an element type. The groups are returned in the order given in the file. This is also the same order as in the list given by getElementTypes().

Each returned reader must be closed before the next reader is requested with this method.

Specified by:
nextElementReader in interface PlyReader
Returns:
Reader for the next group of elements or null if there are no more groups.
Throws:
IOException - if an error occurs during reading.

close

public void close()
           throws IOException
Closes the file.

Specified by:
close in interface PlyReader
Throws:
IOException - if closing fails.


Copyright © 2011. All Rights Reserved.