Package com.irurueta.geometry.io
Class LoaderBinary
java.lang.Object
com.irurueta.geometry.io.Loader
com.irurueta.geometry.io.LoaderBinary
- All Implemented Interfaces:
Closeable,AutoCloseable
Loads a custom binary file implemented for this library.
The binary format has been created to keep 3D data in a more compact way than
other formats.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classLoader iterator in charge of loading file data in small chunks.private classInternal listener to be notified when loading process finishes. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intNumber of bytes required to determine the bounding box of a chunk or the whole 3D object (which are 2 3D points = 2x3 coordinates = 6 floats * 4 bytes per float).static final intBuffer size to load input file.Iterator to load binary data in small chunks.private static final byteVersion number of the binary format supported by this class.private booleanIndicates if after checking validity, the file header has been found to be valid or not.private final booleanIndicates if file has been checked to have a valid header. -
Constructor Summary
ConstructorsConstructorDescriptionConstructor.LoaderBinary(LoaderListener listener) Constructor.LoaderBinary(File f) Constructor.LoaderBinary(File f, LoaderListener listener) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionReturns mesh format supported by this class, which is MESH_FORMAT_BINARY2.booleanisReady()If loader is ready to start loading a file.booleanDetermines if provided file is a valid file that can be read by this loader.load()Starts the loading process of provided file.Methods inherited from class com.irurueta.geometry.io.Loader
close, getFileSizeLimitToKeepInMemory, getListener, hasFile, isLocked, setFile, setFileSizeLimitToKeepInMemory, setListener, setLocked
-
Field Details
-
BUFFER_SIZE
public static final int BUFFER_SIZEBuffer size to load input file.- See Also:
-
SUPPORTED_VERSION
private static final byte SUPPORTED_VERSIONVersion number of the binary format supported by this class.- See Also:
-
BOUNDING_BYTES_SIZE
private static final int BOUNDING_BYTES_SIZENumber of bytes required to determine the bounding box of a chunk or the whole 3D object (which are 2 3D points = 2x3 coordinates = 6 floats * 4 bytes per float).- See Also:
-
loaderIterator
Iterator to load binary data in small chunks. Usually data is divided in chunks that can be directly loaded by graphic layers such as OpenGL. -
validityChecked
private final boolean validityCheckedIndicates if file has been checked to have a valid header. Notice that file might still be corrupt or incomplete at some point. -
validFile
private boolean validFileIndicates if after checking validity, the file header has been found to be valid or not.
-
-
Constructor Details
-
LoaderBinary
public LoaderBinary()Constructor. -
LoaderBinary
Constructor.- Parameters:
f- file to be loaded.- Throws:
IOException- if an I/O error occurs.
-
LoaderBinary
Constructor.- Parameters:
listener- listener to be notified of loading progress.
-
LoaderBinary
Constructor.- Parameters:
f- file to be loaded.listener- listener to be notified of loading progress.- Throws:
IOException- if an I/O error occurs.
-
-
Method Details
-
isReady
public boolean isReady()If loader is ready to start loading a file. This is true once a file has been provided. -
getMeshFormat
Returns mesh format supported by this class, which is MESH_FORMAT_BINARY2.- Specified by:
getMeshFormatin classLoader- Returns:
- mesh format supported by this class.
-
isValidFile
Determines if provided file is a valid file that can be read by this loader.- Specified by:
isValidFilein classLoader- Returns:
- true if file is valid, false otherwise.
- Throws:
LockedException- raised if this instance is already locked.IOException- if an I/O error occurs.
-
load
public LoaderIterator load() throws LockedException, NotReadyException, IOException, LoaderExceptionStarts the loading process of provided file. This method returns a LoaderIterator to start the iterative process to load a file in small chunks of data.- Specified by:
loadin classLoader- Returns:
- a loader iterator to read the file in a step-by-step process.
- Throws:
LockedException- raised if this instance is already locked.NotReadyException- raised if this instance is not yet ready.IOException- if an I/O error occurs.LoaderException- if file is corrupted or cannot be interpreted.
-