Class VoxelBuffer<T>
- Type Parameters:
T
- buffer-type
- Direct Known Subclasses:
VoxelBufferUnsigned
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 -
Method Summary
Modifier and TypeMethodDescriptionabstract T
buffer()
The associated buffer for storing the voxels.abstract int
capacity()
The capacity (i.e. size) of the buffer.abstract void
copyVoxelFrom
(int destinationIndex, VoxelBuffer<T> source, int sourceIndex) Copies one particular intensity-value from anotherVoxelBuffer
into this buffer.abstract VoxelDataType
dataType()
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 anint
.abstract boolean
Are there voxels remaining in a buffer?abstract boolean
isDirect()
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.toString()
abstract ByteBuffer
THe underlying bytes that describe the voxels.
-
Constructor Details
-
VoxelBuffer
public VoxelBuffer()
-
-
Method Details
-
dataType
Data-type of each voxel in the buffer.- Returns:
- the data-type.
-
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
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 anint
.Note this can provide slower access than reading directly in the native buffer type.
The advantage is that all buffer-types implement
getInt
andputInt
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
THe underlying bytes that describe the voxels.- Returns:
- the associated
ByteBuffer
with the voxels.
-
toString
-
copyVoxelFrom
Copies one particular intensity-value from anotherVoxelBuffer
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 insource
to copy from.
-