golib  0.5
goSignal3D< T > Class Template Reference

Up to 3-dimensional (signal) data container. More...

#include <gosignal3d.h>

Public Member Functions

 goSignal3D ()
 Constructor.
 
 goSignal3D (goSize_t x, goSize_t y, goSize_t z, goSize_t blocksize_x=32, goSize_t blocksize_y=32, goSize_t blocksize_z=32, goSize_t border_x=0, goSize_t border_y=0, goSize_t border_z=0, goSize_t channelCount=1)
 Constructor. More...
 
 goSignal3D (goSignal3D< T > &other)
 Copy constructor. More...
 
const goSignal3D< T > & copy (const goSignal3DBase< T > &other)
 Copy operator. More...
 
virtual goSize_t memoryUsage () const
 Returns the size of this object or some measure of its memory consumption. More...
 
bool make (const goSize3D &size, const goSize3D &blockSize, const goSize3D &borderSize, goSize_t channelCount)
 Allocate memory. More...
 
bool make (goSize_t x, goSize_t y, goSize_t z, goSize_t blocksize_x=32, goSize_t blocksize_y=32, goSize_t blocksize_z=32, goSize_t border_x=0, goSize_t border_y=0, goSize_t border_z=0, goSize_t channelCount=1)
 
bool make (const goSignal3DBase< T > *other)
 Copies only the size, NOT THE DATA!
 
virtual void destroy ()
 
void fillByte (goInt8 b)
 Works only with linear-memory blocks. No sub blocks. Uses memset().
 
virtual void fill (const T *element)
 Fills this signal with element.
 
virtual void fill (goDouble v)
 
- Public Member Functions inherited from goSignal3DBase< T >
void setChanged ()
 
goCaller0< void > & getChangedCaller ()
 
void setPtr (T *p)
 
const goTypegetDataType () const
 
void setChannel (goSize_t c)
 
goSize_t getChannel () const
 
goPtrdiff_t getChannelOffset (goSize_t channel) const
 Get the pointer offset from a channel 0 element to the corresponding channel channel element. More...
 
virtual void setBorderFlags (int axes=GO_X|GO_Y|GO_Z, int borderFlag=GO_PERIODIC_BORDER)
 Sets the border behaviour. More...
 
virtual void setBorderFlags (const goFixedArray< int > &flags)
 
const goFixedArray< int > & getBorderFlags () const
 
bool setDataType (goTypeEnum t)
 
goDouble getValue (goIndex_t x, goIndex_t y=0, goIndex_t z=0, goSize_t channel=0) const
 Convenience function to get a value. More...
 
void setValue (goDouble value, goIndex_t x, goIndex_t y=0, goIndex_t z=0, goSize_t channel=0)
 Convenience function to set a value. More...
 
T * getPtr ()
 
const T * getPtr () const
 
const T * getRealPtr () const
 
T * getRealPtr ()
 
T * getPtr (goIndex_t x, goIndex_t y, goIndex_t z)
 
const T * getPtr (goIndex_t x, goIndex_t y, goIndex_t z) const
 
const goPtrdiff_t * getXDiff () const
 
const goPtrdiff_t * getYDiff () const
 
const goPtrdiff_t * getZDiff () const
 
goPtrdiff_t * getXDiff ()
 
goPtrdiff_t * getYDiff ()
 
goPtrdiff_t * getZDiff ()
 
const goPtrdiff_t * getXJump () const
 
const goPtrdiff_t * getYJump () const
 
const goPtrdiff_t * getZJump () const
 
goPtrdiff_t * getXJump ()
 
goPtrdiff_t * getYJump ()
 
goPtrdiff_t * getZJump ()
 
void setSize (goSize_t x, goSize_t y, goSize_t z, goSize_t channelCount=1)
 INTERNAL – DO NOT USE. More...
 
void setSize (const goSize3D &sz)
 INTERNAL – DO NOT USE. More...
 
void setSizeX (goSize_t s)
 INTERNAL – DO NOT USE. More...
 
void setSizeY (goSize_t s)
 INTERNAL – DO NOT USE. More...
 
void setSizeZ (goSize_t s)
 INTERNAL – DO NOT USE. More...
 
