--- ray/src/util/cmatrix.h 2014/01/20 21:29:04 2.1 +++ ray/src/util/cmatrix.h 2015/05/04 20:53:21 2.7 @@ -1,4 +1,4 @@ -/* RCSid $Id: cmatrix.h,v 2.1 2014/01/20 21:29:04 greg Exp $ */ +/* RCSid $Id: cmatrix.h,v 2.7 2015/05/04 20:53:21 greg Exp $ */ /* * Color matrix routine declarations. * @@ -15,8 +15,11 @@ extern "C" { #endif /* Data types for file loading */ -enum {DTfromHeader, DTascii, DTfloat, DTdouble, DTrgbe, DTxyze}; +enum {DTfromHeader=0, DTascii, DTrgbe, DTxyze, DTfloat, DTdouble, DTend}; +extern const char *cm_fmt_id[]; +extern const int cm_elem_size[]; + /* A color coefficient matrix -- vectors have ncols==1 */ typedef struct { int nrows, ncols; @@ -30,33 +33,33 @@ typedef struct { #define cv_lval(cm,i) ((cm)->cmem + 3*(i)) /* Allocate a color coefficient matrix */ -extern CMATRIX *cm_alloc(int nrows, int ncols); +extern CMATRIX *cm_alloc(int nrows, int ncols); /* Resize color coefficient matrix */ -extern CMATRIX *cm_resize(CMATRIX *cm, int nrows); +extern CMATRIX *cm_resize(CMATRIX *cm, int nrows); #define cm_free(cm) free(cm) -/* Load header to obtain data type */ -int getDTfromHeader(FILE *fp); +/* Load header to obtain/check data type and matrix dimensions */ +extern char *cm_getheader(int *dt, int *nr, int *nc, FILE *fp); -/* Allocate and load a matrix from the given file (or stdin if NULL) */ -extern CMATRIX *cm_load(const char *fname, int nrows, int ncols, int dtype); +/* Allocate and load a matrix from the given input (or stdin if NULL) */ +extern CMATRIX *cm_load(const char *inspec, int nrows, int ncols, int dtype); /* Extract a column vector from a matrix */ -extern CMATRIX *cm_column(const CMATRIX *cm, int c); +extern CMATRIX *cm_column(const CMATRIX *cm, int c); /* Scale a matrix by a single value */ -extern CMATRIX *cm_scale(const CMATRIX *cm1, const COLOR sca); +extern CMATRIX *cm_scale(const CMATRIX *cm1, const COLOR sca); /* Multiply two matrices (or a matrix and a vector) and allocate the result */ -extern CMATRIX *cm_multiply(const CMATRIX *cm1, const CMATRIX *cm2); +extern CMATRIX *cm_multiply(const CMATRIX *cm1, const CMATRIX *cm2); -/* print out matrix as ASCII text -- no header */ -extern void cm_print(const CMATRIX *cm, FILE *fp); +/* write out matrix to file (precede by resolution string if picture) */ +extern int cm_write(const CMATRIX *cm, int dtype, FILE *fp); -/* Load and convert a matrix BSDF from the given XML file */ -extern CMATRIX *cm_loadBSDF(char *fname, COLOR cLamb); +/* Load and convert a matrix BTDF from the given XML file */ +extern CMATRIX *cm_loadBTDF(char *fname); #ifdef __cplusplus }