Class LoaderBinary

java.lang.Object
com.irurueta.geometry.io.Loader
com.irurueta.geometry.io.LoaderBinary
All Implemented Interfaces:
Closeable, AutoCloseable

public class LoaderBinary extends Loader
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.
  • Field Details

    • BUFFER_SIZE

      public static final int BUFFER_SIZE
      Buffer size to load input file.
      See Also:
    • SUPPORTED_VERSION

      private static final byte SUPPORTED_VERSION
      Version number of the binary format supported by this class.
      See Also:
    • BOUNDING_BYTES_SIZE

      private static final int BOUNDING_BYTES_SIZE
      Number 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

      private LoaderBinary.LoaderIteratorBinary 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 validityChecked
      Indicates 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 validFile
      Indicates if after checking validity, the file header has been found to be valid or not.
  • Constructor Details

    • LoaderBinary

      public LoaderBinary()
      Constructor.
    • LoaderBinary

      public LoaderBinary(File f) throws IOException
      Constructor.
      Parameters:
      f - file to be loaded.
      Throws:
      IOException - if an I/O error occurs.
    • LoaderBinary

      public LoaderBinary(LoaderListener listener)
      Constructor.
      Parameters:
      listener - listener to be notified of loading progress.
    • LoaderBinary

      public LoaderBinary(File f, LoaderListener listener) throws IOException
      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.
      Specified by:
      isReady in class Loader
      Returns:
      true if ready to start loading a file, false otherwise.
    • getMeshFormat

      public MeshFormat getMeshFormat()
      Returns mesh format supported by this class, which is MESH_FORMAT_BINARY2.
      Specified by:
      getMeshFormat in class Loader
      Returns:
      mesh format supported by this class.
    • isValidFile

      public boolean isValidFile() throws LockedException, IOException
      Determines if provided file is a valid file that can be read by this loader.
      Specified by:
      isValidFile in class Loader
      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

      Starts 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:
      load in class Loader
      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.