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 Tbuffer()The associated buffer for storing the voxels.abstract intcapacity()The capacity (i.e. size) of the buffer.abstract voidcopyVoxelFrom(int destinationIndex, VoxelBuffer<T> source, int sourceIndex) Copies one particular intensity-value from anotherVoxelBufferinto this buffer.abstract VoxelDataTypedataType()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 intgetInt(int index) Gets an element from the buffer at a particular position, converting, if necessary, to anint.abstract booleanAre there voxels remaining in a buffer?abstract booleanisDirect()Is this buffer direct or non-direct?abstract voidposition(int newPosition) Assigns a new position to the buffer.abstract voidputByte(int index, byte value) Puts a byte in the buffer at a particular position, converting, if necessary, to the buffer type.abstract voidputInt(int index, int value) Puts a int in the buffer at a particular position, converting, if necessary, to the buffer type.toString()abstract ByteBufferTHe 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
getIntandputIntso no type-specific code needs to be written.The disadvantage is that this can be less efficient, unless conversion to
intneeds to occur anyway.- Parameters:
index- the index in the buffer.- Returns:
- the intensity value corresponding to position
indexin 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
Bufferclasses.- 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
Bufferclasses.- 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
Bufferclasses.- 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
Bufferclasses.- Returns:
- true iff the buffer is direct.
-
underlyingBytes
THe underlying bytes that describe the voxels.- Returns:
- the associated
ByteBufferwith the voxels.
-
toString
-
copyVoxelFrom
Copies one particular intensity-value from anotherVoxelBufferinto 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 insourceto copy from.
-