Rev 1221 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
399 | werner | 1 | #ifndef GRIDITERATOR_H |
2 | #define GRIDITERATOR_H |
||
3 | |||
4 | #include "grid.h" |
||
5 | |||
6 | /** GridIterator is a iterator used to navigate over grids with different size. |
||
7 | Usage: |
||
8 | GridIterator<float> gi(HeightGrid); // create the iterator and link to a grid of type float |
||
9 | gi.setRect(QRect(10., 10., 1120., 120.)); |
||
10 | while (float *p=gi.next()) { |
||
11 | // do something with *p |
||
12 | } |
||
13 | // usage (2) |
||
14 | gi.targetSize(targetGrid.size()); |
||
15 | gi.setTargetIndex(targetGrid.indexOf(coord)); |
||
16 | while (float *p=gi.next()) |
||
17 | *p++; |
||
18 | // usage(3) |
||
19 | gi.neighboursOf(index); // 8-neighbourhood |
||
20 | gi.neighboursOf(index, 2); // 2 rings, ..24 neighbours |
||
21 | while (float *p=gi.next()) |
||
22 | *p=0.; |
||
23 | */ |
||
24 | template <class T> |
||
25 | class GridIterator { |
||
26 | public: |
||
27 | GridIterator(); |
||
28 | GridIterator(const Grid<T> &targetGrid); |
||
29 | private: |
||
30 | |||
31 | } |
||
32 | #endif // GRIDITERATOR_H |