31 #ifndef DRAIN_DIRECTION_H
32 #define DRAIN_DIRECTION_H
35 #include <drain/PseudoTuple.h>
36 #include <drain/util/Dictionary.h>
53 Position(
int i=0,
int j=0) : i(i), j(j) {
69 bool operator==(
const Position & pos)
const {
70 return ((i == pos.i) && (j == pos.j));
74 bool operator!=(
const Position & pos)
const {
75 return ((i != pos.i) || (j != pos.j));
96 #define DIR_TURN_DEG(dir, deg) (((dir << (deg/45)) & 0xff) | (dir >> (8 - deg/45)))
101 typedef short int value_t;
103 static const value_t NONE = 0;
104 static const value_t UP=1;
105 static const value_t UP_RIGHT=2;
106 static const value_t RIGHT=4;
107 static const value_t DOWN_RIGHT=8;
108 static const value_t DOWN=16;
109 static const value_t DOWN_LEFT=32;
110 static const value_t LEFT=64;
111 static const value_t UP_LEFT=128;
113 static const value_t RECTANGULAR = UP | RIGHT | DOWN | LEFT;
114 static const value_t DIAGONAL = UP_RIGHT | DOWN_RIGHT | DOWN_LEFT | UP_LEFT;
117 bool isDiagonal(value_t dir){
118 return (dir & DIAGONAL) > 0;
126 static const dict_t arrows;
178 std::ostream &operator<<(std::ostream &ostr,
const Position & p){
179 ostr <<
'[' << p.i <<
',' << p.j <<
']';
Two-way mapping between strings and objects of template class T.
Definition: Dictionary.h:63
Definition: PseudoTuple.h:60
Definition: DataSelector.cpp:1277
Definition: Direction.h:99
static const std::map< value_t, Position > offset
Opposite direction.
Definition: Direction.h:173
Definition: Direction.h:46