GRASS Programmer's Manual
6.4.2(2012)
|
00001 #include <stdio.h> 00002 #include <math.h> 00003 #include <sys/types.h> 00004 00005 #define GRID_ID "grid003.02" 00006 #define DSPF_ID "dspf003.02" 00007 00008 #define LINTERP(A,B,C) ((C-A)/(B-A))*255 00009 #define VOID_TYPE char 00010 00011 #define FLINTERP(A,B,C,D,E) (((C-A)*(E-D))/(B-A)) + D 00012 /*#define LENGTH(A,B,C) sqrt(A*A + B*B + C*C) */ 00013 00014 /* used in the lambert shading model */ 00015 #define NV(A,B,C) ((A*A) + (B*B) + (C*C)) 00016 #define MAXLITS 3 00017 00018 #define MAXTHRESH 127 00019 #define MAXPOLY 10 00020 00021 typedef struct 00022 { 00023 int nthres; /* number of thresholds */ 00024 float tvalue[MAXTHRESH]; /* array of threshold values */ 00025 int litmodel; /* 1 = flat, 2 = gradient(6), 3 = gradient(26) */ 00026 } cmndln_info; 00027 00028 typedef struct 00029 { 00030 int token; /*type of file */ 00031 void *g3mapin, *g3mapout; /* G3D_Map */ 00032 FILE *datainfp, *dataoutfp; 00033 FILE *dspfinfp, *dspfoutfp; 00034 int xdim, ydim, zdim; 00035 float north, south, east, west; 00036 float top, bottom; 00037 float ns_res, ew_res, tb_res; 00038 int zone; 00039 int proj; 00040 int type; /*1 = short int, 2 = integer, 3 = float */ 00041 float min, max; /* max and min values present in the data */ 00042 long Dataoff; /* offset of beginning of data in file */ 00043 long Lookoff; /* offset of beginning of lookup table in file */ 00044 cmndln_info linefax; /* more global info */ 00045 int headsize; /* size of datainf file header, necessary for random 00046 access to grid3 data */ 00047 } file_info; 00048 00049 00050 typedef struct 00051 { 00052 float v1[3]; /*polygon vertices */ 00053 float v2[3]; 00054 float v3[3]; 00055 float n1[3], n2[3], n3[3]; /*normals for vertices */ 00056 } poly_info; 00057 00058 typedef struct 00059 { 00060 int npoly; /* number of polygons in cube at given threshold */ 00061 int t_ndx; /* index of given threshold */ 00062 poly_info poly[MAXPOLY]; /*vertices and normals */ 00063 } cube_info; 00064 00065 typedef struct 00066 { 00067 int n_thresh; 00068 cube_info data[MAXTHRESH]; 00069 } Cube_data; 00070 00071 typedef struct 00072 { 00073 int nverts; 00074 int verts[8]; 00075 int nedges; 00076 int edges[12]; 00077 int npolys; 00078 int polys[30]; 00079 } CELL_ENTRY; /* for writing out in condensed format */ 00080 00081 /* cube_io.c */ 00082 int write_cube(Cube_data *, int, file_info *); 00083 int write_cube_buffer(unsigned char *, int, int, file_info *); 00084 int read_cube(Cube_data *, file_info *); 00085 int my_fread(char *, int, int, FILE *); 00086 int my_fread(char *, int, int, FILE *); 00087 int reset_reads(file_info *); 00088 int new_dspf(file_info *); 00089 00090 /* dspf_header.c */ 00091 int dfwrite_header(file_info *); 00092 int dfread_header(file_info *); 00093 int dfread_header_old(file_info *, FILE *); 00094 00095 /* print_info.c */ 00096 int print_head_info(file_info *); 00097 00098 /* struct_copy.c */ 00099 int struct_copy(char *, char *, int); 00100 00101 #ifdef MAIN 00102 #define GLOBAL 00103 #else 00104 #define GLOBAL extern 00105 #endif 00106 00107 #include "cell_table.h"