Package com.openinventor.imageviz
Class SbImageDataAccessor
- java.lang.Object
-
- com.openinventor.inventor.Inventor
-
- com.openinventor.imageviz.SbImageDataAccessor
-
public class SbImageDataAccessor extends Inventor
Class used to retrieve data from anSoImageDataAdapter
. Class used to retrieve data from anSoImageDataAdapter
.To create an
SbImageDataAccessor
, call the getDataAccessor() method on the SoImageDataAdaptor.To get an
SoMemoryDataAdapter
containing the data from a region, callcopyRegion()
with an instance of a class implementing theRegion
interface. You can use the predefinedRegion
classSubVolumeRegion
and the helper methods, e.g.createSliceRegion()
, for convenience. Note that the returned data are stored in CPU memory. This class does not aim to support out of core access. Make sure you have enough free memory when requesting data.- See Also:
SoImageDataAdapter SbImageDataVoxel
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
SbImageDataAccessor.Region
A region must be an ordered set with a first voxel and for each voxel a next voxel, else we cannot associate a buffer to this region.static class
SbImageDataAccessor.SubVolumeRegion
Region
representing a 3D box.-
Nested classes/interfaces inherited from class com.openinventor.inventor.Inventor
Inventor.ConstructorCommand
-
-
Field Summary
-
Fields inherited from class com.openinventor.inventor.Inventor
VERBOSE_LEVEL, ZeroHandle
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description SoMemoryDataAdapter
copyRegion(SbImageDataAccessor.Region region)
Returns anSoMemoryDataAdapter
corresponding to the requested region.SoMemoryDataAdapter
copyRegion(SbImageDataAccessor.Region region, SbChannelList channels)
Returns anSoMemoryDataAdapter
corresponding to the requested region.static SbImageDataAccessor.SubVolumeRegion
createFullRegion(SoImageDataAdapter image)
Helper to create aSubVolumeRegion
corresponding to the whole region of the given image.static SbImageDataAccessor.SubVolumeRegion
createSliceRegion(SoImageDataAdapter image, int sliceNumber)
Helper to create aSubVolumeRegion
corresponding to one slice of the given image.boolean
getColumn(SoCpuBufferObject values, int x)
Calls getColumn(values, x, (int)0, (int)0, (int)0).boolean
getColumn(SoCpuBufferObject values, int x, int z)
Calls getColumn(values, x, z, (int)0, (int)0).boolean
getColumn(SoCpuBufferObject values, int x, int z, int t)
Calls getColumn(values, x, z, t, (int)0).boolean
getColumn(SoCpuBufferObject values, int x, int z, int t, int c)
Get values of the full column at specified coordinates.SoImageDataAdapter
getImageAdapter()
Returns theSoImageDataAdapter
associated with this DataAccessor.boolean
getRow(SoCpuBufferObject values, int y)
Calls getRow(values, y, (int)0, (int)0, (int)0).boolean
getRow(SoCpuBufferObject values, int y, int z)
Calls getRow(values, y, z, (int)0, (int)0).boolean
getRow(SoCpuBufferObject values, int y, int z, int t)
Calls getRow(values, y, z, t, (int)0).boolean
getRow(SoCpuBufferObject values, int y, int z, int t, int c)
Get values of the full row at specified coordinates.double
getVoxel(int x, int y)
Calls getVoxel(x, y, (int)0, (int)0, (int)0).double
getVoxel(int x, int y, int z)
Calls getVoxel(x, y, z, (int)0, (int)0).double
getVoxel(int x, int y, int z, int t)
Calls getVoxel(x, y, z, t, (int)0).double
getVoxel(int x, int y, int z, int t, int c)
Returns value of voxel at specified position.boolean
setColumn(SoCpuBufferObject values, int x)
Calls setColumn(values, x, (int)0, (int)0, (int)0).boolean
setColumn(SoCpuBufferObject values, int x, int z)
Calls setColumn(values, x, z, (int)0, (int)0).boolean
setColumn(SoCpuBufferObject values, int x, int z, int t)
Calls setColumn(values, x, z, t, (int)0).boolean
setColumn(SoCpuBufferObject values, int x, int z, int t, int c)
Set values to a column at specified coordinates.boolean
setColumn(java.util.Collection<java.lang.Double> values, int x)
Calls setColumn(values, x, (int)0, (int)0, (int)0).boolean
setColumn(java.util.Collection<java.lang.Double> values, int x, int z)
Calls setColumn(values, x, z, (int)0, (int)0).boolean
setColumn(java.util.Collection<java.lang.Double> values, int x, int z, int t)
Calls setColumn(values, x, z, t, (int)0).boolean
setColumn(java.util.Collection<java.lang.Double> values, int x, int z, int t, int c)
Alternate method tosetColumn( const SoCpuBufferObject* values, int x, int z, int t, int c )
.boolean
setRow(SoCpuBufferObject values, int y)
Calls setRow(values, y, (int)0, (int)0, (int)0).boolean
setRow(SoCpuBufferObject values, int y, int z)
Calls setRow(values, y, z, (int)0, (int)0).boolean
setRow(SoCpuBufferObject values, int y, int z, int t)
Calls setRow(values, y, z, t, (int)0).boolean
setRow(SoCpuBufferObject values, int y, int z, int t, int c)
Set values to a row at specified coordinates.boolean
setRow(java.util.Collection<java.lang.Double> values, int y)
Calls setRow(values, y, (int)0, (int)0, (int)0).boolean
setRow(java.util.Collection<java.lang.Double> values, int y, int z)
Calls setRow(values, y, z, (int)0, (int)0).boolean
setRow(java.util.Collection<java.lang.Double> values, int y, int z, int t)
Calls setRow(values, y, z, t, (int)0).boolean
setRow(java.util.Collection<java.lang.Double> values, int y, int z, int t, int c)
Alternate method tosetRow( const SoCpuBufferObject* values, int y, int z, int t, int c )
.boolean
setVoxel(double value, int x, int y)
Calls setVoxel(value, x, y, (int)0, (int)0, (int)0).boolean
setVoxel(double value, int x, int y, int z)
Calls setVoxel(value, x, y, z, (int)0, (int)0).boolean
setVoxel(double value, int x, int y, int z, int t)
Calls setVoxel(value, x, y, z, t, (int)0).boolean
setVoxel(double value, int x, int y, int z, int t, int c)
Set the value of voxel at specified coordinates.-
Methods inherited from class com.openinventor.inventor.Inventor
dispose, getNativeResourceHandle
-
-
-
-
Method Detail
-
setRow
public boolean setRow(SoCpuBufferObject values, int y, int z)
Calls setRow(values, y, z, (int)0, (int)0).
-
setRow
public boolean setRow(SoCpuBufferObject values, int y)
Calls setRow(values, y, (int)0, (int)0, (int)0).
-
setRow
public boolean setRow(SoCpuBufferObject values, int y, int z, int t)
Calls setRow(values, y, z, t, (int)0).
-
setRow
public boolean setRow(java.util.Collection<java.lang.Double> values, int y, int z)
Calls setRow(values, y, z, (int)0, (int)0).
-
setRow
public boolean setRow(java.util.Collection<java.lang.Double> values, int y)
Calls setRow(values, y, (int)0, (int)0, (int)0).
-
setVoxel
public boolean setVoxel(double value, int x, int y, int z, int t)
Calls setVoxel(value, x, y, z, t, (int)0).
-
setVoxel
public boolean setVoxel(double value, int x, int y, int z)
Calls setVoxel(value, x, y, z, (int)0, (int)0).
-
getRow
public boolean getRow(SoCpuBufferObject values, int y)
Calls getRow(values, y, (int)0, (int)0, (int)0).
-
getRow
public boolean getRow(SoCpuBufferObject values, int y, int z, int t)
Calls getRow(values, y, z, t, (int)0).
-
getRow
public boolean getRow(SoCpuBufferObject values, int y, int z)
Calls getRow(values, y, z, (int)0, (int)0).
-
setColumn
public boolean setColumn(SoCpuBufferObject values, int x, int z, int t)
Calls setColumn(values, x, z, t, (int)0).
-
setColumn
public boolean setColumn(SoCpuBufferObject values, int x, int z)
Calls setColumn(values, x, z, (int)0, (int)0).
-
setColumn
public boolean setColumn(java.util.Collection<java.lang.Double> values, int x)
Calls setColumn(values, x, (int)0, (int)0, (int)0).
-
setColumn
public boolean setColumn(java.util.Collection<java.lang.Double> values, int x, int z, int t)
Calls setColumn(values, x, z, t, (int)0).
-
setColumn
public boolean setColumn(java.util.Collection<java.lang.Double> values, int x, int z)
Calls setColumn(values, x, z, (int)0, (int)0).
-
getColumn
public boolean getColumn(SoCpuBufferObject values, int x)
Calls getColumn(values, x, (int)0, (int)0, (int)0).
-
setRow
public boolean setRow(java.util.Collection<java.lang.Double> values, int y, int z, int t)
Calls setRow(values, y, z, t, (int)0).
-
getColumn
public boolean getColumn(SoCpuBufferObject values, int x, int z)
Calls getColumn(values, x, z, (int)0, (int)0).
-
setColumn
public boolean setColumn(SoCpuBufferObject values, int x)
Calls setColumn(values, x, (int)0, (int)0, (int)0).
-
getColumn
public boolean getColumn(SoCpuBufferObject values, int x, int z, int t)
Calls getColumn(values, x, z, t, (int)0).
-
getVoxel
public double getVoxel(int x, int y)
Calls getVoxel(x, y, (int)0, (int)0, (int)0).
-
setVoxel
public boolean setVoxel(double value, int x, int y)
Calls setVoxel(value, x, y, (int)0, (int)0, (int)0).
-
getVoxel
public double getVoxel(int x, int y, int z, int t)
Calls getVoxel(x, y, z, t, (int)0).
-
getVoxel
public double getVoxel(int x, int y, int z)
Calls getVoxel(x, y, z, (int)0, (int)0).
-
copyRegion
public SoMemoryDataAdapter copyRegion(SbImageDataAccessor.Region region)
Returns anSoMemoryDataAdapter
corresponding to the requested region. The data are copied and can be accessed in read/write. Returned buffer data are interleaved, i.e. if request for RGB buffer, data will be RGBRGBRGB... Data are then organized line by line, slice by slice, volume by volume. Ptr[0] is 1st channel of 1st voxel of 1st line of 1st slice of 1st volume. Ptr[nbChannel * regionWidth] is 1st channel of 1st voxel of 2nd line of 1st volume, and so on. The returned buffer is the requested region with all channels. There is no intersection with image extent or image available channels. Any data outside of image are considered to be zeros.
-
setRow
public boolean setRow(java.util.Collection<java.lang.Double> values, int y, int z, int t, int c)
Alternate method tosetRow( const SoCpuBufferObject* values, int y, int z, int t, int c )
.
-
copyRegion
public SoMemoryDataAdapter copyRegion(SbImageDataAccessor.Region region, SbChannelList channels)
Returns anSoMemoryDataAdapter
corresponding to the requested region. The data are copied and can be accessed in read/write. Returned buffer data are interleaved, i.e. if request for RGB buffer, data will be RGBRGBRGB... Data are then organized line by line, slice by slice, volume by volume. Ptr[0] is 1st channel of 1st voxel of 1st line of 1st slice of 1st volume. Ptr[nbChannel * regionWidth] is 1st channel of 1st voxel of 2nd line of 1st volume, and so on. The returned buffer is the intersection of requested region and requested channels. There is no intersection with image extent or image available channels. Any data outside of image are considered to be zeros.
-
setColumn
public boolean setColumn(SoCpuBufferObject values, int x, int z, int t, int c)
Set values to a column at specified coordinates.- Parameters:
values
- to set one component of the specified column as an array of double.SoCpuBufferObject
cannot be NULL. If its size does not match the required one, false is returned.x
- column coordinatez
- depth coordinate. Default is 0. Useful for 2D images.t
- time coordinate. Default is 0.c
- component number. Default is 0.- Returns:
- true if the column is correctly written on image false otherwise
-
setColumn
public boolean setColumn(java.util.Collection<java.lang.Double> values, int x, int z, int t, int c)
Alternate method tosetColumn( const SoCpuBufferObject* values, int x, int z, int t, int c )
.
-
getColumn
public boolean getColumn(SoCpuBufferObject values, int x, int z, int t, int c)
Get values of the full column at specified coordinates.- Parameters:
values
- a buffer to retrieve voxel values of one component at specified column position as an array of double.SoCpuBufferObject
cannot be NULL. If its size does not match the required one, it is resized.x
- column coordinatez
- depth coordinate. Default is 0. Useful for 2D images.t
- time coordinate. Default is 0.c
- component number. Default is 0.- Returns:
- true if the column is correctly read. false otherwise
-
setRow
public boolean setRow(SoCpuBufferObject values, int y, int z, int t, int c)
Set values to a row at specified coordinates.- Parameters:
values
- to set one component of the specified row as an array of double.SoCpuBufferObject
cannot be NULL. If its size does not match the required one, false is returned.y
- row coordinatez
- depth coordinate. Default is 0. Useful for 2D images.t
- time coordinate. Default is 0.c
- component number. Default is 0.- Returns:
- true if the row is correctly written on image false otherwise
-
createSliceRegion
public static SbImageDataAccessor.SubVolumeRegion createSliceRegion(SoImageDataAdapter image, int sliceNumber)
Helper to create aSubVolumeRegion
corresponding to one slice of the given image.
-
createFullRegion
public static SbImageDataAccessor.SubVolumeRegion createFullRegion(SoImageDataAdapter image)
Helper to create aSubVolumeRegion
corresponding to the whole region of the given image.
-
getVoxel
public double getVoxel(int x, int y, int z, int t, int c)
Returns value of voxel at specified position. See also getVoxel( const SbVec4i32& pos ). Any request outside of the image will return 0. If the specified channel is not in image channel range, 0.0 will be returned.- Parameters:
x
- column coordinatey
- row coordinatez
- depth coordinate. Default is 0. Useful for 2D images.t
- time coordinate. Default is 0.c
- component number. Default is 0.
-
getImageAdapter
public SoImageDataAdapter getImageAdapter()
Returns theSoImageDataAdapter
associated with this DataAccessor.
-
getRow
public boolean getRow(SoCpuBufferObject values, int y, int z, int t, int c)
Get values of the full row at specified coordinates.- Parameters:
values
- a buffer to retrieve voxel values of one component at specified row position as an array of double.SoCpuBufferObject
cannot be NULL. If its size does not match the required one, it is resized.y
- row coordinatez
- depth coordinate. Default is 0. Useful for 2D images.t
- time coordinate. Default is 0.c
- component number. Default is 0.- Returns:
- true if the row is correctly read. false otherwise
-
setVoxel
public boolean setVoxel(double value, int x, int y, int z, int t, int c)
Set the value of voxel at specified coordinates.- Parameters:
value
- to set one component at specified positionx
- column coordinatey
- row coordinatez
- depth coordinate. Default is 0. Useful for 2D images.t
- time coordinate. Default is 0.c
- component number. Default is 0.- Returns:
- true if the voxel is written on image false otherwise
-
-