GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
gsget.h
Go to the documentation of this file.
1 #ifndef _GSGET_H
2 #define _GSGET_H
3 
4 #include <grass/gsurf.h>
5 
6 #define GET_MAPATT1(buff, offset, att) att=(buff->ib? (float)buff->ib[offset]: \
7  buff->sb? (float)buff->sb[offset]: \
8  buff->cb? (float)buff->cb[offset]: \
9  buff->fb? (float)buff->fb[offset]: \
10  0.0)
11 
12 #define GET_MAPATT2(buff, offset, att) att=(buff->ib? (float)buff->ib[offset]: \
13  buff->sb? (float)buff->sb[offset]: \
14  buff->cb? (float)buff->cb[offset]: \
15  buff->fb? (float)buff->fb[offset]: \
16  buff->k); \
17  if(buff->tfunc) \
18  att = (buff->tfunc)(att, offset);
19 
20 /* cast to float, otherwise doesn't seem to handle neg. values */
21 
22 #define SCALE_ATT(att, val, low, high) ((val) <= att->max_nz && \
23  (val) >= att->min_nz && att->range_nz? \
24  (((val) - att->min_nz)/att->range_nz) * \
25  ((high) - (low)) + (low): 0)
26 
27 #define GET_MAPATT(buff, offset, att) (get_mapatt(buff, offset, &(att)))
28 
29 #define BM_GET_BYOFFSET(bm, off) (bm? BM_get(bm, (off%bm->cols), (off/bm->cols)): 0)
30 
31 
32 
33 #define XYMAXPOS 0x3ff /* 1023 */
34 #define ZMAXPOS 0x3ff /* 1023 */
35 
36 #define NXMASK 0xffe00000 /* top 11 bits */
37 #define NYMASK 0x1ffc00 /* middle 11 bits of packed int */
38 #define NZMASK 0x3ff /* lowest 10 bits */
39 
40 #define NZUP 0x000003ff
41 
42 /* Fetch Normal vector from packed int */
43 /*
44  #define FNORM(i,nv) \
45  nv[X] = ((int)(((i) & NXMASK) >> 21) - XYMAXPOS)/(float)XYMAXPOS; \
46  nv[Y] = ((int)(((i) & NYMASK) >> 10) - XYMAXPOS)/(float)XYMAXPOS; \
47  nv[Z] = (int)((i) & NZMASK) * GS_global_exag()/(float)ZMAXPOS
48  */
49 
50 #define FNORM(i,nv) \
51  nv[X] = ((int)(((i) & NXMASK) >> 21) - XYMAXPOS)/(float)XYMAXPOS; \
52  nv[Y] = ((int)(((i) & NYMASK) >> 10) - XYMAXPOS)/(float)XYMAXPOS; \
53  nv[Z] = (int)((i) & NZMASK) /(float)ZMAXPOS
54 
55 /* Pack Normal vector into int */
56 #define PNORM(i,nv) \
57  i = ((unsigned int)((nv[X]*XYMAXPOS)+XYMAXPOS) << 21) | \
58  ((unsigned int)((nv[Y]*XYMAXPOS)+XYMAXPOS) << 10) | \
59  (unsigned int)(nv[Z]*ZMAXPOS)
60 
61 #endif /* _GSGET_H */