NAVIÉ
Documentation : Effex : Developer API : Classes : Iterators

### FXCellIterator

FXCellIterator

The FXCellIterator grants browse, read & write access to grid cells of a specific channel or volume.
It natively supports multiple processors so you don't have to worry about it yourself.
There are three different iterator types:
FXScalarCellIterator (for any scalar channel)
FXVectorCellIterator (for any vector channel)
FXVolumeCellIterator (for volumes)
The below definitions are displayed as if it was a class template although the specific classes are NOT accessed as a template.
It is just for convenience because all available cell iterators have the same interface definitions.
The template typenames are T and C, while T represents the datatype (double or vector3d) and C is the node type (FXScalarChannel, FXVectorChannel or FXVolume)

#### typename T GetValue(const int cpu)

Retrieves the value stored in the current cell.
Returns
the cell value. T is either double (FXScalarChannel, FXVolume) or vector3d (FXVectorChannel)
Parameters
const int cpu:
the current cpu thread.

#### typename T GetNeighborValue(const int cpu, short x, short y, short z)

Returns
the cell value of a neighboring cell. Either double (FXScalarChannel, FXVolume) or vector3d (FXVectorChannel)
Parameters
const int cpu:
the current cpu thread.
short x:
either 1 or -1 for the right or left neighbor cell respectively.
short y:
either 1 or -1 for the top or bottom neighbor cell respectively.
short z:
either 1 or -1 for the back or front neighbor cell respectively.

#### void SetValue(const int cpu, const typename T& value)

Overwrites the current cell's value.
Parameters
const int cpu:
the current cpu thread.
const T& value:
the new cell value. T is either double (FXScalarChannel, FXVolume) or vector3d (FXVectorChannel)

#### bool Init(typename C* channel)

Initialise the iterator for a specific channel and for single processor use.
Returns
true if the iterator was successfully initialised.
Parameters
C* channel:
the node to initialise the iterator for. C can be a FXScalarChannel, a FXVectorChannel or a FXVolume depending on the type of this iterator (FXScalarCellIterator, FXVectorCellIterator or FXVolumeCellIterator respectively).

#### bool Init(typename C* channel, int cpus, bool include_borders = false)

Initialise the iterator for a specific channel and for multiple processor usage.
Returns
true if the iterator was successfully initialised.
Parameters
C* channel:
Pass the node to initialise the iterator for. C can be a FXScalarChannel, a FXVectorChannel or a FXVolume depending on the type of this iterator (FXScalarCellIterator, FXVectorCellIterator or FXVolumeCellIterator respectively).
int cpus:
Pass the amount of cpu threads you will be using for iterating cells.
bool include_borders:
Specifies if you want to also browse the outermost border cells. By default it does not.

#### inline void Start(const int cpu, bool reverse = false)

This will reset the iterator for the given cpu.
You should call this once before browsing in a multiprocessor context.
Parameters
const int cpu:
Pass the cpu thread to reset the iterator for.
bool reverse:
Pass true if you want to reverse iterate (backwards).

#### inline bool SetNext(const int cpu)

Steps the iterator to get the next cell. Use for forward stepping.
Returns
true if the iterator has been incremented.
Parameters
const int cpu:
the current cpu thread to increment the iterator for.

#### inline bool SetPrev(const int cpu)

Steps the iterator to get the previous cell. Use for backward stepping.
Returns
true if the iterator has been decremented.
Parameters
const int cpu:
the current cpu thread to decrement the iterator for.

#### inline void Offset(long offset)

Offsets the iterator to a user defined position. This is only used for single processor iterations!
You need to make sure yourself the resulting iterator position is valid.
Parameters
const long offset:
the iterator cell offset.

#### inline void OffsetSafe(long offset)

Offsets the iterator to a user defined position. This is only used for single processor iterations!
It will make sure the iterator never falls out of range (trades of performance though).
Parameters
const long offset:
the iterator cell offset.

#### inline bool IsValid(void)

Returns
true if the current iterator is valid.

#### static FXCellIterator* Alloc()

Allocates the iterator. You can use AutoAlloc for a scope based allocation.
Works the same for FXVectorCellIterator and FXVolumeCellIterator.
Returns
the according Cell iterator. The user owns the pointed object.

#### static void Free(FXCellIterator*& p)

Frees a previously allocated Cell Iterator..
Parameters
FXCellIterator*&:
Pass the Cell iterator to free.