ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/cmatrix.h
Revision: 2.14
Committed: Tue Nov 21 01:30:20 2023 UTC (4 months, 3 weeks ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 2.13: +2 -2 lines
Log Message:
feat(rmtxop): Added handling of Radiance spectral pictures as matrices

File Contents

# User Rev Content
1 greg 2.14 /* RCSid $Id: cmatrix.h,v 2.13 2021/01/19 23:32:00 greg Exp $ */
2 greg 2.1 /*
3     * Color matrix routine declarations.
4     *
5     * G. Ward
6     */
7    
8     #ifndef _RAD_CMATRIX_H_
9     #define _RAD_CMATRIX_H_
10    
11 greg 2.8 #include <sys/types.h>
12 greg 2.1 #include "color.h"
13    
14     #ifdef __cplusplus
15     extern "C" {
16     #endif
17    
18     /* Data types for file loading */
19 greg 2.14 enum {DTfromHeader=0, DTrgbe, DTxyze, DTspec, DTfloat, DTascii, DTdouble, DTend};
20 greg 2.4
21 greg 2.13 extern const char stdin_name[];
22 greg 2.4 extern const char *cm_fmt_id[];
23     extern const int cm_elem_size[];
24 greg 2.1
25     /* A color coefficient matrix -- vectors have ncols==1 */
26     typedef struct {
27     int nrows, ncols;
28     COLORV cmem[3]; /* extends struct */
29     } CMATRIX;
30    
31     #define COLSPEC (sizeof(COLORV)==sizeof(float) ? "%f %f %f" : "%lf %lf %lf")
32    
33 greg 2.8 #define cm_lval(cm,r,c) ((cm)->cmem + 3*((size_t)(r)*(cm)->ncols + (c)))
34 greg 2.1
35     #define cv_lval(cm,i) ((cm)->cmem + 3*(i))
36    
37     /* Allocate a color coefficient matrix */
38 greg 2.5 extern CMATRIX *cm_alloc(int nrows, int ncols);
39 greg 2.1
40     /* Resize color coefficient matrix */
41 greg 2.5 extern CMATRIX *cm_resize(CMATRIX *cm, int nrows);
42 greg 2.1
43     #define cm_free(cm) free(cm)
44    
45 greg 2.5 /* Load header to obtain/check data type and matrix dimensions */
46 greg 2.12 extern char *cm_getheader(int *dt, int *nr, int *nc,
47     int *swp, COLOR scale, FILE *fp);
48 greg 2.1
49 greg 2.7 /* Allocate and load a matrix from the given input (or stdin if NULL) */
50     extern CMATRIX *cm_load(const char *inspec, int nrows, int ncols, int dtype);
51 greg 2.1
52     /* Extract a column vector from a matrix */
53 greg 2.5 extern CMATRIX *cm_column(const CMATRIX *cm, int c);
54 greg 2.1
55     /* Multiply two matrices (or a matrix and a vector) and allocate the result */
56 greg 2.5 extern CMATRIX *cm_multiply(const CMATRIX *cm1, const CMATRIX *cm2);
57 greg 2.1
58 greg 2.4 /* write out matrix to file (precede by resolution string if picture) */
59 greg 2.5 extern int cm_write(const CMATRIX *cm, int dtype, FILE *fp);
60 greg 2.1
61 greg 2.3 /* Load and convert a matrix BTDF from the given XML file */
62 greg 2.13 extern CMATRIX *cm_loadBTDF(const char *fname);
63    
64     /* Load and convert a matrix BRDF from the given XML file */
65     extern CMATRIX *cm_loadBRDF(const char *fname, int backside);
66 greg 2.1
67     #ifdef __cplusplus
68     }
69     #endif
70     #endif /* _RAD_CMATRIX_H_ */