GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-36359e2344
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  int nthres; /* number of thresholds */
23  float tvalue[MAXTHRESH]; /* array of threshold values */
24  int litmodel; /* 1 = flat, 2 = gradient(6), 3 = gradient(26) */
25 } cmndln_info;
26 
27 typedef struct {
28  int token; /* type of file */
29  void *g3mapin, *g3mapout; /* RASTER3D_Map */
30  FILE *datainfp, *dataoutfp;
31  FILE *dspfinfp, *dspfoutfp;
32  int xdim, ydim, zdim;
33  float north, south, east, west;
34  float top, bottom;
35  float ns_res, ew_res, tb_res;
36  int zone;
37  int proj;
38  int type; /* 1 = short int, 2 = integer, 3 = float */
39  float min, max; /* max and min values present in the data */
40  long Dataoff; /* offset of beginning of data in file */
41  long Lookoff; /* offset of beginning of lookup table in file */
42  cmndln_info linefax; /* more global info */
43  int headsize; /* size of datainf file header, necessary for random
44  access to grid3 data */
45 } file_info;
46 
47 typedef struct {
48  float v1[3]; /* polygon vertices */
49  float v2[3];
50  float v3[3];
51  float n1[3], n2[3], n3[3]; /* normals for vertices */
52 } poly_info;
53 
54 typedef struct {
55  int npoly; /* number of polygons in cube at given threshold */
56  int t_ndx; /* index of given threshold */
57  poly_info poly[MAXPOLY]; /* vertices and normals */
58 } cube_info;
59 
60 typedef struct {
61  int n_thresh;
63 } Cube_data;
64 
65 typedef struct {
66  int nverts;
67  int verts[8];
68  int nedges;
69  int edges[12];
70  int npolys;
71  int polys[30];
72 } CELL_ENTRY; /* for writing out in condensed format */
73 
74 /* cube_io.c */
75 int write_cube(Cube_data *, int, file_info *);
76 int write_cube_buffer(unsigned char *, int, int, file_info *);
77 int read_cube(Cube_data *, file_info *);
78 int my_fread(char *, int, int, FILE *);
79 int my_fread(char *, int, int, FILE *);
80 int reset_reads(file_info *);
81 int new_dspf(file_info *);
82 
83 /* dspf_header.c */
86 int dfread_header_old(file_info *, FILE *);
87 
88 /* print_info.c */
90 
91 /* struct_copy.c */
92 int struct_copy(char *, char *, int);
93 
94 extern CELL_ENTRY cell_table[];
#define min(x, y)
Definition: draw2.c:29
Definition: viz.h:65
int nverts
Definition: viz.h:66
int npolys
Definition: viz.h:70
int nedges
Definition: viz.h:68
Definition: viz.h:60
int n_thresh
Definition: viz.h:61
int nthres
Definition: viz.h:22
int litmodel
Definition: viz.h:24
Definition: viz.h:54
int t_ndx
Definition: viz.h:56
int npoly
Definition: viz.h:55
Definition: viz.h:27
float east
Definition: viz.h:33
long Lookoff
Definition: viz.h:41
int xdim
Definition: viz.h:32
void * g3mapin
Definition: viz.h:29
int proj
Definition: viz.h:37
float ew_res
Definition: viz.h:35
FILE * datainfp
Definition: viz.h:30
cmndln_info linefax
Definition: viz.h:42
long Dataoff
Definition: viz.h:40
FILE * dspfinfp
Definition: viz.h:31
int type
Definition: viz.h:38
float bottom
Definition: viz.h:34
float max
Definition: viz.h:39
int zone
Definition: viz.h:36
int token
Definition: viz.h:28
int headsize
Definition: viz.h:43
Definition: viz.h:47
int write_cube(Cube_data *, int, file_info *)
Definition: cube_io.c:26
int dfwrite_header(file_info *)
Definition: dspf_header.c:7
CELL_ENTRY cell_table[]
Definition: cell_table.c:3
int struct_copy(char *, char *, int)
Definition: struct_copy.c:1
int read_cube(Cube_data *, file_info *)
Definition: cube_io.c:137
int write_cube_buffer(unsigned char *, int, int, file_info *)
Definition: cube_io.c:96
int new_dspf(file_info *)
Definition: cube_io.c:285
int dfread_header_old(file_info *, FILE *)
Definition: dspf_header.c:139
#define MAXPOLY
Definition: viz.h:19
int print_head_info(file_info *)
Definition: print_info.c:3
#define MAXTHRESH
Definition: viz.h:18
int my_fread(char *, int, int, FILE *)
Definition: cube_io.c:257
int reset_reads(file_info *)
Definition: cube_io.c:275
int dfread_header(file_info *)
Definition: dspf_header.c:85