2 |
|
/* |
3 |
|
* bsdf_m.h |
4 |
|
* |
5 |
< |
* Support for BSDF matrices |
5 |
> |
* Support for BSDF matrices. |
6 |
> |
* Assumes "bsdf.h" already included. |
7 |
> |
* Include after "ezxml.h" for SDloadMtx() declaration. |
8 |
|
* |
9 |
|
* Created by Greg Ward on 2/2/11. |
10 |
|
* |
17 |
|
extern "C" { |
18 |
|
#endif |
19 |
|
/* Fixed-position coordinate functions */ |
20 |
< |
typedef int b_vecf(FVECT vec, int ndx, double randX, void *c_data); |
20 |
> |
typedef int b_vecf(FVECT vec, double ndxr, void *c_data); |
21 |
|
typedef int b_ndxf(const FVECT vec, void *c_data); |
22 |
|
typedef double b_ohmf(int ndx, void *c_data); |
23 |
|
|
37 |
|
} SDMat; |
38 |
|
|
39 |
|
/* Matrix BSDF accessors */ |
40 |
< |
#define mBSDF_incvec(v,b,i) (*(b)->ib_vec)(v,i,(b)->ib_priv) |
40 |
> |
#define mBSDF_incvec(v,b,ix) (*(b)->ib_vec)(v,ix,(b)->ib_priv) |
41 |
|
#define mBSDF_incndx(b,v) (*(b)->ib_ndx)(v,(b)->ib_priv) |
42 |
|
#define mBSDF_incohm(b,i) (*(b)->ib_ohm)(i,(b)->ib_priv) |
43 |
< |
#define mBSDF_outvec(v,b,o) (*(b)->ob_vec)(v,o,(b)->ob_priv) |
43 |
> |
#define mBSDF_outvec(v,b,ox) (*(b)->ob_vec)(v,ox,(b)->ob_priv) |
44 |
|
#define mBSDF_outndx(b,v) (*(b)->ob_ndx)(v,(b)->ob_priv) |
45 |
|
#define mBSDF_outohm(b,o) (*(b)->ob_ohm)(o,(b)->ob_priv) |
46 |
|
#define mBSDF_value(b,i,o) (b)->bsdf[(o)*(b)->ninc + (i)] |
47 |
|
|
48 |
|
/* Holder for cumulative distribution (sum of BSDF * projSA) */ |
49 |
< |
typedef struct { |
50 |
< |
SD_CDIST_BASE; /* base fields; must come first */ |
49 |
> |
typedef struct SDMatCDst_s { |
50 |
> |
SD_CDIST_BASE(SDMatCDst_s); /* base fields; must come first */ |
51 |
|
int indx; /* incident angle index */ |
52 |
|
void *ob_priv; /* private data for generator */ |
53 |
|
b_vecf *ob_vec; /* outbound vector generator */ |
55 |
|
unsigned carr[1]; /* cumulative array (extends struct) */ |
56 |
|
} SDMatCDst; |
57 |
|
|
58 |
+ |
#ifdef _EZXML_H |
59 |
|
/* Load a set of BSDF matrices from an open XML file */ |
60 |
|
extern SDError SDloadMtx(SDData *sd, ezxml_t wtl); |
61 |
+ |
#endif |
62 |
|
|
63 |
|
/* Our matrix handling routines */ |
64 |
|
extern SDFunc SDhandleMtx; |
65 |
+ |
|
66 |
+ |
/******** Klems basis declarations for more intimate access ********/ |
67 |
+ |
|
68 |
+ |
#define MAXLATS 46 /* maximum number of latitudes */ |
69 |
+ |
|
70 |
+ |
/* BSDF angle specification */ |
71 |
+ |
typedef struct { |
72 |
+ |
char name[64]; /* basis name */ |
73 |
+ |
int nangles; /* total number of directions */ |
74 |
+ |
struct { |
75 |
+ |
float tmin; /* starting theta */ |
76 |
+ |
int nphis; /* number of phis (0 term) */ |
77 |
+ |
} lat[MAXLATS+1]; /* latitudes */ |
78 |
+ |
} ANGLE_BASIS; |
79 |
+ |
|
80 |
+ |
#define MAXABASES 7 /* limit on defined bases */ |
81 |
+ |
|
82 |
+ |
extern ANGLE_BASIS abase_list[MAXABASES]; |
83 |
+ |
|
84 |
+ |
extern int nabases; /* current number of defined bases */ |
85 |
+ |
|
86 |
+ |
/* Get vector for this angle basis index (front exiting) */ |
87 |
+ |
extern b_vecf fo_getvec; |
88 |
+ |
|
89 |
+ |
/* Get index corresponding to the given vector (front exiting) */ |
90 |
+ |
extern b_ndxf fo_getndx; |
91 |
+ |
|
92 |
+ |
/* Get projected solid angle for this angle basis index (universal) */ |
93 |
+ |
extern b_ohmf io_getohm; |
94 |
+ |
|
95 |
+ |
/* Get vector for this angle basis index (back incident) */ |
96 |
+ |
extern b_vecf bi_getvec; |
97 |
+ |
|
98 |
+ |
/* Get index corresponding to the vector (back incident) */ |
99 |
+ |
extern b_ndxf bi_getndx; |
100 |
+ |
|
101 |
+ |
/* Get vector for this angle basis index (back exiting) */ |
102 |
+ |
extern b_vecf bo_getvec; |
103 |
+ |
|
104 |
+ |
/* Get index corresponding to the vector (back exiting) */ |
105 |
+ |
extern b_ndxf bo_getndx; |
106 |
+ |
|
107 |
+ |
/* Get vector for this angle basis index (front incident) */ |
108 |
+ |
extern b_vecf fi_getvec; |
109 |
+ |
|
110 |
+ |
/* Get index corresponding to the vector (front incident) */ |
111 |
+ |
extern b_ndxf fi_getndx; |
112 |
|
|
113 |
|
#ifdef __cplusplus |
114 |
|
} |