GRASS Programmer's Manual
6.4.2(2012)
|
00001 #ifndef _GSGET_H 00002 #define _GSGET_H 00003 00004 #include <grass/gsurf.h> 00005 00006 #define GET_MAPATT1(buff, offset, att) att=(buff->ib? (float)buff->ib[offset]: \ 00007 buff->sb? (float)buff->sb[offset]: \ 00008 buff->cb? (float)buff->cb[offset]: \ 00009 buff->fb? (float)buff->fb[offset]: \ 00010 0.0) 00011 00012 #define GET_MAPATT2(buff, offset, att) att=(buff->ib? (float)buff->ib[offset]: \ 00013 buff->sb? (float)buff->sb[offset]: \ 00014 buff->cb? (float)buff->cb[offset]: \ 00015 buff->fb? (float)buff->fb[offset]: \ 00016 buff->k); \ 00017 if(buff->tfunc) \ 00018 att = (buff->tfunc)(att, offset); 00019 00020 /* cast to float, otherwise doesn't seem to handle neg. values */ 00021 00022 #define SCALE_ATT(att, val, low, high) ((val) <= att->max_nz && \ 00023 (val) >= att->min_nz && att->range_nz? \ 00024 (((val) - att->min_nz)/att->range_nz) * \ 00025 ((high) - (low)) + (low): 0) 00026 00027 #define GET_MAPATT(buff, offset, att) (get_mapatt(buff, offset, &(att))) 00028 00029 #define BM_GET_BYOFFSET(bm, off) (bm? BM_get(bm, (off%bm->cols), (off/bm->cols)): 0) 00030 00031 00032 00033 #define XYMAXPOS 0x3ff /* 1023 */ 00034 #define ZMAXPOS 0x3ff /* 1023 */ 00035 00036 #define NXMASK 0xffe00000 /* top 11 bits */ 00037 #define NYMASK 0x1ffc00 /* middle 11 bits of packed int */ 00038 #define NZMASK 0x3ff /* lowest 10 bits */ 00039 00040 #define NZUP 0x000003ff 00041 00042 /* Fetch Normal vector from packed int */ 00043 /* 00044 #define FNORM(i,nv) \ 00045 nv[X] = ((int)(((i) & NXMASK) >> 21) - XYMAXPOS)/(float)XYMAXPOS; \ 00046 nv[Y] = ((int)(((i) & NYMASK) >> 10) - XYMAXPOS)/(float)XYMAXPOS; \ 00047 nv[Z] = (int)((i) & NZMASK) * GS_global_exag()/(float)ZMAXPOS 00048 */ 00049 00050 #define FNORM(i,nv) \ 00051 nv[X] = ((int)(((i) & NXMASK) >> 21) - XYMAXPOS)/(float)XYMAXPOS; \ 00052 nv[Y] = ((int)(((i) & NYMASK) >> 10) - XYMAXPOS)/(float)XYMAXPOS; \ 00053 nv[Z] = (int)((i) & NZMASK) /(float)ZMAXPOS 00054 00055 /* Pack Normal vector into int */ 00056 #define PNORM(i,nv) \ 00057 i = ((unsigned int)((nv[X]*XYMAXPOS)+XYMAXPOS) << 21) | \ 00058 ((unsigned int)((nv[Y]*XYMAXPOS)+XYMAXPOS) << 10) | \ 00059 (unsigned int)(nv[Z]*ZMAXPOS) 00060 00061 #endif /* _GSGET_H */