VolumeAtomic< T > Class Template Reference

Inheritance diagram for VolumeAtomic< T >:
Volume

List of all members.

Public Types

enum  { BYTES_PER_VOXEL = sizeof(T), BITS_PER_VOXEL = BYTES_PER_VOXEL * 8 }
typedef T VoxelType

Public Member Functions

 VolumeAtomic (const tgt::ivec3 &dimensions, const tgt::vec3 &spacing=tgt::vec3(1.f), int bitsStored=BITS_PER_VOXEL, bool allocMem=true) throw (std::bad_alloc)
 While using this constructor the class will automatically allocate an appropriate chunk of memory.
 VolumeAtomic (T *data, const tgt::ivec3 &dimensions, const tgt::vec3 &spacing=tgt::vec3(1.f), int bitsStored=BITS_PER_VOXEL)
 While using this constructor the class will use an preallocated chunk of memory given in data.
virtual ~VolumeAtomic ()
 Deletes the data_ array.
virtual VolumeAtomic< T > * clone () const throw (std::bad_alloc)
 Use this as a kind of a virtual constructor.
virtual VolumeAtomic< T > * clone (void *data) const throw (std::bad_alloc)
 Use this as a kind of a virtual constructor that does _NOT_ copy over the voxels but uses the given pointer instead as a voxel data.
virtual int getBitsAllocated () const
 Returns the number of bits that are allocated by each voxel.
virtual int getNumChannels () const
 Returns the number of channels of this volume.
virtual int getBytesPerVoxel () const
 Returns the number of bytes that are allocated for each voxel.
virtual tgt::vec2 elementRange () const
 Returns the minimal and maximal element data values that can be contained by the volume according to its data type.
min () const
 Returns the minimum data value that is actually contained by the volume.
max () const
 Returns the maximal data value that is actually contained by the volume.
virtual size_t getNumBytes () const
 Returns the number of bytes held in the data_ array.
T * voxel ()
 just get a proper pointer for read and write access
const T * voxel () const
 just get a proper pointer for read access only
T & voxel (size_t x, size_t y, size_t z)
 get or set voxel
const T & voxel (size_t x, size_t y, size_t z) const
 get voxel
T & voxel (const tgt::ivec3 &pos)
 get or set voxel
const T & voxel (const tgt::ivec3 &pos) const
 get voxel
T & voxel (size_t i)
 get or set voxel
const T & voxel (size_t i) const
 get voxel
virtual float getVoxelFloat (const tgt::ivec3 &pos, size_t channel=0) const
 Returns the voxel of a given postion and channel, converted to a float.
virtual float getVoxelFloat (size_t x, size_t y, size_t z, size_t channel=0) const
 Returns the voxel of a given postion and channel, converted to a float.
virtual float getVoxelFloat (size_t index, size_t channel=0) const
 Returns the voxel of a given position and channel, converted to a float.
virtual void setVoxelFloat (float value, const tgt::ivec3 &pos, size_t channel=0)
 Sets the voxel of a given postion and channel, converted from a float.
virtual void setVoxelFloat (float value, size_t x, size_t y, size_t z, size_t channel=0)
 Sets the voxel of a given postion and channel, converted from a float.
virtual void setVoxelFloat (float value, size_t index, size_t channel=0)
 Sets the voxel of a given postion and channel, converted from a float.
virtual void clear ()
 Set all volume data to zero.
virtual void * getData ()
 Gets a void* to the data stored with this Volume.
virtual void resize (tgt::ivec3 newDims, bool allocMem=true) throw (std::bad_alloc)
 Resizes the volume to the specified dimensions by keeping its remaining properties.
virtual VolumeAtomic< T > * resample (tgt::ivec3 newDims, Filter filter) const throw (std::bad_alloc)
 Returns a volume that has been resampled to the specified dimensions by using the given filtering mode.
virtual VolumeAtomic< T > * createSubset (tgt::ivec3 pos, tgt::ivec3 size) const throw (std::bad_alloc)
virtual VolumeAtomic< T > * halfsample () const throw (std::bad_alloc)
 Reduces the Volume's resolution by half, by linearly downsampling 8 voxels to 1 voxel.
