BRL-CAD

Routines for processing tables (curves) of data with one independent parameter which is common to many sets of dependent data values. More...

Collaboration diagram for Tabulated Data:

Data Structures

struct  bn_table
 
struct  bn_tabdata
 

Macros

#define BN_CK_TABLE(_p)   BU_CKMAG(_p, BN_TABLE_MAGIC, "bn_table")
 
#define BN_TABLE_NULL   ((struct bn_table *)NULL)
 
#define BN_GET_TABLE(_table, _nx)
 
#define BN_CK_TABDATA(_p)   BU_CKMAG(_p, BN_TABDATA_MAGIC, "bn_tabdata")
 
#define BN_TABDATA_NULL   ((struct bn_tabdata *)NULL)
 
#define BN_SIZEOF_TABDATA_Y(_tabdata)   sizeof(fastf_t)*((_tabdata)->ny)
 
#define BN_SIZEOF_TABDATA(_table)
 
#define BN_GET_TABDATA(_data, _table)
 

Functions

void bn_table_free (struct bn_table *tabp)
 
void bn_tabdata_free (struct bn_tabdata *data)
 
void bn_ck_table (const struct bn_table *tabp)
 
struct bn_tablebn_table_make_uniform (size_t num, double first, double last)
 
void bn_tabdata_add (struct bn_tabdata *out, const struct bn_tabdata *in1, const struct bn_tabdata *in2)
 
void bn_tabdata_mul (struct bn_tabdata *out, const struct bn_tabdata *in1, const struct bn_tabdata *in2)
 
void bn_tabdata_mul3 (struct bn_tabdata *out, const struct bn_tabdata *in1, const struct bn_tabdata *in2, const struct bn_tabdata *in3)
 
void bn_tabdata_incr_mul3_scale (struct bn_tabdata *out, const struct bn_tabdata *in1, const struct bn_tabdata *in2, const struct bn_tabdata *in3, double scale)
 
void bn_tabdata_incr_mul2_scale (struct bn_tabdata *out, const struct bn_tabdata *in1, const struct bn_tabdata *in2, double scale)
 
void bn_tabdata_scale (struct bn_tabdata *out, const struct bn_tabdata *in1, double scale)
 
void bn_table_scale (struct bn_table *tabp, double scale)
 
void bn_tabdata_join1 (struct bn_tabdata *out, const struct bn_tabdata *in1, double scale, const struct bn_tabdata *in2)
 
void bn_tabdata_join2 (struct bn_tabdata *out, const struct bn_tabdata *in1, double scale2, const struct bn_tabdata *in2, double scale3, const struct bn_tabdata *in3)
 
void bn_tabdata_blend2 (struct bn_tabdata *out, double scale1, const struct bn_tabdata *in1, double scale2, const struct bn_tabdata *in2)
 
void bn_tabdata_blend3 (struct bn_tabdata *out, double scale1, const struct bn_tabdata *in1, double scale2, const struct bn_tabdata *in2, double scale3, const struct bn_tabdata *in3)
 
double bn_tabdata_area1 (const struct bn_tabdata *in)
 
double bn_tabdata_area2 (const struct bn_tabdata *in)
 
double bn_tabdata_mul_area1 (const struct bn_tabdata *in1, const struct bn_tabdata *in2)
 
double bn_tabdata_mul_area2 (const struct bn_tabdata *in1, const struct bn_tabdata *in2)
 
fastf_t bn_table_lin_interp (const struct bn_tabdata *samp, double wl)
 
struct bn_tabdatabn_tabdata_resample_max (const struct bn_table *newtable, const struct bn_tabdata *olddata)
 
struct bn_tabdatabn_tabdata_resample_avg (const struct bn_table *newtable, const struct bn_tabdata *olddata)
 
int bn_table_write (const char *filename, const struct bn_table *tabp)
 
struct bn_tablebn_table_read (const char *filename)
 
void bn_pr_table (const char *title, const struct bn_table *tabp)
 
void bn_pr_tabdata (const char *title, const struct bn_tabdata *data)
 
int bn_print_table_and_tabdata (const char *filename, const struct bn_tabdata *data)
 
