Open Inventor Release 2023.2.3
 
Loading...
Searching...
No Matches
SbImageDataAccessor Class Reference

ImageViz 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 ).
 
SoMemoryDataAdaptercopyRegion (const Region &region, const SbChannelList &channels)
 Returns an SoMemoryDataAdapter corresponding to the requested region.
 
SoMemoryDataAdaptercopyRegion (const Region &region)
 Returns an SoMemoryDataAdapter corresponding to the requested region.
 
SoImageDataAdaptergetImageAdapter () 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.
 

Detailed Description

ImageViz 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.

SEE ALSO

SoImageDataAdapter, SbImageDataVoxel

Definition at line 57 of file SbImageDataAccessor.h.

Member Function Documentation

◆ copyRegion() [1/2]

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.

◆ copyRegion() [2/2]

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.

◆ createFullRegion()

static SubVolumeRegion SbImageDataAccessor::createFullRegion ( SoImageDataAdapter image)
static

Helper to create a SubVolumeRegion corresponding to the whole region of the given image.

◆ createSliceRegion()

static SubVolumeRegion SbImageDataAccessor::createSliceRegion ( SoImageDataAdapter image,
uint32_t  sliceNumber 
)
static

Helper to create a SubVolumeRegion corresponding to one slice of the given image.

◆ getColumn() [1/2]

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.

Parameters
valuesa 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.
xcolumn coordinate
zdepth coordinate. Default is 0. Useful for 2D images.
ttime coordinate. Default is 0.
ccomponent number. Default is 0.
Returns
true if the column is correctly read. false otherwise

◆ getColumn() [2/2]

bool SbImageDataAccessor::getColumn ( std::vector< double > &  values,
int  x,
int  z = 0,
int  t = 0,
int  c = 0 
)

◆ getImageAdapter()

SoImageDataAdapter * SbImageDataAccessor::getImageAdapter ( ) const
inline

Returns the SoImageDataAdapter associated with this DataAccessor.

Definition at line 278 of file SbImageDataAccessor.h.

◆ getRow() [1/2]

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.

Parameters
valuesa 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.
yrow coordinate
zdepth coordinate. Default is 0. Useful for 2D images.
ttime coordinate. Default is 0.
ccomponent number. Default is 0.
Returns
true if the row is correctly read. false otherwise

◆ getRow() [2/2]

bool SbImageDataAccessor::getRow ( std::vector< double > &  values,
int  y,
int  z = 0,
int  t = 0,
int  c = 0 
)

◆ getVoxel() [1/2]

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.

◆ getVoxel() [2/2]

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.

Parameters
xcolumn coordinate
yrow coordinate
zdepth coordinate. Default is 0. Useful for 2D images.
ttime coordinate. Default is 0.
ccomponent number. Default is 0.

◆ setColumn() [1/2]

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.

Parameters
valuesto 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.
xcolumn coordinate
zdepth coordinate. Default is 0. Useful for 2D images.
ttime coordinate. Default is 0.
ccomponent number. Default is 0.
Returns
true if the column is correctly written on image false otherwise

◆ setColumn() [2/2]

bool SbImageDataAccessor::setColumn ( const std::vector< double > &  values,
int  x,
int  z = 0,
int  t = 0,
int  c = 0 
)

◆ setRow() [1/2]

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.

Parameters
valuesto 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.
yrow coordinate
zdepth coordinate. Default is 0. Useful for 2D images.
ttime coordinate. Default is 0.
ccomponent number. Default is 0.
Returns
true if the row is correctly written on image false otherwise

◆ setRow() [2/2]

bool SbImageDataAccessor::setRow ( const std::vector< double > &  values,
int  y,
int  z = 0,
int  t = 0,
int  c = 0 
)

◆ setVoxel()

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.

Parameters
valueto set one component at specified position
xcolumn coordinate
yrow coordinate
zdepth coordinate. Default is 0. Useful for 2D images.
ttime coordinate. Default is 0.
ccomponent number. Default is 0.
Returns
true if the voxel is written on image false otherwise

Friends And Related Symbol Documentation

◆ SoImageDataAdapter

friend class SoImageDataAdapter
friend

Only SoImageDataAdapter is allowed to create an SbImageDataAccessor.

Definition at line 283 of file SbImageDataAccessor.h.


The documentation for this class was generated from the following file: