1 /* @(#)r.proj.h v1.2 - 27 Jun 1995 -emes- */
2
3 #ifndef R_PROJ_H
4 #define R_PROJ_H
5
6 #include <grass/gprojects.h>
7
8 #define L2BDIM 6
9 #define BDIM (1<<(L2BDIM))
10 #define L2BSIZE (2*(L2BDIM))
11 #define BSIZE (1<<(L2BSIZE))
12 #define HI(i) ((i)>>(L2BDIM))
13 #define LO(i) ((i)&((BDIM)-1))
14
15 typedef FCELL block[BDIM][BDIM];
16
17 struct cache
18 {
19 int fd;
20 char *fname;
21 int stride;
22 int nblocks;
23 block **grid;
24 block *blocks;
25 int *refs;
26 };
27
28 typedef void (*func) (struct cache *, void *, int, double, double,
29 struct Cell_head *);
30
31 struct menu
32 {
33 func method; /* routine to interpolate new value */
34 char *name; /* method name */
35 char *text; /* menu display - full description */
36 };
37
38 extern void bordwalk(const struct Cell_head *, struct Cell_head *,
39 const struct pj_info *, const struct pj_info *,
40 const struct pj_info *, int);
41 extern void bordwalk_edge(const struct Cell_head *, struct Cell_head *,
42 const struct pj_info *, const struct pj_info *,
43 const struct pj_info *, int);
44 extern struct cache *readcell(int, const char *);
45 extern block *get_block(struct cache *, int);
46 extern void release_cache(struct cache *);
47
48 /* declare resampling methods */
49 /* bilinear.c */
50 extern void p_bilinear(struct cache *, void *, int, double, double,
51 struct Cell_head *);
52 /* cubic.c */
53 extern void p_cubic(struct cache *, void *, int, double, double,
54 struct Cell_head *);
55 /* nearest.c */
56 extern void p_nearest(struct cache *, void *, int, double, double,
57 struct Cell_head *);
58 /* bilinear_f.c */
59 extern void p_bilinear_f(struct cache *, void *, int, double, double,
60 struct Cell_head *);
61 /* cubic_f.c */
62 extern void p_cubic_f(struct cache *, void *, int, double, double,
63 struct Cell_head *);
64 /* lanczos.c */
65 extern void p_lanczos(struct cache *, void *, int, double, double,
66 struct Cell_head *);
67 extern void p_lanczos_f(struct cache *, void *, int, double, double,
68 struct Cell_head *);
69
70 #if 1
71
72 #define BKIDX(c,y,x) ((y) * (c)->stride + (x))
73 #define BKPTR(c,y,x) ((c)->grid[BKIDX((c),(y),(x))])
74 #define BLOCK(c,y,x) (BKPTR((c),(y),(x)) ? BKPTR((c),(y),(x)) : get_block((c),BKIDX((c),(y),(x))))
75 #define CVAL(c,y,x) ((*BLOCK((c),HI((y)),HI((x))))[LO((y))][LO((x))])
76
77 #else
78
BKIDX(const struct cache * c,int y,int x)79 static inline int BKIDX(const struct cache *c, int y, int x)
80 {
81 return y * c->stride + x;
82 }
83
BKPTR(const struct cache * c,int y,int x)84 static inline block *BKPTR(const struct cache *c, int y, int x)
85 {
86 return c->grid[BKIDX(c, y, x)];
87 }
88
BLOCK(struct cache * c,int y,int x)89 static inline block *BLOCK(struct cache *c, int y, int x)
90 {
91 return BKPTR(c, y, x) ? BKPTR(c, y, x) : get_block(c, BKIDX(c, y, x));
92 }
93
CPTR(struct cache * c,int y,int x)94 static inline FCELL *CPTR(struct cache *c, int y, int x)
95 {
96 return &(*BLOCK(c, HI(y), HI(x)))[LO(y)][LO(x)];
97 }
98
99 #endif
100
101 #endif
102