struct bn_tabdatabn_read_table_and_tabdata (const char *filename)
 
struct bn_tabdatabn_tabdata_binary_read (const char *filename, size_t num, const struct bn_table *tabp)
 
struct bn_tabdatabn_tabdata_malloc_array (const struct bn_table *tabp, size_t num)
 
void bn_tabdata_copy (struct bn_tabdata *out, const struct bn_tabdata *in)
 
struct bn_tabdatabn_tabdata_dup (const struct bn_tabdata *in)
 
struct bn_tabdatabn_tabdata_get_constval (double val, const struct bn_table *tabp)
 
void bn_tabdata_constval (struct bn_tabdata *data, double val)
 
void bn_tabdata_to_tcl (struct bu_vls *vp, const struct bn_tabdata *data)
 
struct bn_tabdatabn_tabdata_from_array (const double *array)
 
void bn_tabdata_freq_shift (struct bn_tabdata *out, const struct bn_tabdata *in, double offset)
 
size_t bn_table_interval_num_samples (const struct bn_table *tabp, double low, double hi)
 
size_t bn_table_delete_sample_pnts (struct bn_table *tabp, size_t i, size_t j)
 
struct bn_tablebn_table_merge2 (const struct bn_table *a, const struct bn_table *b)
 
struct bn_tabdatabn_tabdata_mk_linear_filter (const struct bn_table *spectrum, double lower_wavelen, double upper_wavelen)
 

Detailed Description

Routines for processing tables (curves) of data with one independent parameter which is common to many sets of dependent data values.

Data structures to assist with recording many sets of data sampled along the same set of independent variables.

The overall notion is that each sample should be as compact as possible (an array of measurements), with all the context stored in one place.

These structures and support routines apply to any measured "curve" or "function" or "table" with one independent variable and one or more scalar dependent variable(s).

The context is kept in an 'bn_table' structure, and the data for one particular sample are kept in an 'bn_tabdata' structure.

The contents of the sample in val[j] are interpreted in the interval (wavel[j]..wavel[j+1]). This value could be power, albedo, absorption, refractive index, or any other wavelength-specific parameter.

For example, if the val[] array contains power values, then val[j] contains the integral of the power from wavel[j] to wavel[j+1]

As an example, assume nwave=2, wavel[0]=500, wavel[1]=600, wavel[2]=700. Then val[0] would contain data for the 500 to 600nm interval, and val[1] would contain data for the 600 to 700nm interval. There would be no storage allocated for val[2] – don't use it! There are several interpretations of this: 1) val[j] stores the total (integral, area) value for the interval, or 2) val[j] stores the average value across the interval.

The intervals need not be uniformly spaced; it is acceptable to increase wavelength sampling density around "important" frequencies.

Operates on bn_table (independent var) and bn_tabdata (dependent variable) structures.

One application is for storing spectral curves, see spectrum.c

Inspired by -
Roy Hall and his book "Illumination and Color in Computer @n Generated Imagery", Springer Verlag, New York, 1989.
ISBN 0-387-96774-5

With thanks to Russ Moulton Jr, EOSoft Inc. for his "rad.c" module.

Macro Definition Documentation

◆ BN_CK_TABLE

#define BN_CK_TABLE (   _p)    BU_CKMAG(_p, BN_TABLE_MAGIC, "bn_table")

Definition at line 96 of file tabdata.h.

◆ BN_TABLE_NULL

#define BN_TABLE_NULL   ((struct bn_table *)NULL)

Definition at line 97 of file tabdata.h.

◆ BN_GET_TABLE

#define BN_GET_TABLE (   _table,
  _nx 
)
Value:
{ \
if ((_nx) < 1) bu_bomb("RT_GET_TABLE() _nx < 1\n"); \
_table = (struct bn_table *)bu_calloc(1, \
sizeof(struct bn_table) + sizeof(fastf_t)*(_nx), \
"struct bn_table"); \
_table->magic = BN_TABLE_MAGIC; \
_table->nx = (_nx); }
NORETURN void bu_bomb(const char *str)
#define BN_TABLE_MAGIC
Definition: magic.h:82
void * bu_calloc(size_t nelem, size_t elsize, const char *str)
void float float int * n
Definition: tig.h:74
double fastf_t
fastest 64-bit (or larger) floating point type
Definition: vmath.h:330

