Image Component Library (ICL)
|
Abstract data segment class. More...
#include <DataSegmentBase.h>
Classes | |
class | Bytes |
Very simple Byte Vector class to provide binary access to DataSegmentBase data. More... | |
Public Member Functions | |
bool | isOrganized () const |
returns, whether the segment is 2D-organized | |
utils::Size | getSize () const |
returns the ordred size of the segment of utils::Size::null if it's not organized | |
int | getStride () const |
returns the internal stride used | |
int | getDim () const |
returns the number of elements | |
core::depth | getDepth () const |
returns the actual core::depth (data type) of the entries | |
int | getElemDim () const |
returns the dimension of the contained elements | |
icl8u * | getDataPointer () |
returns the internal (strided) data pointer | |
const icl8u * | getDataPointer () const |
returns the internal (strided) data pointer | |
DataSegmentBase (void *data=0, size_t stride=0, size_t numElements=0, icl32s organizedWidth=-1, core::depth dataDepth=core::depth8u, size_t elemDim=0) | |
Constructor with given parameters. | |
template<class T , int N> | |
const DataSegment< T, N > & | as () const |
shallow and save cast from data segment base to special data segment version | |
Bytes | operator[] (int idx) |
linear index operator | |
const Bytes | operator[] (int idx) const |
linear index operator (const) | |
Bytes | operator() (int x, int y) |
2D-index operator (only for organized data segments) | |
const Bytes | operator() (int x, int y) const |
2D-index operator (only for organized data segments, const) | |
Static Protected Member Functions | |
static int | getSizeOf (core::depth d) |
associcates a core::depth values and the (byte)-size of the corresponding type | |
Protected Attributes | |
icl8u * | data |
data pointer orign | |
size_t | stride |
stride between elements | |
size_t | numElements |
number of vector elements contained | |
icl32s | organizedWidth |
if > 0 , the data is 2D-organized | |
core::depth | dataDepth |
underlying data depth | |
size_t | elemDim |
vector element dim | |
Friends | |
class | geom::PointCloudObjectBase |
for easier integration with the pointcloud object base class |
Abstract data segment class.
The DataSegmentBase class is a generic base class for interleaved data sets. It is use as a base class for all versions of the DataSegment class template. While the the latter provides typesave access to all data entries, the DataSegmentBase class provides runtime information about the actual type. The DataSegmentBase::as template method can be used for a type-checked cast into an actual DataSegment type, which provides type-safe access to the reference data.
Data segments allow for an easy access to different types of interleaved data. Internally a single stride value is used to allow for wrapping strided data as well. Examples are given in the DataSegment<T> template class. The following ascii art graphics illustrates the Idea of the data segment:
consider a data set as a table | x y z timestamp r g b ------------------------------------------- 0 | 2.0 4.3 5.5 3478932 255 0 0 1 | 2.1 3.3 6.4 3478933 0 255 0 ...
The a DataSegment could e.g. reference the columns x,y and z Where each entry is a 3D vector with float elements. The internal stride is defined by the size of a whole row. But please note that the DataSegment does not provide an internal stride, i.e. the elements of a single vector (here x,y,z) must always be packed in memory.
DataSegments are only shallow wrappers around data that is mananged externally. Therefore, copying (by copy constructor or assignment) DataSegment instances always leeds to shallow copier.
Data segments can be either 1D or 2D organized. In case of 2D organization, an positive "organizedWidth" value has to be given to the constructor.
Since the DataSegmentBase does not provice type-save data access directly, it provides binary data access operators that return instances of the internal untility class DataSegmentBase::Bytes. These can be copied deeply (by simple assignment) and the DataSegmentBase::Bytes class does also provide iterator based access to every byte element
icl::core::DataSegmentBase::DataSegmentBase | ( | void * | data = 0 , |
size_t | stride = 0 , |
||
size_t | numElements = 0 , |
||
icl32s | organizedWidth = -1 , |
||
core::depth | dataDepth = core::depth8u , |
||
size_t | elemDim = 0 |
||
) | [inline] |
Constructor with given parameters.
const DataSegment<T,N>& icl::core::DataSegmentBase::as | ( | ) | const |
shallow and save cast from data segment base to special data segment version
This function performs a save shallow cast, by evaluating runtime core::depth and dim parameters to throw an instance of utils::ICLException if the targetet type is not compatible
Please note: this function can only be defined after the DataSegment template class definition is available, so you can find it after that class,
icl8u* icl::core::DataSegmentBase::getDataPointer | ( | ) | [inline] |
returns the internal (strided) data pointer
only for those who know what they are doing
const icl8u* icl::core::DataSegmentBase::getDataPointer | ( | ) | const [inline] |
returns the internal (strided) data pointer
only for those who know what they are doing
core::depth icl::core::DataSegmentBase::getDepth | ( | ) | const [inline] |
returns the actual core::depth (data type) of the entries
int icl::core::DataSegmentBase::getDim | ( | ) | const [inline] |
returns the number of elements
If the data is 2D-organized, than width*height is returned
int icl::core::DataSegmentBase::getElemDim | ( | ) | const [inline] |
returns the dimension of the contained elements
utils::Size icl::core::DataSegmentBase::getSize | ( | ) | const [inline] |
returns the ordred size of the segment of utils::Size::null if it's not organized
static int icl::core::DataSegmentBase::getSizeOf | ( | core::depth | d | ) | [inline, static, protected] |
associcates a core::depth values and the (byte)-size of the corresponding type
int icl::core::DataSegmentBase::getStride | ( | ) | const [inline] |
returns the internal stride used
bool icl::core::DataSegmentBase::isOrganized | ( | ) | const [inline] |
returns, whether the segment is 2D-organized
Bytes icl::core::DataSegmentBase::operator() | ( | int | x, |
int | y | ||
) | [inline] |
2D-index operator (only for organized data segments)
Reimplemented in icl::core::DataSegment< T, 1 >, icl::core::DataSegment< T, N >, and icl::core::DataSegment< float, 4 >.
const Bytes icl::core::DataSegmentBase::operator() | ( | int | x, |
int | y | ||
) | const [inline] |
2D-index operator (only for organized data segments, const)
Reimplemented in icl::core::DataSegment< T, 1 >, icl::core::DataSegment< T, N >, and icl::core::DataSegment< float, 4 >.
Bytes icl::core::DataSegmentBase::operator[] | ( | int | idx | ) | [inline] |
linear index operator
Reimplemented in icl::core::DataSegment< T, 1 >, icl::core::DataSegment< T, N >, and icl::core::DataSegment< float, 4 >.
const Bytes icl::core::DataSegmentBase::operator[] | ( | int | idx | ) | const [inline] |
linear index operator (const)
Reimplemented in icl::core::DataSegment< T, 1 >, icl::core::DataSegment< T, N >, and icl::core::DataSegment< float, 4 >.
friend class geom::PointCloudObjectBase [friend] |
for easier integration with the pointcloud object base class
icl8u* icl::core::DataSegmentBase::data [protected] |
data pointer orign
core::depth icl::core::DataSegmentBase::dataDepth [protected] |
underlying data depth
size_t icl::core::DataSegmentBase::elemDim [protected] |
vector element dim
size_t icl::core::DataSegmentBase::numElements [protected] |
number of vector elements contained
icl32s icl::core::DataSegmentBase::organizedWidth [protected] |
if > 0 , the data is 2D-organized
size_t icl::core::DataSegmentBase::stride [protected] |
stride between elements
The stride defines the number of bytes, one has to jump, to get from one vector start to the next start. The unit is byte E.g.
float data[2*4] = {x,y,z,_, x,y,z, _}; // -> stride = 4*sizeof(float)