10 |
|
#define DEBUG 1 |
11 |
|
|
12 |
|
#ifndef GRIDRES |
13 |
< |
#define GRIDRES 200 /* grid resolution per side */ |
13 |
> |
#define GRIDRES (1<<8) /* grid resolution per side */ |
14 |
|
#endif |
15 |
|
/* convert to/from coded radians */ |
16 |
|
#define ANG2R(r) (int)((r)*((1<<16)/M_PI)) |
18 |
|
|
19 |
|
typedef struct { |
20 |
|
float vsum; /* DSF sum */ |
21 |
< |
unsigned short nval; /* number of values in sum */ |
22 |
< |
unsigned short crad; /* radius (coded angle) */ |
21 |
> |
unsigned int nval; /* number of values in sum */ |
22 |
|
} GRIDVAL; /* grid value */ |
23 |
|
|
24 |
|
typedef struct { |
56 |
|
#define INP_QUAD3 4 /* 180-270 degree quadrant */ |
57 |
|
#define INP_QUAD4 8 /* 270-360 degree quadrant */ |
58 |
|
|
59 |
+ |
/* name and manufacturer if known */ |
60 |
+ |
extern char bsdf_name[]; |
61 |
+ |
extern char bsdf_manuf[]; |
62 |
+ |
/* active grid resolution */ |
63 |
+ |
extern int grid_res; |
64 |
+ |
/* coverage/symmetry using INP_QUAD? flags */ |
65 |
|
extern int inp_coverage; |
66 |
|
|
67 |
|
/* all incident angles in-plane so far? */ |
71 |
|
extern int input_orient; |
72 |
|
extern int output_orient; |
73 |
|
|
74 |
+ |
/* log BSDF histogram */ |
75 |
+ |
#define HISTLEN 256 |
76 |
+ |
#define BSDF2BIG (1./M_PI) |
77 |
+ |
#define BSDF2SML 1e-8 |
78 |
+ |
#define HISTLNR 17.2759509 /* log(BSDF2BIG/BSDF2SML) */ |
79 |
+ |
extern unsigned long bsdf_hist[HISTLEN]; |
80 |
+ |
#define histndx(v) (int)(log((v)*(1./BSDF2SML))*(HISTLEN/HISTLNR)) |
81 |
+ |
#define histval(i) (exp(((i)+.5)*(HISTLNR/HISTLEN))*BSDF2SML) |
82 |
+ |
|
83 |
+ |
/* BSDF value for boundary regions */ |
84 |
+ |
extern double bsdf_min; |
85 |
+ |
|
86 |
|
/* processed incident DSF measurements */ |
87 |
|
extern RBFNODE *dsf_list; |
88 |
|
|
89 |
|
/* RBF-linking matrices (edges) */ |
90 |
|
extern MIGRATION *mig_list; |
91 |
|
|
92 |
< |
/* migration edges drawn in raster fashion */ |
93 |
< |
extern MIGRATION *mig_grid[GRIDRES][GRIDRES]; |
94 |
< |
|
78 |
< |
#define mtx_nrows(m) ((m)->rbfv[0]->nrbf) |
79 |
< |
#define mtx_ncols(m) ((m)->rbfv[1]->nrbf) |
80 |
< |
#define mtx_ndx(m,i,j) ((i)*mtx_ncols(m) + (j)) |
92 |
> |
#define mtx_nrows(m) (m)->rbfv[0]->nrbf |
93 |
> |
#define mtx_ncols(m) (m)->rbfv[1]->nrbf |
94 |
> |
#define mtx_coef(m,i,j) (m)->mtx[(i)*mtx_ncols(m) + (j)] |
95 |
|
#define is_src(rbf,m) ((rbf) == (m)->rbfv[0]) |
96 |
|
#define is_dest(rbf,m) ((rbf) == (m)->rbfv[1]) |
97 |
|
#define nextedge(rbf,m) (m)->enxt[is_dest(rbf,m)] |
99 |
|
|
100 |
|
#define round(v) (int)((v) + .5 - ((v) < -.5)) |
101 |
|
|
102 |
< |
#define BSDFREP_FMT "binary_RBF_BSDF_mesh" |
102 |
> |
#define BSDFREP_FMT "BSDF_RBFmesh" |
103 |
|
|
104 |
|
/* global argv[0] */ |
105 |
|
extern char *progname; |
106 |
|
|
107 |
|
/* get theta value in degrees [0,180) range */ |
108 |
< |
#define get_theta180(v) (180./M_PI)*acos((v)[2]) |
108 |
> |
#define get_theta180(v) ((180./M_PI)*Acos((v)[2])) |
109 |
|
/* get phi value in degrees, [0,360) range */ |
110 |
< |
#define get_phi360(v) ((180./M_PI)*atan2((v)[1],(v)[0]) + 180.) |
110 |
> |
#define get_phi360(v) ((180./M_PI)*atan2((v)[1],(v)[0]) + 360.*((v)[1]<0)) |
111 |
|
|
112 |
|
/* our loaded grid for this incident angle */ |
113 |
|
extern double theta_in_deg, phi_in_deg; |
128 |
|
/* Reverse symmetry for an RBF distribution */ |
129 |
|
extern void rev_rbf_symmetry(RBFNODE *rbf, int sym); |
130 |
|
|
131 |
+ |
/* Rotate RBF to correspond to given incident vector */ |
132 |
+ |
extern void rotate_rbf(RBFNODE *rbf, const FVECT invec); |
133 |
+ |
|
134 |
|
/* Compute volume associated with Gaussian lobe */ |
135 |
|
extern double rbf_volume(const RBFVAL *rbfp); |
136 |
|
|
160 |
|
/* Find vertices completing triangles on either side of the given edge */ |
161 |
|
extern int get_triangles(RBFNODE *rbfv[2], const MIGRATION *mig); |
162 |
|
|
163 |
+ |
/* Clear our BSDF representation and free memory */ |
164 |
+ |
extern void clear_bsdf_rep(void); |
165 |
+ |
|
166 |
|
/* Write our BSDF mesh interpolant out to the given binary stream */ |
167 |
|
extern void save_bsdf_rep(FILE *ofp); |
168 |
|
|
182 |
|
/* Build our triangle mesh from recorded RBFs */ |
183 |
|
extern void build_mesh(void); |
184 |
|
|
165 |
– |
/* Draw edge list into mig_grid array */ |
166 |
– |
extern void draw_edges(void); |
167 |
– |
|
185 |
|
/* Find edge(s) for interpolating the given vector, applying symmetry */ |
186 |
|
extern int get_interp(MIGRATION *miga[3], FVECT invec); |
187 |
|
|
188 |
+ |
/* Advect and allocate new RBF along edge (internal call) */ |
189 |
+ |
extern RBFNODE * e_advect_rbf(const MIGRATION *mig, |
190 |
+ |
const FVECT invec, int lobe_lim); |
191 |
+ |
|
192 |
|
/* Partially advect between recorded incident angles and allocate new RBF */ |
193 |
< |
extern RBFNODE * advect_rbf(const FVECT invec); |
193 |
> |
extern RBFNODE * advect_rbf(const FVECT invec, int lobe_lim); |