const goSize3DgetSize () const
 
const goSize3DgetBlockSize () const
 
const goSize3DgetBorderSize () const
 
void resizeBorder (const goSize3D &size)
 Resize the border and re-initialise internal data structures accordingly. More...
 
goSize_t getSizeX () const
 
goSize_t getSizeY () const
 
goSize_t getSizeZ () const
 
goIndex_t getBorderX () const
 
goIndex_t getBorderY () const
 
goIndex_t getBorderZ () const
 
goSize_t getBlockSizeX () const
 
goSize_t getBlockSizeY () const
 
goSize_t getBlockSizeZ () const
 
goSize_t getChannelCount () const
 
const goSignal3DBase< T > & reference (goSignal3DBase< T > &other)
 
bool operator== (goSignal3DBase< T > &other)
 
goDouble getMaximum () const
 
goDouble getMinimum () const
 
void getMinMax (goDouble &minRet, goDouble &maxRet) const
 
virtual void shiftLeftDiff (int n, int axes=GO_X|GO_Y|GO_Z)
 Copies the last valid values from the block data into the borders. More...
 
virtual void shiftRightDiff (int n, int axes=GO_X|GO_Y|GO_Z)
 
virtual void shiftLeftSize (int n, int axes=GO_X|GO_Y|GO_Z)
 
virtual void shiftRightSize (int n, int axes=GO_X|GO_Y|GO_Z)
 
void rotateAxes ()
 
void swapXY ()
 
void flip (int axis)
 BROKEN. Fix when there's time. More...
 
const T * getClosest (go3Vector< goFloat > &point) const
 
goFloat sample (go3Vector< goFloat > &point)
 
goDouble sum () const
 
goSignal3DBase< T > & operator+= (const goSignal3DBase< T > &other)
 Element-wise operator. More...
 
goSignal3DBase< T > & operator-= (const goSignal3DBase< T > &other)
 Element-wise operator. More...
 
goSignal3DBase< T > & operator*= (const goSignal3DBase< T > &other)
 Element-wise operator. More...
 
goSignal3DBase< T > & operator/= (const goSignal3DBase< T > &other)
 Element-wise operator. More...
 
goSignal3DBase< T > & operator+= (goFloat scalar)
 Element-wise operator. More...
 
goSignal3DBase< T > & operator-= (goFloat scalar)
 Element-wise operator. More...
 
goSignal3DBase< T > & operator*= (goFloat scalar)
 Element-wise operator. More...
 
goSignal3DBase< T > & operator/= (goFloat scalar)
 Element-wise operator. More...
 
void applyBorderFlags (int axis)
 
void applyBorderFlags ()
 
template<>
goDouble getValue (goIndex_t x, goIndex_t y, goIndex_t z, goSize_t channel) const
 
template<>
void setValue (goDouble value, goIndex_t x, goIndex_t y, goIndex_t z, goSize_t channel)
 
template<>
goFloat sample (go3Vector< goFloat > &point)
 
template<>
goDouble getMaximum () const
 
template<>
goDouble getMaximum () const
 
template<>
goDouble getMinimum () const
 
template<>
goDouble getMinimum () const
 
template<>
void fill (goDouble v)
 
template<>
goFloat sample (go3Vector< goFloat > &point)
 
template<>
goSignal3DBase< void * > & operator+= (goFloat scalar)
 
template<>
goSignal3DBase< void * > & operator-= (goFloat scalar)
 
template<>
goSignal3DBase< void * > & operator*= (goFloat scalar)
 
template<>
goSignal3DBase< void * > & operator/= (goFloat scalar)
 
- Public Member Functions inherited from goObjectBase
 goObjectBase ()
 Constructor.
 
virtual ~goObjectBase ()
 Destructor. More...
 
const char * getClassName () const
 Returns the class name. More...
 
int getClassID () const
 
void setObjectName (const char *name)
 Set name string for an object. More...
 
void setObjectName (const goString &name)
 Set name string for an object. More...
 
const goStringgetObjectName () const
 Get the object name. More...
 
virtual bool writeObjectFile (FILE *) const
 Write object to a file. More...
 
virtual bool readObjectFile (FILE *)
 Read object from a file. More...
 
