| 1 | // =============================================================== // |
|---|
| 2 | // // |
|---|
| 3 | // File : ali_pathmap.hxx // |
|---|
| 4 | // Purpose : // |
|---|
| 5 | // // |
|---|
| 6 | // Institute of Microbiology (Technical University Munich) // |
|---|
| 7 | // http://www.arb-home.de/ // |
|---|
| 8 | // // |
|---|
| 9 | // =============================================================== // |
|---|
| 10 | |
|---|
| 11 | #ifndef ALI_PATHMAP_HXX |
|---|
| 12 | #define ALI_PATHMAP_HXX |
|---|
| 13 | |
|---|
| 14 | #ifndef ALI_TARRAY_HXX |
|---|
| 15 | #include "ali_tarray.hxx" |
|---|
| 16 | #endif |
|---|
| 17 | |
|---|
| 18 | #define ALI_UNDEF 0x00 |
|---|
| 19 | #define ALI_LEFT 0x01 |
|---|
| 20 | #define ALI_DIAG 0x02 |
|---|
| 21 | #define ALI_UP 0x04 |
|---|
| 22 | #define ALI_LUP 0x08 |
|---|
| 23 | |
|---|
| 24 | // Structure for a long up pointer (a multi gap) |
|---|
| 25 | struct ali_pathmap_up_pointer { |
|---|
| 26 | unsigned long start; |
|---|
| 27 | unsigned char operation; |
|---|
| 28 | }; |
|---|
| 29 | |
|---|
| 30 | class ALI_PATHMAP : virtual Noncopyable { |
|---|
| 31 | unsigned long width, height; |
|---|
| 32 | unsigned long height_real; |
|---|
| 33 | unsigned char **pathmap; |
|---|
| 34 | ALI_TARRAY<ali_pathmap_up_pointer> ****up_pointers; |
|---|
| 35 | unsigned char **optimized; |
|---|
| 36 | |
|---|
| 37 | public: |
|---|
| 38 | |
|---|
| 39 | ALI_PATHMAP(unsigned long width, unsigned long height); |
|---|
| 40 | ~ALI_PATHMAP(); |
|---|
| 41 | |
|---|
| 42 | void set(unsigned long x, unsigned long y, unsigned char val, |
|---|
| 43 | ALI_TARRAY<ali_pathmap_up_pointer> *up_pointer = 0); |
|---|
| 44 | void get(unsigned long x, unsigned long y, unsigned char *val, |
|---|
| 45 | ALI_TARRAY<ali_pathmap_up_pointer> **up_pointer); |
|---|
| 46 | unsigned char get_value(unsigned long x, unsigned long y) { |
|---|
| 47 | if (x >= width || y >= height) |
|---|
| 48 | ali_fatal_error("Out of range", "ALI_PATHMAP::get_value()"); |
|---|
| 49 | if (y & 0x01) |
|---|
| 50 | return (*pathmap)[x*height_real + y/2] & 0x0f; |
|---|
| 51 | else |
|---|
| 52 | return (*pathmap)[x*height_real + y/2] >> 4; |
|---|
| 53 | } |
|---|
| 54 | void optimize(unsigned long x); |
|---|
| 55 | void print(); |
|---|
| 56 | }; |
|---|
| 57 | |
|---|
| 58 | #else |
|---|
| 59 | #error ali_pathmap.hxx included twice |
|---|
| 60 | #endif // ALI_PATHMAP_HXX |
|---|