GRASS GIS 7 Programmer's Manual  7.9.dev(2021)-e5379bbd7
viz.h
Go to the documentation of this file.
1 #include <stdio.h>
2 #include <math.h>
3 #include <sys/types.h>
4 
5 #define GRID_ID "grid003.02"
6 #define DSPF_ID "dspf003.02"
7 
8 #define LINTERP(A,B,C) ((C-A)/(B-A))*255
9 #define VOID_TYPE char
10 
11 #define FLINTERP(A,B,C,D,E) (((C-A)*(E-D))/(B-A)) + D
12 /*#define LENGTH(A,B,C) sqrt(A*A + B*B + C*C) */
13 
14 /* used in the lambert shading model */
15 #define NV(A,B,C) ((A*A) + (B*B) + (C*C))
16 #define MAXLITS 3
17 
18 #define MAXTHRESH 127
19 #define MAXPOLY 10
20 
21 typedef struct
22 {
23  int nthres; /* number of thresholds */
24  float tvalue[MAXTHRESH]; /* array of threshold values */
25  int litmodel; /* 1 = flat, 2 = gradient(6), 3 = gradient(26) */
26 } cmndln_info;
27 
28 typedef struct
29 {
30  int token; /*type of file */
31  void *g3mapin, *g3mapout; /* RASTER3D_Map */
32  FILE *datainfp, *dataoutfp;
33  FILE *dspfinfp, *dspfoutfp;
34  int xdim, ydim, zdim;
35  float north, south, east, west;
36  float top, bottom;
37  float ns_res, ew_res, tb_res;
38  int zone;
39  int proj;
40  int type; /*1 = short int, 2 = integer, 3 = float */
41  float min, max; /* max and min values present in the data */
42  long Dataoff; /* offset of beginning of data in file */
43  long Lookoff; /* offset of beginning of lookup table in file */
44  cmndln_info linefax; /* more global info */
45  int headsize; /* size of datainf file header, necessary for random
46  access to grid3 data */
47 } file_info;
48 
49 
50 typedef struct
51 {
52  float v1[3]; /*polygon vertices */
53  float v2[3];
54  float v3[3];
55  float n1[3], n2[3], n3[3]; /*normals for vertices */
56 } poly_info;
57 
58 typedef struct
59 {
60  int npoly; /* number of polygons in cube at given threshold */
61  int t_ndx; /* index of given threshold */
62  poly_info poly[MAXPOLY]; /*vertices and normals */
63 } cube_info;
64 
65 typedef struct
66 {
67  int n_thresh;
69 } Cube_data;
70 
71 typedef struct
72 {
73  int nverts;
74  int verts[8];
75  int nedges;
76  int edges[12];
77  int npolys;
78  int polys[30];
79 } CELL_ENTRY; /* for writing out in condensed format */
80 
81 /* cube_io.c */
82 int write_cube(Cube_data *, int, file_info *);
83 int write_cube_buffer(unsigned char *, int, int, file_info *);
84 int read_cube(Cube_data *, file_info *);
85 int my_fread(char *, int, int, FILE *);
86 int my_fread(char *, int, int, FILE *);
87 int reset_reads(file_info *);
88 int new_dspf(file_info *);
89 
90 /* dspf_header.c */
93 int dfread_header_old(file_info *, FILE *);
94 
95 /* print_info.c */
97 
98 /* struct_copy.c */
99 int struct_copy(char *, char *, int);
100 
101 extern CELL_ENTRY cell_table[];
FILE * dataoutfp
Definition: viz.h:32
int token
Definition: viz.h:30
int dfread_header_old(file_info *, FILE *)
Definition: dspf_header.c:146
int write_cube(Cube_data *, int, file_info *)
Definition: cube_io.c:25
int read_cube(Cube_data *, file_info *)
Definition: cube_io.c:134
float tb_res
Definition: viz.h:37
int litmodel
Definition: viz.h:25
int reset_reads(file_info *)
Definition: cube_io.c:285
float min
Definition: viz.h:41
Definition: viz.h:28
int struct_copy(char *, char *, int)
Definition: struct_copy.c:2
int npolys
Definition: viz.h:77
#define max(x, y)
Definition: draw2.c:32
int nverts
Definition: viz.h:73
int t_ndx
Definition: viz.h:61
Definition: viz.h:58
Definition: viz.h:50
int print_head_info(file_info *)
Definition: print_info.c:3
int zone
Definition: viz.h:38
int type
Definition: viz.h:40
Definition: viz.h:71
int dfwrite_header(file_info *)
Definition: dspf_header.c:8
int write_cube_buffer(unsigned char *, int, int, file_info *)
Definition: cube_io.c:93
int nedges
Definition: viz.h:75
#define MAXTHRESH
Definition: viz.h:18
int new_dspf(file_info *)
Definition: cube_io.c:295
#define MAXPOLY
Definition: viz.h:19
Definition: viz.h:65
cmndln_info linefax
Definition: viz.h:44
void * g3mapout
Definition: viz.h:31
long Dataoff
Definition: viz.h:42
int n_thresh
Definition: viz.h:67
int zdim
Definition: viz.h:34
long Lookoff
Definition: viz.h:43
int headsize
Definition: viz.h:45
CELL_ENTRY cell_table[]
Definition: cell_table.c:3
int dfread_header(file_info *)
Definition: dspf_header.c:91
int my_fread(char *, int, int, FILE *)
Definition: cube_io.c:267
int npoly
Definition: viz.h:60
float west
Definition: viz.h:35
FILE * dspfoutfp
Definition: viz.h:33
int proj
Definition: viz.h:39
float top
Definition: viz.h:36
int nthres
Definition: viz.h:23