| 1 |
/* RCSid $Id: bsdf_t.h,v 3.12 2015/04/05 01:32:01 greg Exp $ */
|
| 2 |
/*
|
| 3 |
* bsdf_t.h
|
| 4 |
*
|
| 5 |
* Support for variable-resolution BSDF trees.
|
| 6 |
* Assumes "bsdf.h" already included.
|
| 7 |
* Include after "ezxml.h" for SDloadTre() declaration.
|
| 8 |
*
|
| 9 |
* Created by Greg Ward on 2/2/11.
|
| 10 |
*
|
| 11 |
*/
|
| 12 |
|
| 13 |
#ifndef _BSDF_T_H_
|
| 14 |
#define _BSDF_T_H_
|
| 15 |
|
| 16 |
#ifdef __cplusplus
|
| 17 |
extern "C" {
|
| 18 |
#endif
|
| 19 |
|
| 20 |
#define SD_MAXDIM 4 /* maximum expected # dimensions */
|
| 21 |
|
| 22 |
/* Basic node structure for variable-resolution BSDF data */
|
| 23 |
typedef struct SDNode_s {
|
| 24 |
short ndim; /* number of dimensions */
|
| 25 |
short log2GR; /* log(2) of grid resolution (< 0 for tree) */
|
| 26 |
union {
|
| 27 |
struct SDNode_s *t[1]; /* subtree pointers */
|
| 28 |
float v[1]; /* scattering value(s) */
|
| 29 |
} u; /* subtrees or values (extends struct) */
|
| 30 |
} SDNode;
|
| 31 |
|
| 32 |
#define SD_FREFL 1 /* component reflects off front side */
|
| 33 |
#define SD_BREFL 2 /* component reflects off back side */
|
| 34 |
#define SD_FXMIT 3 /* component transmits through front side */
|
| 35 |
#define SD_BXMIT 4 /* component transmits through back side */
|
| 36 |
|
| 37 |
/* Variable-resolution BSDF holder */
|
| 38 |
typedef struct {
|
| 39 |
int sidef; /* which component */
|
| 40 |
SDNode *stc[3]; /* BSDF (Y,u,v) trees */
|
| 41 |
} SDTre;
|
| 42 |
|
| 43 |
/* Holder for cumulative distribution (sum of BSDF * projSA) */
|
| 44 |
typedef struct SDTreCDst_s {
|
| 45 |
/* base fields; must come first */
|
| 46 |
SD_CDIST_BASE(SDTreCDst_s);
|
| 47 |
double clim[2][2]; /* input coordinate limits */
|
| 48 |
double max_psa; /* maximum projected solid angle */
|
| 49 |
short sidef; /* which mode is in play */
|
| 50 |
short isodist; /* isotropic distribution? */
|
| 51 |
int calen; /* cumulative array length */
|
| 52 |
struct {
|
| 53 |
unsigned hndx; /* hilbert index */
|
| 54 |
unsigned cuml; /* cumulative value */
|
| 55 |
} carr[1]; /* cumulative array (extends struct) */
|
| 56 |
} SDTreCDst;
|
| 57 |
|
| 58 |
#ifdef _EZXML_H
|
| 59 |
/* Load a variable-resolution BSDF tree from an open XML file */
|
| 60 |
extern SDError SDloadTre(SDData *sd, ezxml_t wtl);
|
| 61 |
#endif
|
| 62 |
|
| 63 |
/* Our matrix handling routines */
|
| 64 |
extern const SDFunc SDhandleTre;
|
| 65 |
|
| 66 |
#ifdef __cplusplus
|
| 67 |
}
|
| 68 |
#endif
|
| 69 |
#endif /* ! _BSDF_T_H_ */
|