Class used to retrieve data from an SoImageDataAdapter. More...
#include <ImageViz/SbImageDataAccessor.h>
Classes | |
class | 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. More... | |
class | SubVolumeRegion |
Region representing a 3D box. More... | |
Public Member Functions | |
SbImageDataVoxel | getVoxel (const SbVec4i32 &pos) |
Returns voxel at specified position. | |
double | getVoxel (int x, int y, int z=0, int t=0, int c=0) |
Returns value of voxel at specified position. | |
bool | setVoxel (double value, int x, int y, int z=0, int t=0, int c=0) |
Set the value of voxel at specified coordinates. | |
bool | getRow (SoCpuBufferObject *values, int y, int z=0, int t=0, int c=0) |
Get values of the full row at specified coordinates. | |
bool | getRow (std::vector< double > &values, int y, int z=0, int t=0, int c=0) |
Alternate method to getRow( SoCpuBufferObject* values, int y, int z, int t, int c ). | |
bool | setRow (const SoCpuBufferObject *values, int y, int z=0, int t=0, int c=0) |
Set values to a row at specified coordinates. | |
bool | setRow (const std::vector< double > &values, int y, int z=0, int t=0, int c=0) |
Alternate method to setRow( const SoCpuBufferObject* values, int y, int z, int t, int c ). | |
bool | getColumn (SoCpuBufferObject *values, int x, int z=0, int t=0, int c=0) |
Get values of the full column at specified coordinates. | |
bool | getColumn (std::vector< double > &values, int x, int z=0, int t=0, int c=0) |
Alternate method to getColumn( SoCpuBufferObject* values, int x, int z, int t, int c ). | |
bool | setColumn (const SoCpuBufferObject *values, int x, int z=0, int t=0, int c=0) |
Set values to a column at specified coordinates. | |
bool | setColumn (const std::vector< double > &values, int x, int z=0, int t=0, int c=0) |
Alternate method to setColumn( const SoCpuBufferObject* values, int x, int z, int t, int c ). | |
SoMemoryDataAdapter * | copyRegion (const Region ®ion, const SbChannelList &channels) |
Returns an SoMemoryDataAdapter corresponding to the requested region. | |
SoMemoryDataAdapter * | copyRegion (const Region ®ion) |
Returns an SoMemoryDataAdapter corresponding to the requested region. | |
SoImageDataAdapter * | getImageAdapter () const |
Returns the SoImageDataAdapter associated with this DataAccessor. | |
Static Public Member Functions | |
static SubVolumeRegion | createFullRegion (SoImageDataAdapter *image) |
Helper to create a SubVolumeRegion corresponding to the whole region of the given image. | |
static SubVolumeRegion | createSliceRegion (SoImageDataAdapter *image, uint32_t sliceNumber) |
Helper to create a SubVolumeRegion corresponding to one slice of the given image. | |
Friends | |
class | SoImageDataAdapter |
Only SoImageDataAdapter is allowed to create an SbImageDataAccessor. | |
Class used to retrieve data from an SoImageDataAdapter.
Class used to retrieve data from an SoImageDataAdapter.
To create an SbImageDataAccessor, call the getDataAccessor() method on the SoImageDataAdaptor.
To get an SoMemoryDataAdapter containing the data from a region, call copyRegion() with an instance of a class implementing the Region interface. You can use the predefined Region class SubVolumeRegion 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.
SoImageDataAdapter, SbImageDataVoxel
Definition at line 57 of file SbImageDataAccessor.h.
SoMemoryDataAdapter * SbImageDataAccessor::copyRegion | ( | const Region & | region | ) |
Returns an SoMemoryDataAdapter 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.
SoMemoryDataAdapter * SbImageDataAccessor::copyRegion | ( | const Region & | region, |
const SbChannelList & | channels | ||
) |
Returns an SoMemoryDataAdapter 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.
|
static |
Helper to create a SubVolumeRegion corresponding to the whole region of the given image.
|
static |
Helper to create a SubVolumeRegion corresponding to one slice of the given image.
bool SbImageDataAccessor::getColumn | ( | SoCpuBufferObject * | values, |
int | x, | ||
int | z = 0 , |
||
int | t = 0 , |
||
int | c = 0 |
||
) |
Get values of the full column at specified coordinates.
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 coordinate |
z | depth coordinate. Default is 0. Useful for 2D images. |
t | time coordinate. Default is 0. |
c | component number. Default is 0. |
bool SbImageDataAccessor::getColumn | ( | std::vector< double > & | values, |
int | x, | ||
int | z = 0 , |
||
int | t = 0 , |
||
int | c = 0 |
||
) |
Alternate method to getColumn( SoCpuBufferObject* values, int x, int z, int t, int c ).
|
inline |
Returns the SoImageDataAdapter associated with this DataAccessor.
Definition at line 278 of file SbImageDataAccessor.h.
bool SbImageDataAccessor::getRow | ( | SoCpuBufferObject * | values, |
int | y, | ||
int | z = 0 , |
||
int | t = 0 , |
||
int | c = 0 |
||
) |
Get values of the full row at specified coordinates.
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 coordinate |
z | depth coordinate. Default is 0. Useful for 2D images. |
t | time coordinate. Default is 0. |
c | component number. Default is 0. |
bool SbImageDataAccessor::getRow | ( | std::vector< double > & | values, |
int | y, | ||
int | z = 0 , |
||
int | t = 0 , |
||
int | c = 0 |
||
) |
Alternate method to getRow( SoCpuBufferObject* values, int y, int z, int t, int c ).
SbImageDataVoxel SbImageDataAccessor::getVoxel | ( | const SbVec4i32 & | pos | ) |
Returns voxel at specified position.
pos[0], pos[1] and pos[2] refer to width, height and depth of image. Pos[3] refers to timestep. Any request outside of the image will return 0. If the specified channel is not in image channel range, 0 will be returned.
double SbImageDataAccessor::getVoxel | ( | int | x, |
int | y, | ||
int | z = 0 , |
||
int | t = 0 , |
||
int | c = 0 |
||
) |
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.
x | column coordinate |
y | row coordinate |
z | depth coordinate. Default is 0. Useful for 2D images. |
t | time coordinate. Default is 0. |
c | component number. Default is 0. |
bool SbImageDataAccessor::setColumn | ( | const SoCpuBufferObject * | values, |
int | x, | ||
int | z = 0 , |
||
int | t = 0 , |
||
int | c = 0 |
||
) |
Set values to a column at specified coordinates.
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 coordinate |
z | depth coordinate. Default is 0. Useful for 2D images. |
t | time coordinate. Default is 0. |
c | component number. Default is 0. |
bool SbImageDataAccessor::setColumn | ( | const std::vector< double > & | values, |
int | x, | ||
int | z = 0 , |
||
int | t = 0 , |
||
int | c = 0 |
||
) |
Alternate method to setColumn( const SoCpuBufferObject* values, int x, int z, int t, int c ).
bool SbImageDataAccessor::setRow | ( | const SoCpuBufferObject * | values, |
int | y, | ||
int | z = 0 , |
||
int | t = 0 , |
||
int | c = 0 |
||
) |
Set values to a row at specified coordinates.
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 coordinate |
z | depth coordinate. Default is 0. Useful for 2D images. |
t | time coordinate. Default is 0. |
c | component number. Default is 0. |
bool SbImageDataAccessor::setRow | ( | const std::vector< double > & | values, |
int | y, | ||
int | z = 0 , |
||
int | t = 0 , |
||
int | c = 0 |
||
) |
Alternate method to setRow( const SoCpuBufferObject* values, int y, int z, int t, int c ).
bool SbImageDataAccessor::setVoxel | ( | double | value, |
int | x, | ||
int | y, | ||
int | z = 0 , |
||
int | t = 0 , |
||
int | c = 0 |
||
) |
Set the value of voxel at specified coordinates.
value | to set one component at specified position |
x | column coordinate |
y | row coordinate |
z | depth coordinate. Default is 0. Useful for 2D images. |
t | time coordinate. Default is 0. |
c | component number. Default is 0. |
|
friend |
Only SoImageDataAdapter is allowed to create an SbImageDataAccessor.
Definition at line 283 of file SbImageDataAccessor.h.