Definition at line 101 of file tabdata.h.

◆ BN_CK_TABDATA

#define BN_CK_TABDATA (   _p)    BU_CKMAG(_p, BN_TABDATA_MAGIC, "bn_tabdata")

Definition at line 123 of file tabdata.h.

◆ BN_TABDATA_NULL

#define BN_TABDATA_NULL   ((struct bn_tabdata *)NULL)

Definition at line 124 of file tabdata.h.

◆ BN_SIZEOF_TABDATA_Y

#define BN_SIZEOF_TABDATA_Y (   _tabdata)    sizeof(fastf_t)*((_tabdata)->ny)

Definition at line 126 of file tabdata.h.

◆ BN_SIZEOF_TABDATA

#define BN_SIZEOF_TABDATA (   _table)
Value:
(sizeof(struct bn_tabdata) + \
sizeof(fastf_t)*((_table)->nx-1))

Definition at line 127 of file tabdata.h.

◆ BN_GET_TABDATA

#define BN_GET_TABDATA (   _data,
  _table 
)
Value:
{ \
BN_CK_TABLE(_table);\
_data = (struct bn_tabdata *)bu_calloc(1, \
BN_SIZEOF_TABDATA(_table), "struct bn_tabdata"); \
_data->magic = BN_TABDATA_MAGIC; \
_data->ny = (_table)->nx; \
_data->table = (_table); }
#define BN_SIZEOF_TABDATA(_table)
Definition: tabdata.h:127
#define BN_TABDATA_MAGIC
Definition: magic.h:81

Definition at line 131 of file tabdata.h.

Function Documentation

◆ bn_table_free()

void bn_table_free ( struct bn_table tabp)

◆ bn_tabdata_free()

void bn_tabdata_free ( struct bn_tabdata data)

◆ bn_ck_table()

void bn_ck_table ( const struct bn_table tabp)

◆ bn_table_make_uniform()

struct bn_table * bn_table_make_uniform ( size_t  num,
double  first,
double  last 
)

◆ bn_tabdata_add()

void bn_tabdata_add ( struct bn_tabdata out,
const struct bn_tabdata in1,
const struct bn_tabdata in2 
)

◆ bn_tabdata_mul()

void bn_tabdata_mul ( struct bn_tabdata out,
const struct bn_tabdata in1,
const struct bn_tabdata in2 
)

◆ bn_tabdata_mul3()

void bn_tabdata_mul3 ( struct bn_tabdata out,
const struct bn_tabdata in1,
const struct bn_tabdata in2,
const struct bn_tabdata in3 
)

◆ bn_tabdata_incr_mul3_scale()

void bn_tabdata_incr_mul3_scale ( struct bn_tabdata out,
const struct bn_tabdata in1,
const struct bn_tabdata in2,
const struct bn_tabdata in3,
double  scale 
)

◆ bn_tabdata_incr_mul2_scale()

void bn_tabdata_incr_mul2_scale ( struct bn_tabdata out,
const struct bn_tabdata in1,
const struct bn_tabdata in2,
double  scale 
)

◆ bn_tabdata_scale()

void bn_tabdata_scale ( struct bn_tabdata out,
const struct bn_tabdata in1,
double  scale 
)

◆ bn_table_scale()

void bn_table_scale ( struct bn_table tabp,
double  scale 
)

◆ bn_tabdata_join1()

void bn_tabdata_join1 ( struct bn_tabdata out,
const struct bn_tabdata in1,
double  scale,
const struct bn_tabdata in2 
)

◆ bn_tabdata_join2()

void bn_tabdata_join2 ( struct bn_tabdata out,
const struct bn_tabdata in1,
double  scale2,
const struct bn_tabdata in2,
double  scale3,
const struct bn_tabdata in3 
)

◆ bn_tabdata_blend2()

