Class VoxelBuffer<T>

Object
VoxelBuffer<T>
Type Parameters:
T - buffer-type
Direct Known Subclasses:
VoxelBufferUnsigned

public abstract class VoxelBuffer<T> extends Object
A buffer of voxel-values, usually corresponding to a single z-slice in Voxels.

The operations are modelled on the NIO Buffer classes that can provide the underlying buffers, but parameter T need not strictly be a sub-class of Buffer. This is useful for automatically wrapping signed to unsigned values with custom buffers.

Author:
Owen Feehan
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract T
    The associated buffer for storing the voxels.
    abstract int
    The capacity (i.e. size) of the buffer.
    abstract void
    copyVoxelFrom(int destinationIndex, VoxelBuffer<T> source, int sourceIndex)
    Copies one particular intensity-value from another VoxelBuffer into this buffer.
    abstract VoxelDataType
    Data-type of each voxel in the buffer.
    abstract VoxelBuffer<T>
    Creates a deep copy of the current object, including deep-copying the associated buffer.
    abstract int
    getInt(int index)
    Gets an element from the buffer at a particular position, converting, if necessary, to an int.
    abstract boolean
    Are there voxels remaining in a buffer?
    abstract boolean
    Is this buffer direct or non-direct?
    abstract void
    position(int newPosition)
    Assigns a new position to the buffer.
    abstract void
    putByte(int index, byte value)
    Puts a byte in the buffer at a particular position, converting, if necessary, to the buffer type.
    abstract void
    putInt(int index, int value)
    Puts a int in the buffer at a particular position, converting, if necessary, to the buffer type.
     
    abstract ByteBuffer
    THe underlying bytes that describe the voxels.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • VoxelBuffer

      public VoxelBuffer()
  • Method Details

    • dataType

      public abstract VoxelDataType dataType()
      Data-type of each voxel in the buffer.
      Returns:
      the data-type.
    • buffer

      public abstract T buffer()
      The associated buffer for storing the voxels.

      This buffer is either a NIO or other classes that wraps the underlying array storing voxel intensities.

      Returns:
      the buffer.
    • duplicate

      public abstract VoxelBuffer<T> duplicate()
      Creates a deep copy of the current object, including deep-copying the associated buffer.
      Returns:
      a newly created deep copy.
    • getInt

      public abstract int getInt(int index)
      Gets an element from the buffer at a particular position, converting, if necessary, to an int.

      Note this can provide slower access than reading directly in the native buffer type.

      The advantage is that all buffer-types implement getInt and putInt so no type-specific code needs to be written.

      The disadvantage is that this can be less efficient, unless conversion to int needs to occur anyway.

      Parameters:
      index - the index in the buffer.
      Returns:
      the intensity value corresponding to position index in the buffer.
    • putInt

      public abstract void putInt(int index, int value)
      Puts a int in the buffer at a particular position, converting, if necessary, to the buffer type.

      Note this can provide slower access than reading directly in the native buffer type. See the note in getInt(int).

      Parameters:
      index - the index in the buffer.
      value - value to put in the buffer.
    • putByte

      public abstract void putByte(int index, byte value)
      Puts a byte in the buffer at a particular position, converting, if necessary, to the buffer type.
      Parameters:
      index - the index in the buffer.
      value - value to put in the buffer.
    • capacity

      public abstract int capacity()
      The capacity (i.e. size) of the buffer.

      This is meant in the sense of Java's NIO Buffer classes.

      Returns:
      the size.
    • hasRemaining

      public abstract boolean hasRemaining()
      Are there voxels remaining in a buffer?

      This is meant in the sense of Java's NIO Buffer classes.

      Returns:
      true if there are voxels remaining in the buffer, false otherwise.
    • position

      public abstract void position(int newPosition)
      Assigns a new position to the buffer.

      This is meant in the sense of Java's NIO Buffer classes.

      Parameters:
      newPosition - the offset to assign as position.
    • isDirect

      public abstract boolean isDirect()
      Is this buffer direct or non-direct?

      This is meant in the sense of Java's NIO Buffer classes.

      Returns:
      true iff the buffer is direct.
    • underlyingBytes

      public abstract ByteBuffer underlyingBytes()
      THe underlying bytes that describe the voxels.
      Returns:
      the associated ByteBuffer with the voxels.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • copyVoxelFrom

      public abstract void copyVoxelFrom(int destinationIndex, VoxelBuffer<T> source, int sourceIndex)
      Copies one particular intensity-value from another VoxelBuffer into this buffer.
      Parameters:
      destinationIndex - the index in the current buffer to write to.
      source - the buffer to copy the value from.
      sourceIndex - the index of the voxel in source to copy from.