NPL
Neurological Programs and Libraries
|
This class is used to step through an ND array in order of dimensions. Order may be any size from 0 to the number of dimensions. The first member of order will be the fastest moving, and the last will be the slowest. Any not dimensions not included in the order vector will be slower than the last member of order. More...
#include <slicer.h>
Inherited by npl::NDConstIter< double >, npl::NDConstIter< T >, npl::NDIter< T >, npl::Vector3DConstIter< T >, and npl::Vector3DIter< T >.
Public Member Functions | |
Slicer () | |
Default Constructor, max a length 1, dimension 1 slicer. More... | |
Slicer (size_t ndim, const size_t *dim) | |
Constructor, takses the number of dimensions and the size of the image. More... | |
void | setDim (size_t ndim, const size_t *dim) |
Updates dimensions of target nd array. More... | |
bool | isBegin () const |
Are we at the begining of iteration? More... | |
bool | isEnd () const |
Are we at the end of iteration? Note that this will be 1 past the end, as typically is done in c++. More... | |
bool | eof () const |
Are we at the end of iteration? Note that this will be 1 past the end, as typically is done in c++. More... | |
Slicer & | operator++ () |
Prefix iterator. Iterates in the order dictatored by the dimension order passsed during construction or by setOrder. More... | |
Slicer & | operator-- () |
Prefix negative iterator. Iterates in the order dictatored by the dimension order passsed during construction or by setOrder. More... | |
void | goBegin () |
Are we at the begining of iteration? More... | |
void | goEnd () |
Jump to the end of iteration. More... | |
void | goIndex (size_t len, int64_t *newpos) |
Jump to the given position, additional values in newpos beyond dim will be ignored. Any values missing due to ndim > len will be treated as zeros. More... | |
void | goIndex (std::vector< int64_t > newpos) |
Jump to the given position. More... | |
int64_t | operator* () const |
dereference operator. Returns the linear position in the array given the n-dimensional position. More... | |
void | index (size_t len, int64_t *index) const |
Places the first len dimension in the given array. If the number of dimensions exceed the len then the additional dimensions will be ignored, if len exceeds the dimensionality then index[dim...len-1] = 0. In other words index will be completely overwritten in the most sane way possible if the internal dimensions and size index differ. More... | |
void | index (size_t len, int *index) const |
Places the first len dimension in the given array. If the number of dimensions exceed the len then the additional dimensions will be ignored, if len exceeds the dimensionality then index[dim...len-1] = 0. In other words index will be completely overwritten in the most sane way possible if the internal dimensions and size index differ. More... | |
void | index (size_t len, double *index) const |
Places the first len dimension in the given array. If the number of dimensions exceed the len then the additional dimensions will be ignored, if len exceeds the dimensionality then index[dim...len-1] = 0. In other words index will be completely overwritten in the most sane way possible if the internal dimensions and size index differ. More... | |
void | index (std::vector< int64_t > &ind) const |
Places the first len dimension in the given array. If the number of dimensions exceed the len then the additional dimensions will be ignored, if len exceeds the dimensionality then index[dim...len-1] = 0. In other words index will be completely overwritten in the most sane way possible if the internal dimensions and size index differ. More... | |
void | index (std::vector< int > &ind) const |
Places the first len dimension in the given array. If the number of dimensions exceed the len then the additional dimensions will be ignored, if len exceeds the dimensionality then index[dim...len-1] = 0. In other words index will be completely overwritten in the most sane way possible if the internal dimensions and size index differ. More... | |
void | index (std::vector< double > &ind) const |
Places the first len dimension in the given array. If the number of dimensions exceed the len then the additional dimensions will be ignored, if len exceeds the dimensionality then index[dim...len-1] = 0. In other words index will be completely overwritten in the most sane way possible if the internal dimensions and size index differ. More... | |
int64_t | index (size_t dd) const |
Returns the index in the specified dimension. More... | |
size_t | linIndex () const |
get linear position of current point More... | |
int64_t | getStride (size_t dd) |
get stride in specified dimension More... | |
void | setROI (size_t len, const size_t *roisize, const int64_t *roistart=NULL) |
Sets the region of interest, with lower bound of 0. During iteration or any motion the position will not move outside the specified range. Invalidates position. More... | |
void | setROI (const std::vector< std::pair< int64_t, int64_t >> &roi) |
Sets the region of interest. During iteration or any motion the position will not move outside the specified range. Extra elements in roi beyond the number of dimensions, are ignored. More... | |
void | setOrder (const std::vector< size_t > &order, bool revorder=false) |
Sets the order of iteration from increment operators. More... | |
void | setOrder (std::initializer_list< size_t > order, bool revorder=false) |
Sets the order of iteration from ++/– operators. More... | |
void | setOrder () |
Sets the order of iteration from ++/– operators. Order will be the default (highest to lowest) More... | |
const std::vector< size_t > & | getOrder () const |
Returns the array giving the order of dimension being traversed. So 3,2,1,0 would mean that the next point in dimension 3 will be next, when wrapping the next point in 2 is visited, when that wraps the next in one and so on. More... | |
Protected Attributes | |
size_t | m_linpos |
size_t | m_linfirst |
std::vector< int64_t > | m_pos |
bool | m_end |
size_t | m_ndim |
std::vector< size_t > | m_order |
std::vector< std::pair< int64_t, int64_t > > | m_roi |
std::vector< size_t > | m_dim |
std::vector< size_t > | m_strides |
This class is used to step through an ND array in order of dimensions. Order may be any size from 0 to the number of dimensions. The first member of order will be the fastest moving, and the last will be the slowest. Any not dimensions not included in the order vector will be slower than the last member of order.
npl::Slicer::Slicer | ( | ) |
Default Constructor, max a length 1, dimension 1 slicer.
npl::Slicer::Slicer | ( | size_t | ndim, |
const size_t * | dim | ||
) |
Constructor, takses the number of dimensions and the size of the image.
ndim | size of ND array |
dim | array providing the size in each dimension |
|
inline |
|
inline |
|
inline |
void npl::Slicer::goBegin | ( | ) |
Are we at the begining of iteration?
void npl::Slicer::goEnd | ( | ) |
Jump to the end of iteration.
void npl::Slicer::goIndex | ( | size_t | len, |
int64_t * | newpos | ||
) |
Jump to the given position, additional values in newpos beyond dim will be ignored. Any values missing due to ndim > len will be treated as zeros.
len | Length of newpos array |
newpos | location to move to |
void npl::Slicer::goIndex | ( | std::vector< int64_t > | newpos | ) |
Jump to the given position.
newpos | location to move to |
void npl::Slicer::index | ( | size_t | len, |
int64_t * | index | ||
) | const |
Places the first len dimension in the given array. If the number of dimensions exceed the len then the additional dimensions will be ignored, if len exceeds the dimensionality then index[dim...len-1] = 0. In other words index will be completely overwritten in the most sane way possible if the internal dimensions and size index differ.
len | size of index |
index | output index variable |
void npl::Slicer::index | ( | size_t | len, |
int * | index | ||
) | const |
Places the first len dimension in the given array. If the number of dimensions exceed the len then the additional dimensions will be ignored, if len exceeds the dimensionality then index[dim...len-1] = 0. In other words index will be completely overwritten in the most sane way possible if the internal dimensions and size index differ.
len | size of index |
index | output index variable |
void npl::Slicer::index | ( | size_t | len, |
double * | index | ||
) | const |
Places the first len dimension in the given array. If the number of dimensions exceed the len then the additional dimensions will be ignored, if len exceeds the dimensionality then index[dim...len-1] = 0. In other words index will be completely overwritten in the most sane way possible if the internal dimensions and size index differ.
len | size of index |
index | output index variable |
|
inline |
Places the first len dimension in the given array. If the number of dimensions exceed the len then the additional dimensions will be ignored, if len exceeds the dimensionality then index[dim...len-1] = 0. In other words index will be completely overwritten in the most sane way possible if the internal dimensions and size index differ.
ind | output index variable |
|
inline |
Places the first len dimension in the given array. If the number of dimensions exceed the len then the additional dimensions will be ignored, if len exceeds the dimensionality then index[dim...len-1] = 0. In other words index will be completely overwritten in the most sane way possible if the internal dimensions and size index differ.
ind | output index variable |
|
inline |
Places the first len dimension in the given array. If the number of dimensions exceed the len then the additional dimensions will be ignored, if len exceeds the dimensionality then index[dim...len-1] = 0. In other words index will be completely overwritten in the most sane way possible if the internal dimensions and size index differ.
ind | output index variable |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Slicer& npl::Slicer::operator++ | ( | ) |
Prefix iterator. Iterates in the order dictatored by the dimension order passsed during construction or by setOrder.
Slicer& npl::Slicer::operator-- | ( | ) |
Prefix negative iterator. Iterates in the order dictatored by the dimension order passsed during construction or by setOrder.
void npl::Slicer::setDim | ( | size_t | ndim, |
const size_t * | dim | ||
) |
Updates dimensions of target nd array.
ndim | Rank (dimensionality) of data block, length of dim |
dim | Size of data block, in each dimension, so dim = {32, 2,54 } would have 32*2*54 members |
void npl::Slicer::setOrder | ( | const std::vector< size_t > & | order, |
bool | revorder = false |
||
) |
Sets the order of iteration from increment operators.
order | vector of priorities, with first element being the fastest iteration and last the slowest. All other dimensions not used will be slower than the last |
revorder | Reverse order, in which case the first element of order will have the slowest iteration, and dimensions not specified in order will be faster than those included. |
void npl::Slicer::setOrder | ( | std::initializer_list< size_t > | order, |
bool | revorder = false |
||
) |
Sets the order of iteration from ++/– operators.
order | vector of priorities, with first element being the fastest iteration and last the slowest. All other dimensions not used will be slower than the last |
revorder | Reverse order, in which case the first element of order will have the slowest iteration, and dimensions not specified in order will be faster than those included. |
void npl::Slicer::setOrder | ( | ) |
Sets the order of iteration from ++/– operators. Order will be the default (highest to lowest)
void npl::Slicer::setROI | ( | size_t | len, |
const size_t * | roisize, | ||
const int64_t * | roistart = NULL |
||
) |
Sets the region of interest, with lower bound of 0. During iteration or any motion the position will not move outside the specified range. Invalidates position.
Invalidates position
len | length of roi array |
roisize | Size of ROI (which runs in the block from: [roistart[0] ... roisize[0]-1, roistart[0] ... roisize[1]-1, etc] or, if roistart is Null then [0 ... roisize[0]-1, 0 ... roisize[1]-1, etc] |
roistart | Lower corner of region-of-interest |
void npl::Slicer::setROI | ( | const std::vector< std::pair< int64_t, int64_t >> & | roi | ) |
Sets the region of interest. During iteration or any motion the position will not move outside the specified range. Extra elements in roi beyond the number of dimensions, are ignored.
roi | pair of [min,max] values in the desired hypercube |
|
protected |