ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/bsdf_m.h
Revision: 3.1
Committed: Fri Feb 18 00:40:25 2011 UTC (13 years, 2 months ago) by greg
Content type: text/plain
Branch: MAIN
Log Message:
Major code reorg, moving mgflib to common and introducing BSDF material

File Contents

# User Rev Content
1 greg 3.1 /*
2     * bsdf_m.h
3     *
4     * Support for BSDF matrices
5     *
6     * Created by Greg Ward on 2/2/11.
7     *
8     */
9    
10     #ifndef _BSDF_M_H_
11     #define _BSDF_M_H_
12    
13     #ifdef __cplusplus
14     extern "C" {
15     #endif
16     /* Fixed-position coordinate functions */
17     typedef int b_vecf(FVECT vec, int ndx, double randX, void *c_data);
18     typedef int b_ndxf(const FVECT vec, void *c_data);
19     typedef double b_ohmf(int ndx, void *c_data);
20    
21     /* Rectangular matrix format BSDF */
22     typedef struct {
23     int ninc; /* number of incoming directions */
24     int nout; /* number of outgoing directions */
25     void *ib_priv; /* input basis private data */
26     b_vecf *ib_vec; /* get input vector from index */
27     b_ndxf *ib_ndx; /* get input index from vector */
28     b_ohmf *ib_ohm; /* get input proj. SA for index */
29     void *ob_priv; /* output basis private data */
30     b_vecf *ob_vec; /* get output vector from index */
31     b_ndxf *ob_ndx; /* get output index from vector */
32     b_ohmf *ob_ohm; /* get output proj. SA for index */
33     float bsdf[1]; /* scattering data (extends struct) */
34     } SDMat;
35    
36     /* Matrix BSDF accessors */
37     #define mBSDF_incvec(v,b,i) (*(b)->ib_vec)(v,i,(b)->ib_priv)
38     #define mBSDF_incndx(b,v) (*(b)->ib_ndx)(v,(b)->ib_priv)
39     #define mBSDF_incohm(b,i) (*(b)->ib_ohm)(i,(b)->ib_priv)
40     #define mBSDF_outvec(v,b,o) (*(b)->ob_vec)(v,o,(b)->ob_priv)
41     #define mBSDF_outndx(b,v) (*(b)->ob_ndx)(v,(b)->ob_priv)
42     #define mBSDF_outohm(b,o) (*(b)->ob_ohm)(o,(b)->ob_priv)
43     #define mBSDF_value(b,i,o) (b)->bsdf[(o)*(b)->ninc + (i)]
44    
45     /* Holder for cumulative distribution (sum of BSDF * projSA) */
46     typedef struct {
47     SD_CDIST_BASE; /* base fields; must come first */
48     int indx; /* incident angle index */
49     void *ob_priv; /* private data for generator */
50     b_vecf *ob_vec; /* outbound vector generator */
51     int calen; /* cumulative array length */
52     unsigned carr[1]; /* cumulative array (extends struct) */
53     } SDMatCDst;
54    
55     /* Load a set of BSDF matrices from an open XML file */
56     extern SDError SDloadMtx(SDData *sd, ezxml_t fl);
57    
58     /* Our matrix handling routines */
59     extern SDFunc SDhandleMtx;
60    
61     #ifdef __cplusplus
62     }
63     #endif
64     #endif /* ! _BSDF_M_H_ */