Back to index

radiance  4R0+20100331
Classes | Defines | Typedefs | Enumerations | Functions
bsdf.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  BSDF_data

Defines

#define getBSDF_incvec(v, b, i)   (*(b)->ib_vec)(v,i,(b)->ib_priv)
#define getBSDF_incndx(b, v)   (*(b)->ib_ndx)(v,(b)->ib_priv)
#define getBSDF_incohm(b, i)   (*(b)->ib_ohm)(i,(b)->ib_priv)
#define getBSDF_outvec(v, b, o)   (*(b)->ob_vec)(v,o,(b)->ob_priv)
#define getBSDF_outndx(b, v)   (*(b)->ob_ndx)(v,(b)->ob_priv)
#define getBSDF_outohm(b, o)   (*(b)->ob_ohm)(o,(b)->ob_priv)
#define BSDF_value(b, i, o)   (b)->bsdf[(o)*(b)->ninc + (i)]

Typedefs

typedef int b_vecf (FVECT, int, void *)
typedef int b_ndxf (FVECT, void *)
typedef double b_radf (int, void *)

Enumerations

enum  UpDir {
  UDzneg = -3, UDyneg = -2, UDxneg = -1, UDunknown = 0,
  UDxpos = 1, UDypos = 2, UDzpos = 3
}

Functions

struct BSDF_dataload_BSDF (char *fname)
void free_BSDF (struct BSDF_data *b)
int r_BSDF_incvec (FVECT v, struct BSDF_data *b, int i, double rv, MAT4 xm)
int r_BSDF_outvec (FVECT v, struct BSDF_data *b, int o, double rv, MAT4 xm)
int getBSDF_xfm (MAT4 xm, FVECT nrm, UpDir ud)

Class Documentation

struct BSDF_data

Definition at line 22 of file bsdf.h.

Class Members
float * bsdf
b_ndxf * ib_ndx
b_radf * ib_ohm
void * ib_priv
b_vecf * ib_vec
int ninc
int nout
b_ndxf * ob_ndx
b_radf * ob_ohm
void * ob_priv
b_vecf * ob_vec

Define Documentation

#define BSDF_value (   b,
  i,
 
)    (b)->bsdf[(o)*(b)->ninc + (i)]

Definition at line 42 of file bsdf.h.

#define getBSDF_incndx (   b,
  v 
)    (*(b)->ib_ndx)(v,(b)->ib_priv)

Definition at line 37 of file bsdf.h.

#define getBSDF_incohm (   b,
  i 
)    (*(b)->ib_ohm)(i,(b)->ib_priv)

Definition at line 38 of file bsdf.h.

#define getBSDF_incvec (   v,
  b,
  i 
)    (*(b)->ib_vec)(v,i,(b)->ib_priv)

Definition at line 36 of file bsdf.h.

#define getBSDF_outndx (   b,
  v 
)    (*(b)->ob_ndx)(v,(b)->ob_priv)

Definition at line 40 of file bsdf.h.

#define getBSDF_outohm (   b,
 
)    (*(b)->ob_ohm)(o,(b)->ob_priv)

Definition at line 41 of file bsdf.h.

#define getBSDF_outvec (   v,
  b,
 
)    (*(b)->ob_vec)(v,o,(b)->ob_priv)

Definition at line 39 of file bsdf.h.


Typedef Documentation

typedef int b_ndxf(FVECT, void *)

Definition at line 18 of file bsdf.h.

typedef double b_radf(int, void *)

Definition at line 19 of file bsdf.h.

typedef int b_vecf(FVECT, int, void *)

Definition at line 17 of file bsdf.h.


Enumeration Type Documentation

enum UpDir
Enumerator:
UDzneg 
UDyneg 
UDxneg 
UDunknown 
UDxpos 
UDypos 
UDzpos 

Definition at line 6 of file bsdf.h.

             {
       UDzneg=-3,
       UDyneg=-2,
       UDxneg=-1,
       UDunknown=0,
       UDxpos=1,
       UDypos=2,
       UDzpos=3
} UpDir;

Function Documentation

void free_BSDF ( struct BSDF_data b)

Definition at line 416 of file bsdf.c.

{
       if (b == NULL)
              return;
       if (b->bsdf != NULL)
              free(b->bsdf);
       free(b);
}

Here is the caller graph for this function:

int getBSDF_xfm ( MAT4  xm,
FVECT  nrm,
UpDir  ud 
)

Definition at line 527 of file bsdf.c.

