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