void connectObject (goObjectBase *object)
 Connects an object to this object. More...
 
void disconnectObject (const goObjectBase *object)
 Disconnects an object from this object.
 
virtual bool callObjectMethod (int methodID, goObjectMethodParameters *param=NULL)
 Call an object method by identifier. More...
 
virtual bool queueObjectMethod (int methodID, goObjectMethodParameters *param=NULL, bool blocking=false)
 Enqueue a method call to an internal list of methods. More...
 
bool callQueuedMethods ()
 Call all queued methods. More...
 

Additional Inherited Members

- Public Types inherited from goSignal3DBase< T >
typedef goSignal3DIterator< T > iterator
 
- Public Attributes inherited from goSignal3DBase< T >
const typedef goSignal3DIterator< T > const_iterator
 
- Protected Member Functions inherited from goSignal3DBase< T >
 goSignal3DBase (goSize_t x, goSize_t y, goSize_t z, goSize_t blocksize_x=32, goSize_t blocksize_y=32, goSize_t blocksize_z=32, goSize_t border_x=16, goSize_t border_y=16, goSize_t border_z=16, goSize_t channelCount=1)
 
 goSignal3DBase (goSignal3DBase< T > &other)
 
bool initializeDataType ()
 
bool initialize (T *dataptr, goSize_t x, goSize_t y, goSize_t z, goSize_t blocksize_x=32, goSize_t blocksize_y=32, goSize_t blocksize_z=32, goSize_t border_x=16, goSize_t border_y=16, goSize_t border_z=16, goSize_t channelCount=1)
 
void cleanup ()
 
void setBorder (goSize_t x, goSize_t y, goSize_t z)
 INTERNAL – DO NOT USE. More...
 
void constantBorders (int axes=GO_X|GO_Y|GO_Z)
 
void periodicBorders (int axes=GO_X|GO_Y|GO_Z)
 
template<>
bool initializeDataType () INITIALIZE_DATATYPE_METHOD(GO_INT8)
 
template<>
bool initializeDataType () INITIALIZE_DATATYPE_METHOD(GO_INT16)
 
template<>
bool initializeDataType () INITIALIZE_DATATYPE_METHOD(GO_INT32)
 
template<>
bool initializeDataType () INITIALIZE_DATATYPE_METHOD(GO_UINT8)
 
template<>
bool initializeDataType () INITIALIZE_DATATYPE_METHOD(GO_UINT16)
 
template<>
bool initializeDataType () INITIALIZE_DATATYPE_METHOD(GO_UINT32)
 
template<>
bool initializeDataType () INITIALIZE_DATATYPE_METHOD(GO_FLOAT)
 
template<>
bool initializeDataType () INITIALIZE_DATATYPE_METHOD(GO_DOUBLE)
 
template<>
bool initializeDataType () INITIALIZE_DATATYPE_METHOD(GO_VOID_POINTER)
 
template<>
bool initializeDataType () INITIALIZE_DATATYPE_METHOD(GO_COMPLEX_SINGLE)
 
- Protected Member Functions inherited from goObjectBase
void setClassID (int id)
 Sets the class name.
 
void printClassMessage (const char *msg)
 Sets the class name. More...
 
void printClassMessage (goString &msg)
 Prints an informational message to the calling console. More...
 
void sendObjectMessage (int messageID, void *data=NULL)
 Sends a message to all connected objects.
 
void sendObjectMessage (goObjectBase *object, int messageID, void *data=NULL)
 Sends a message to a specific object.
 
virtual void receiveObjectMessage (const goObjectMessage &message)
 Receive a message. More...
 
- Protected Attributes inherited from goSignal3DBase< T >
T * ptr
 
T * real_ptr
 
goPtrdiff_t * xDiff
 
goPtrdiff_t * yDiff
 
goPtrdiff_t * zDiff
 
goPtrdiff_t * real_xDiff
 
goPtrdiff_t * real_yDiff
 
goPtrdiff_t * real_zDiff
 
goPtrdiff_t * myXJump
 
goPtrdiff_t * myYJump
 
goPtrdiff_t * myZJump
 
goPtrdiff_t * real_myXJump
 
goPtrdiff_t * real_myYJump
 
