forked from OSGeo/grass
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflag.h
53 lines (39 loc) · 1.26 KB
/
flag.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/** idea by Michael Shapiro
** code by Chuck Ehlschlaeger
** April 03, 1989
*/
#include <stdio.h>
#define FLAG struct _f_l_a_g_
FLAG {
int nrows, ncols, leng;
unsigned char **array;
};
#define FLAG_UNSET(flags,row,col) \
(flags)->array[(row)][(col)>>3] &= ~(1<<((col) & 7))
#define FLAG_SET(flags,row,col) \
(flags)->array[(row)][(col)>>3] |= (1<<((col) & 7))
#define FLAG_GET(flags,row,col) \
(flags)->array[(row)][(col)>>3] & (1<<((col) & 7))
/* flag.[ch] is a set of routines which will set up an array of bits
** that allow the programmer to "flag" cells in a raster map.
**/
FLAG *FlagCreate(int nrows, int ncols);
/** opens the structure flag.
** The flag structure will be a two dimensional array of bits the
** size of nrows by ncols. Will initialize flags to zero (unset).
**/
void FlagDestroy(FLAG * flags);
/** closes flags and gives the memory back to the system.
**/
void FlagClearAll(FLAG * flags);
/** sets all values in flags to zero.
**/
void FlagUnset(FLAG * flags, int row, int col);
/** sets the value of (row, col) in flags to zero.
**/
void FlagSet(FLAG * flags, int row, int col);
/** will set the value of (row, col) in flags to one.
**/
int FlagGet(FLAG * flags, int row, int col);
/** returns the value in flags that is at (row, col).
**/