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