File: gsget.h

package info (click to toggle)
grass 6.4.4-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 104,028 kB
  • ctags: 40,409
  • sloc: ansic: 419,980; python: 63,559; tcl: 46,692; cpp: 29,791; sh: 18,564; makefile: 7,000; xml: 3,505; yacc: 561; perl: 559; lex: 480; sed: 70; objc: 7
file content (61 lines) | stat: -rw-r--r-- 2,023 bytes parent folder | download | duplicates (3)
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
54
55
56
57
58
59
60
61
#ifndef _GSGET_H
#define _GSGET_H

#include <grass/gsurf.h>

#define GET_MAPATT1(buff, offset, att) att=(buff->ib? (float)buff->ib[offset]: \
				      buff->sb? (float)buff->sb[offset]: \
				      buff->cb? (float)buff->cb[offset]: \
				      buff->fb? (float)buff->fb[offset]: \
				      0.0)

#define GET_MAPATT2(buff, offset, att) att=(buff->ib? (float)buff->ib[offset]: \
				      buff->sb? (float)buff->sb[offset]: \
				      buff->cb? (float)buff->cb[offset]: \
				      buff->fb? (float)buff->fb[offset]: \
				      buff->k); \
				      if(buff->tfunc) \
					  att = (buff->tfunc)(att, offset);

/* cast to float, otherwise doesn't seem to handle neg. values */

#define SCALE_ATT(att, val, low, high)   ((val) <= att->max_nz && \
				(val) >= att->min_nz && att->range_nz? \
				(((val) - att->min_nz)/att->range_nz) * \
				((high) - (low)) + (low): 0)

#define GET_MAPATT(buff, offset, att) (get_mapatt(buff, offset, &(att)))

#define BM_GET_BYOFFSET(bm, off) (bm? BM_get(bm, (off%bm->cols), (off/bm->cols)): 0)



#define XYMAXPOS 0x3ff		/* 1023 */
#define ZMAXPOS 0x3ff		/* 1023 */

#define NXMASK 0xffe00000	/* top 11 bits */
#define NYMASK 0x1ffc00		/* middle 11 bits of packed int */
#define NZMASK 0x3ff		/* lowest 10 bits */

#define NZUP 0x000003ff

/* Fetch Normal vector from packed int */
/*
   #define FNORM(i,nv)  \
   nv[X] = ((int)(((i) & NXMASK) >> 21) - XYMAXPOS)/(float)XYMAXPOS; \
   nv[Y] = ((int)(((i) & NYMASK) >> 10) - XYMAXPOS)/(float)XYMAXPOS; \
   nv[Z] = (int)((i) & NZMASK) * GS_global_exag()/(float)ZMAXPOS
 */

#define FNORM(i,nv)  \
  nv[X] = ((int)(((i) & NXMASK) >> 21) - XYMAXPOS)/(float)XYMAXPOS; \
  nv[Y] = ((int)(((i) & NYMASK) >> 10) - XYMAXPOS)/(float)XYMAXPOS; \
  nv[Z] = (int)((i) & NZMASK) /(float)ZMAXPOS

/* Pack Normal vector into int */
#define PNORM(i,nv)  \
  i = ((unsigned int)((nv[X]*XYMAXPOS)+XYMAXPOS) << 21) |           \
  ((unsigned int)((nv[Y]*XYMAXPOS)+XYMAXPOS) << 10) |               \
  (unsigned int)(nv[Z]*ZMAXPOS)

#endif /* _GSGET_H */