{
       char   *xfargs[7];
       XF     myxf;
       FVECT  updir, xdest, ydest;

       updir[0] = updir[1] = updir[2] = 0.;
       switch (ud) {
       case UDzneg:
              updir[2] = -1.;
              break;
       case UDyneg:
              updir[1] = -1.;
              break;
       case UDxneg:
              updir[0] = -1.;
              break;
       case UDxpos:
              updir[0] = 1.;
              break;
       case UDypos:
              updir[1] = 1.;
              break;
       case UDzpos:
              updir[2] = 1.;
              break;
       case UDunknown:
              return(0);
       }
       fcross(xdest, updir, nrm);
       if (normalize(xdest) == 0.0)
              return(0);
       fcross(ydest, nrm, xdest);
       xf(&myxf, addrot(xfargs, xdest, ydest, nrm), xfargs);
       copymat4(xm, myxf.xfm);
       return(1);
}

Here is the call graph for this function:

Here is the caller graph for this function:

struct BSDF_data* load_BSDF ( char *  fname) [read]

Definition at line 356 of file bsdf.c.

{
       char                 *path;
       ezxml_t                     fl, wtl, wld, wdb;
       struct BSDF_data     *dp;
       
       path = getpath(fname, getrlibpath(), R_OK);
       if (path == NULL) {
              sprintf(errmsg, "cannot find BSDF file \"%s\"", fname);
              error(WARNING, errmsg);
              return(NULL);
       }
       fl = ezxml_parse_file(path);
       if (fl == NULL) {
              sprintf(errmsg, "cannot open BSDF \"%s\"", path);
              error(WARNING, errmsg);
              return(NULL);
       }
       if (ezxml_error(fl)[0]) {
              sprintf(errmsg, "BSDF \"%s\" %s", path, ezxml_error(fl));
              error(WARNING, errmsg);
              ezxml_free(fl);
              return(NULL);
       }
       if (strcmp(ezxml_name(fl), "WindowElement")) {
              sprintf(errmsg,
                     "BSDF \"%s\": top level node not 'WindowElement'",
                            path);
              error(WARNING, errmsg);
              ezxml_free(fl);
              return(NULL);
       }
       wtl = ezxml_child(ezxml_child(fl, "Optical"), "Layer");
       dp = (struct BSDF_data *)calloc(1, sizeof(struct BSDF_data));
       for (wld = ezxml_child(wtl, "WavelengthData");
                            wld != NULL; wld = wld->next) {
              if (strcmp(ezxml_txt(ezxml_child(wld,"Wavelength")), "Visible"))
                     continue;
              wdb = ezxml_child(wld, "WavelengthDataBlock");
              if (wdb == NULL) continue;
              if (strcmp(ezxml_txt(ezxml_child(wdb,"WavelengthDataDirection")),
                                   "Transmission Front"))
                     continue;
              load_bsdf_data(dp, wdb);    /* load front BTDF */
              break;                      /* ignore the rest */
       }
       ezxml_free(fl);                           /* done with XML file */
       if (!check_bsdf_data(dp)) {
              sprintf(errmsg, "bad/missing BTDF data in \"%s\"", path);
              error(WARNING, errmsg);
              free_BSDF(dp);
              dp = NULL;
       }
       return(dp);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int r_BSDF_incvec ( FVECT  v,
struct BSDF_data b,
int  i,
double  rv,
MAT4  xm 
)

Definition at line 429 of file bsdf.c.

{
       FVECT  pert;
       double rad;
       int    j;
       
       if (!getBSDF_incvec(v, b, i))
              return(0);
       rad = sqrt(getBSDF_incohm(b, i) / PI);
       multisamp(pert, 3, rv);
       for (j = 0; j < 3; j++)
              v[j] += rad*(2.*pert[j] - 1.);
       if (xm != NULL)
              multv3(v, v, xm);
       return(normalize(v) != 0.0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int r_BSDF_outvec ( FVECT  v,
struct BSDF_data b,
int  o,
double  rv,
MAT4  xm 
)

Definition at line 454 of file bsdf.c.

{
       FVECT  pert;
       double rad;
       int    j;
       
       if (!getBSDF_outvec(v, b, o))
              return(0);
       rad = sqrt(getBSDF_outohm(b, o) / PI);
       multisamp(pert, 3, rv);
       for (j = 0; j < 3; j++)
              v[j] += rad*(2.*pert[j] - 1.);
       if (xm != NULL)
              multv3(v, v, xm);
       return(normalize(v) != 0.0);
}

Here is the call graph for this function: