1 |
/* RCSid $Id: bsdf_m.h,v 3.5 2011/08/21 22:38:12 greg Exp $ */ |
2 |
/* |
3 |
* bsdf_m.h |
4 |
* |
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 |
* |
11 |
*/ |
12 |
|
13 |
#ifndef _BSDF_M_H_ |
14 |
#define _BSDF_M_H_ |
15 |
|
16 |
#ifdef __cplusplus |
17 |
extern "C" { |
18 |
#endif |
19 |
/* Fixed-position coordinate functions */ |
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 |
|
24 |
/* Rectangular matrix format BSDF */ |
25 |
typedef struct { |
26 |
int ninc; /* number of incoming directions */ |
27 |
int nout; /* number of outgoing directions */ |
28 |
void *ib_priv; /* input basis private data */ |
29 |
b_vecf *ib_vec; /* get input vector from index */ |
30 |
b_ndxf *ib_ndx; /* get input index from vector */ |
31 |
b_ohmf *ib_ohm; /* get input proj. SA for index */ |
32 |
void *ob_priv; /* output basis private data */ |
33 |
b_vecf *ob_vec; /* get output vector from index */ |
34 |
b_ndxf *ob_ndx; /* get output index from vector */ |
35 |
b_ohmf *ob_ohm; /* get output proj. SA for index */ |
36 |
float bsdf[1]; /* scattering data (extends struct) */ |
37 |
} SDMat; |
38 |
|
39 |
/* Matrix BSDF accessors */ |
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,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 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 */ |
54 |
int calen; /* cumulative array length */ |
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 |
} |
115 |
#endif |
116 |
#endif /* ! _BSDF_M_H_ */ |