void bn_tabdata_blend2 ( struct bn_tabdata out,
double  scale1,
const struct bn_tabdata in1,
double  scale2,
const struct bn_tabdata in2 
)

◆ bn_tabdata_blend3()

void bn_tabdata_blend3 ( struct bn_tabdata out,
double  scale1,
const struct bn_tabdata in1,
double  scale2,
const struct bn_tabdata in2,
double  scale3,
const struct bn_tabdata in3 
)

◆ bn_tabdata_area1()

double bn_tabdata_area1 ( const struct bn_tabdata in)

◆ bn_tabdata_area2()

double bn_tabdata_area2 ( const struct bn_tabdata in)

◆ bn_tabdata_mul_area1()

double bn_tabdata_mul_area1 ( const struct bn_tabdata in1,
const struct bn_tabdata in2 
)

◆ bn_tabdata_mul_area2()

double bn_tabdata_mul_area2 ( const struct bn_tabdata in1,
const struct bn_tabdata in2 
)

◆ bn_table_lin_interp()

fastf_t bn_table_lin_interp ( const struct bn_tabdata samp,
double  wl 
)

◆ bn_tabdata_resample_max()

struct bn_tabdata * bn_tabdata_resample_max ( const struct bn_table newtable,
const struct bn_tabdata olddata 
)

◆ bn_tabdata_resample_avg()

struct bn_tabdata * bn_tabdata_resample_avg ( const struct bn_table newtable,
const struct bn_tabdata olddata 
)

◆ bn_table_write()

int bn_table_write ( const char *  filename,
const struct bn_table tabp 
)

◆ bn_table_read()

struct bn_table * bn_table_read ( const char *  filename)

◆ bn_pr_table()

void bn_pr_table ( const char *  title,
const struct bn_table tabp 
)

◆ bn_pr_tabdata()

void bn_pr_tabdata ( const char *  title,
const struct bn_tabdata data 
)

◆ bn_print_table_and_tabdata()

int bn_print_table_and_tabdata ( const char *  filename,
const struct bn_tabdata data 
)

◆ bn_read_table_and_tabdata()

struct bn_tabdata * bn_read_table_and_tabdata ( const char *  filename)

◆ bn_tabdata_binary_read()

struct bn_tabdata * bn_tabdata_binary_read ( const char *  filename,
size_t  num,
const struct bn_table tabp 
)

◆ bn_tabdata_malloc_array()

struct bn_tabdata * bn_tabdata_malloc_array ( const struct bn_table tabp,
size_t  num 
)

◆ bn_tabdata_copy()

void bn_tabdata_copy ( struct bn_tabdata out,
const struct bn_tabdata in 
)

◆ bn_tabdata_dup()

struct bn_tabdata * bn_tabdata_dup ( const struct bn_tabdata in)

◆ bn_tabdata_get_constval()

struct bn_tabdata * bn_tabdata_get_constval ( double  val,
const struct bn_table tabp 
)

◆ bn_tabdata_constval()

void bn_tabdata_constval ( struct bn_tabdata data,
double  val 
)

◆ bn_tabdata_to_tcl()

void bn_tabdata_to_tcl ( struct bu_vls vp,
const struct bn_tabdata data 
)

◆ bn_tabdata_from_array()

struct bn_tabdata * bn_tabdata_from_array ( const double *  array)

◆ bn_tabdata_freq_shift()

void bn_tabdata_freq_shift ( struct bn_tabdata out,
const struct bn_tabdata in,
double  offset 
)

◆ bn_table_interval_num_samples()

size_t bn_table_interval_num_samples ( const struct bn_table tabp,
double  low,
double  hi 
)

◆ bn_table_delete_sample_pnts()

size_t bn_table_delete_sample_pnts ( struct bn_table tabp,
size_t  i,
size_t  j 
)

◆ bn_table_merge2()

struct bn_table * bn_table_merge2 ( const struct bn_table a,
const struct bn_table b 
)

◆ bn_tabdata_mk_linear_filter()

struct bn_tabdata * bn_tabdata_mk_linear_filter ( const struct bn_table spectrum,
double  lower_wavelen,
double  upper_wavelen 
)