goPtrdiff_t * real_myZJump
 
goPtrdiff_t * myChannelOffset
 
goSize3D mySize
 
goSize3D myBorderSize
 
goSize3D myBlockSize
 
goSize3D myBlocks
 
goType myDataType
 
goSize_t myChannelCount
 
goSize_t myChannel
 
goFixedArray< int > myBorderFlags
 

Detailed Description

template<class T>
class goSignal3D< T >

Up to 3-dimensional (signal) data container.

Todo:
The size is initially (0,0,0). That may lead to segfaults where getPtr() is used on zero-size signals. Maybe it is better to set size to (1,1,1) by default.
Bug:
The size is initially (0,0,0). That may lead to segfaults where getPtr() is used on zero-size signals. Maybe it is better to set size to (1,1,1) by default.

The memory layout is sort of optimized to get some data locality when accessing the data locally in all dimensions.

Author
Christian Gosch
Examples
dwt.cc, and filter3d.cc.

Constructor & Destructor Documentation

◆ goSignal3D() [1/2]

template<class T >
goSignal3D< T >::goSignal3D ( goSize_t  x,
goSize_t  y,
goSize_t  z,
goSize_t  blocksize_x = 32,
goSize_t  blocksize_y = 32,
goSize_t  blocksize_z = 32,
goSize_t  border_x = 0,
goSize_t  border_y = 0,
goSize_t  border_z = 0,
goSize_t  channelCount = 1 
)

Constructor.

Note
This does not make sense for VOID type signals. Use setDataType() there first.
Parameters
xSize in x direction
ySize in y direction
zSize in z direction
blocksize_xBlock size in x direction
blocksize_yBlock size in y direction
blocksize_zBlock size in z direction
border_xBorder size in x direction
border_yBorder size in y direction
border_zBorder size in z direction

◆ goSignal3D() [2/2]

template<class T>
goSignal3D< T >::goSignal3D ( goSignal3D< T > &  other)

Copy constructor.

Creates a signal of the same size as other and copies the content.

Member Function Documentation

◆ copy()

template<class T>
const goSignal3D< T > & goSignal3D< T >::copy ( const goSignal3DBase< T > &  other)

Copy operator.

Resizes this signal to the size of other and copies the content.

◆ destroy()

template<class T >
void goSignal3D< T >::destroy ( )
virtual

Deletes the memory used by the block data.

Todo:
Take care what happens when axes are rotated. Nothing bad should happen though.

Reimplemented from goSignal3DBase< T >.

◆ make() [1/2]

template<class T >
bool goSignal3D< T >::make ( const goSize3D size,
const goSize3D blockSize,
const goSize3D borderSize,
goSize_t  channelCount 
)

Allocate memory.

See also
make()
Parameters
sizeSignal size
blockSizeBlock size
borderSizeBorde size
channelCountNumber of channels
Returns
True if successful, false otherwise.

◆ make() [2/2]

template<class T >
bool goSignal3D< T >::make ( goSize_t  x,
goSize_t  y,
goSize_t  z,
goSize_t  blockSizeX = 32,
goSize_t  blockSizeY = 32,
goSize_t  blockSizeZ = 32,
goSize_t  border_x = 0,
goSize_t  border_y = 0,
goSize_t  border_z = 0,
goSize_t  channelCount = 1 
)

Allocates memory of appropriate size for the whole signal. Sets diffs and size. The data is uninitialized. If make is called, destroy() should be called when the data is not referenced anymore. destroy() is NOT called automagically when the destructor is called. To destroy the actual data, destroy() needs to be called BEFORE deleting the object.

Parameters
xSize in x direction of the signal
ySize in y direction of the signal
zSize in z direction of the signal
border_xSize of the border in x direction
border_ySize of the border in y direction
border_zSize of the border in z direction
channelCountNumber of channels (defaults to 1). If you want to store, say, RGBA data, you would set this to 4.

◆ memoryUsage()

template<class T >
goSize_t goSignal3D< T >::memoryUsage ( ) const
virtual

Returns the size of this object or some measure of its memory consumption.

Overload this function as you please and as it makes sense.

Returns
Size in bytes of this object.

Reimplemented from goSignal3DBase< T >.


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