ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/pictool.h
Revision: 2.1
Committed: Wed Aug 12 23:07:59 2015 UTC (8 years, 8 months ago) by greg
Content type: text/plain
Branch: MAIN
Log Message:
Added Jan Wienold's evalglare to distribution

File Contents

# User Rev Content
1 greg 2.1 #ifndef __PICTOOL_H
2     #define __PICTOOL_H
3    
4     #ifdef __cplusplus
5     extern "C" {
6     #endif
7    
8     #include <stdio.h>
9     #include <stdlib.h>
10    
11     #include "g3vector.h"
12     #include "g3affine.h"
13     #include "g3flist.h"
14    
15     #include "view.h"
16     #include "color.h"
17    
18     #define PICT_GLARE
19    
20     #define PICT_VIEW 1
21     #define PICT_LUT 2
22    
23     #define PICT_CH1 1
24     #define PICT_CH2 2
25     #define PICT_CH3 4
26    
27     #define PICT_ALLCH 7
28    
29     #ifdef PICT_GLARE
30     typedef struct pixinfo {
31     int gsn;
32     int pgs;
33     double omega;
34     FVECT dir;
35     } pixinfo;
36     #endif
37    
38     typedef struct pict {
39     int use_lut;
40     char comment[4096];
41     int valid_view;
42     VIEW view;
43     COLOR* lut;
44     RESOLU resol;
45     COLOR* pic;
46     double pjitter;
47     #ifdef PICT_GLARE
48     pixinfo* pinfo;
49     g3FList* glareinfo;
50     #endif
51     } pict;
52    
53     #define pict_get_origin(p) (p->view.vp)
54     #define pict_get_viewdir(p) (p->view.vdir)
55     #define pict_get_viewup(p) (p->view.vup)
56    
57     #define pict_lut_used(p) (p->use_lut)
58    
59     #define pict_get_comp(p,x,y,i) ((p->pic + x*p->resol.yr)[y][i])
60     #define pict_colbuf(p,buf,x,y) ((buf + y*p->resol.xr)[x])
61     #define pict_get_color(p,x,y) pict_colbuf(p,p->pic,x,y)
62     #define pict_get_xsize(p) (p->resol.xr)
63     #define pict_get_ysize(p) (p->resol.yr)
64    
65    
66    
67     #ifdef PICT_GLARE
68    
69     #define pict_get_omega(p,x,y) ((p->pinfo[y + x*p->resol.yr])).omega
70     #define pict_get_cached_dir(p,x,y) (((p->pinfo[y + x*p->resol.yr])).dir)
71     #define pict_get_gsn(p,x,y) ((p->pinfo[y + x*p->resol.yr])).gsn
72     #define pict_get_pgs(p,x,y) ((p->pinfo[y + x*p->resol.yr])).pgs
73    
74     enum {
75     PICT_GSN = 0,
76     PICT_NPIX,
77     PICT_AVPOSX,
78     PICT_AVPOSY,
79     PICT_AVLUM,
80     PICT_AVOMEGA,
81     PICT_DXMAX,
82     PICT_DYMAX,
83     PICT_LMIN,
84     PICT_LMAX,
85     PICT_EGLARE,
86     PICT_DGLARE,
87     PICT_GLSIZE
88     };
89    
90     #define pict_get_num(p,i) (g3fl_get(p->glareinfo,i)[PICT_GSN])
91     #define pict_get_npix(p,i) (g3fl_get(p->glareinfo,i)[PICT_NPIX])
92     #define pict_get_av_posx(p,i) (g3fl_get(p->glareinfo,i)[PICT_AVPOSX])
93     #define pict_get_av_posy(p,i) (g3fl_get(p->glareinfo,i)[PICT_AVPOSY])
94     #define pict_get_av_lum(p,i) (g3fl_get(p->glareinfo,i)[PICT_AVLUM])
95     #define pict_get_av_omega(p,i) (g3fl_get(p->glareinfo,i)[PICT_AVOMEGA])
96     #define pict_get_dx_max(p,i) (g3fl_get(p->glareinfo,i)[PICT_DXMAX])
97     #define pict_get_dy_max(p,i) (g3fl_get(p->glareinfo,i)[PICT_DYMAX])
98     #define pict_get_lum_min(p,i) (g3fl_get(p->glareinfo,i)[PICT_LMIN])
99     #define pict_get_lum_max(p,i) (g3fl_get(p->glareinfo,i)[PICT_LMAX])
100     #define pict_get_Eglare(p,i) (g3fl_get(p->glareinfo,i)[PICT_EGLARE])
101     #define pict_get_Dglare(p,i) (g3fl_get(p->glareinfo,i)[PICT_DGLARE])
102    
103     #define pict_get_gli_size(p) (p->glareinfo->size)
104    
105     #ifdef PICT_GLARE
106     #define pict_is_validpixel(p,x,y) (((p->view.type != VT_ANG) || \
107     (DOT(pict_get_cached_dir(p,x,y), p->view.vdir) >= 0.0))\
108     && pict_get_omega(p,x,y) > 0.0)
109     #else
110     #define pict_is_validpixel(p,x,y) (((p->view.type != VT_ANG) || \
111     (DOT(pict_get_cached_dir(p,x,y), p->view.vdir) >= 0.0))\
112     && pict_get_sangle(p,x,y) > 0)
113    
114     #endif
115    
116     void pict_new_gli(pict* p);
117    
118     void pict_update_evalglare_caches(pict* p);
119    
120     #endif
121    
122     int pict_init(pict* p);
123     pict* pict_create();
124     void pict_free(pict* p);
125    
126     pict* pict_get_copy(pict* p);
127    
128     void pict_set_comment(pict* p,const char* c);
129    
130     int pict_resize(pict* p,int x,int y);
131    
132     int pict_zero(pict* p);
133    
134     int pict_read(pict* p,char* fn);
135     int pict_read_fp(pict* p,FILE* fp);
136     int pict_read_tt_txt(pict* p,char* fn);
137     int pict_read_from_list(pict* p,FILE* fp);
138     int pict_write(pict* p,char* fn);
139     int pict_write_fp(pict* p,FILE* fp);
140     int pict_write_dir(pict* p,FILE* fp);
141    
142     int pict_setup_lut(pict* p,char* theta_fn,char* phi_fn,char* omega_fn);
143     int pict_update_lut(pict* p);
144    
145     int pict_update_view(pict* p);
146    
147     int pict_get_dir(pict* p,int x,int y,FVECT dir);
148     int pict_get_dir_ic(pict* p,double x,double y,FVECT dir);
149     int pict_get_ray(pict* p,int x,int y,FVECT orig,FVECT dir);
150     int pict_get_ray_ic(pict* p,double x,double y,FVECT orig,FVECT dir);
151     int pict_locate(pict* p,FVECT pt,int* x,int* y);
152     double pict_get_sangle(pict* p,int x,int y);
153    
154     int pict_get_vangle(pict* p,double x,double y,FVECT vdir,FVECT vup,double* a);
155     int pict_get_hangle(pict* p,double x,double y,FVECT vdir,FVECT vup,double* a);
156     int pict_get_tau(pict* p,double x,double y,FVECT vdir,FVECT vup,double* t);
157     int pict_get_sigma(pict* p,double x,double y,FVECT vdir,FVECT vup,double* s);
158    
159     int pict_set_pj(pict* p,double pj);
160     int pict_setorigin(pict* p,FVECT orig);
161     int pict_setdir(pict* p,FVECT dir);
162     int pict_setvtype(pict* p,char vt);
163     int pict_setvup(pict* p,FVECT vup);
164     int pict_sethview(pict* p,double ha);
165     int pict_setvview(pict* p,double va);
166    
167     int pict_trans_cam(pict* p,g3ATrans t);
168    
169    
170    
171    
172     #ifdef __cplusplus
173     }
174     #endif
175     #endif