virtual void invalidate () const
 Invalidates cached values (e.g.

Static Public Member Functions

static bool isSigned ()
 Returns whether the volume's data type is signed.
static bool isBounded ()
 Returns whether the volume's data type is bounded, which is true for integer types and false for floating point types.
static size_t calcPos (const tgt::ivec3 &dimensions, size_t x, size_t y, size_t z)
static size_t calcPos (const tgt::ivec3 &dimensions, const tgt::ivec3 &pos)

Protected Attributes

T * data_
tgt::vec2 elementRange_
maxValue_
minValue_
bool minMaxValid_

Detailed Description

template<class T>
class voreen::VolumeAtomic< T >

Definition at line 46 of file volumeatomic.h.


Constructor & Destructor Documentation

VolumeAtomic ( const tgt::ivec3 dimensions,
const tgt::vec3 spacing = tgt::vec3(1.f),
int  bitsStored = BITS_PER_VOXEL,
bool  allocMem = true 
) throw (std::bad_alloc) [inline]

While using this constructor the class will automatically allocate an appropriate chunk of memory.

This memory will be deleted by this class. If allocMem is false, no memory will be allocated. This can be used to create volumes without any data, in case you just want to store its dimensions, spacing etc. This is used for bricking for example, because the entry-exit point volume would otherwise allocate an enormous amount of memory, although only its dimensions are required.

Definition at line 260 of file volumeatomic.h.

VolumeAtomic ( T *  data,
const tgt::ivec3 dimensions,
const tgt::vec3 spacing = tgt::vec3(1.f),
int  bitsStored = BITS_PER_VOXEL 
) [inline]

While using this constructor the class will use an preallocated chunk of memory given in data.

This memory will be deleted by this class.

Definition at line 286 of file volumeatomic.h.


Member Function Documentation

VolumeAtomic< T > * clone ( void *  data  )  const throw (std::bad_alloc) [inline, virtual]

Use this as a kind of a virtual constructor that does _NOT_ copy over the voxels but uses the given pointer instead as a voxel data.

If this pointer is 0, an empty volume without voxel data is created.

Implements Volume.

Definition at line 328 of file volumeatomic.h.

tgt::vec2 elementRange (  )  const [inline, virtual]

Returns the minimal and maximal element data values that can be contained by the volume according to its data type.

Note:
for unbounded types, (0.0, 1.0) is returned

Implements Volume.

Definition at line 459 of file volumeatomic.h.

int getBitsAllocated (  )  const [inline, virtual]

Returns the number of bits that are allocated by each voxel.

For technical reasons, it may exceed the volume's bit depth.

Implements Volume.

Definition at line 424 of file volumeatomic.h.

float getVoxelFloat ( size_t  index,
size_t  channel = 0 
) const [inline, virtual]

Returns the voxel of a given position and channel, converted to a float.

BEWARE: Since this method is virtual it can be considered as slow.

Parameters:
index the index of the voxel
channel the channel of the voxel

Implements Volume.

Definition at line 387 of file volumeatomic.h.

float getVoxelFloat ( size_t  x,
size_t  y,
size_t  z,
size_t  channel = 0 
) const [inline, virtual]

Returns the voxel of a given postion and channel, converted to a float.

BEWARE: Since this method is virtual it can be considered as slow.

Parameters:
x the x-coordinate of the voxel
y the y-coordinate of the voxel
z the z-coordinate of the voxel
channel the channel of the voxel

Implements Volume.

Definition at line 382 of file volumeatomic.h.

float getVoxelFloat ( const tgt::ivec3 pos,
size_t  channel = 0 
) const [inline, virtual]

Returns the voxel of a given postion and channel, converted to a float.

BEWARE: Since this method is virtual it can be considered as slow.

Parameters:
pos the position of the voxel
channel the channel of the voxel

Implements Volume.

Definition at line 377 of file volumeatomic.h.

VolumeAtomic< T > * halfsample (  )  const throw (std::bad_alloc) [inline, virtual]

Reduces the Volume's resolution by half, by linearly downsampling 8 voxels to 1 voxel.

This does not necessarily happen when using the scale(..) function.

Reimplemented from Volume.

Definition at line 661 of file volumeatomic.h.

void invalidate (  )  const [inline, virtual]

Invalidates cached values (e.g.

min/max), should be called when the volume was modified.

Definition at line 493 of file volumeatomic.h.

T max (  )  const [inline]

Returns the maximal data value that is actually contained by the volume.

Note:
Calculated min/max values are cached. Call invalidate() in order to enforce a recalculation.

Definition at line 476 of file volumeatomic.h.

T min (  )  const [inline]

Returns the minimum data value that is actually contained by the volume.

Note:
Calculated min/max values are cached. Call invalidate() in order to enforce a recalculation.

Definition at line 464 of file volumeatomic.h.

VolumeAtomic< T > * resample ( tgt::ivec3  newDims,
Filter  filter 
) const throw (std::bad_alloc) [inline, virtual]

Returns a volume that has been resampled to the specified dimensions by using the given filtering mode.

Returns:
the resampled volume

Implements Volume.

Definition at line 529 of file volumeatomic.h.

void resize ( tgt::ivec3  newDims,
bool  allocMem = true 
) throw (std::bad_alloc) [inline, virtual]

Resizes the volume to the specified dimensions by keeping its remaining properties.

Note:
The volume data is is cleared by this operation.
Parameters:
newDims the volume's new dimensions
allocMem if true, a new data buffer is allocated

Implements Volume.

Definition at line 503 of file volumeatomic.h.

void setVoxelFloat ( float  value,
size_t  index,
size_t  channel = 0 
) [inline, virtual]

Sets the voxel of a given postion and channel, converted from a float.

BEWARE: Since this method is virtual it can be considered as slow.

Parameters:
value The float value to be set.
index the index of the voxel
channel the channel of the voxel

Implements Volume.

Definition at line 408 of file volumeatomic.h.

void setVoxelFloat ( float  value,
size_t  x,
size_t  y,
size_t  z,
size_t  channel = 0 
) [inline, virtual]

Sets the voxel of a given postion and channel, converted from a float.

BEWARE: Since this method is virtual it can be considered as slow.

Parameters:
value The float value to be set.
x the x-coordinate of the voxel
y the y-coordinate of the voxel
z the z-coordinate of the voxel
channel the channel of the voxel

Implements Volume.

Definition at line 403 of file volumeatomic.h.

void setVoxelFloat ( float  value,
const tgt::ivec3 pos,
size_t  channel = 0 
) [inline, virtual]

Sets the voxel of a given postion and channel, converted from a float.

BEWARE: Since this method is virtual it can be considered as slow.

Parameters:
value The float value to be set.
pos the position of the voxel
channel the channel of the voxel

Implements Volume.

Definition at line 397 of file volumeatomic.h.