1 |
greg |
2.20 |
/* RCSid $Id: rcontrib.h,v 2.19 2023/11/15 18:02:53 greg Exp $ */ |
2 |
greg |
2.1 |
|
3 |
|
|
/* |
4 |
|
|
* Header file for rcontrib modules |
5 |
|
|
*/ |
6 |
|
|
|
7 |
greg |
2.7 |
#include "platform.h" |
8 |
greg |
2.8 |
#include "rtprocess.h" |
9 |
greg |
2.1 |
#include "ray.h" |
10 |
|
|
#include "func.h" |
11 |
|
|
#include "lookup.h" |
12 |
|
|
|
13 |
|
|
extern int gargc; /* global argc */ |
14 |
|
|
extern char **gargv; /* global argv */ |
15 |
|
|
extern char *octname; /* global octree name */ |
16 |
|
|
|
17 |
|
|
extern int nproc; /* number of processes requested */ |
18 |
|
|
extern int nchild; /* number of children (-1 in child) */ |
19 |
|
|
|
20 |
|
|
extern int inpfmt; /* input format */ |
21 |
|
|
extern int outfmt; /* output format */ |
22 |
|
|
|
23 |
|
|
extern int header; /* output header? */ |
24 |
|
|
extern int force_open; /* truncate existing output? */ |
25 |
|
|
extern int recover; /* recover previous output? */ |
26 |
|
|
extern int accumulate; /* input rays per output record */ |
27 |
|
|
extern int contrib; /* computing contributions? */ |
28 |
|
|
|
29 |
|
|
extern int xres; /* horizontal (scan) size */ |
30 |
|
|
extern int yres; /* vertical resolution */ |
31 |
|
|
|
32 |
|
|
extern int using_stdout; /* are we using stdout? */ |
33 |
|
|
|
34 |
|
|
extern int imm_irrad; /* compute immediate irradiance? */ |
35 |
|
|
extern int lim_dist; /* limit distance? */ |
36 |
|
|
|
37 |
|
|
extern int account; /* current accumulation count */ |
38 |
|
|
extern RNUMBER raysleft; /* number of rays left to trace */ |
39 |
|
|
extern long waitflush; /* how long until next flush */ |
40 |
|
|
|
41 |
greg |
2.3 |
extern RNUMBER lastray; /* last ray number sent */ |
42 |
|
|
extern RNUMBER lastdone; /* last ray processed */ |
43 |
greg |
2.1 |
|
44 |
greg |
2.16 |
extern int report_intvl; /* reporting interval (seconds) */ |
45 |
|
|
|
46 |
greg |
2.19 |
typedef double DCOLORV; /* double-precision color type */ |
47 |
greg |
2.1 |
|
48 |
|
|
/* |
49 |
|
|
* The MODCONT structure is used to accumulate ray contributions |
50 |
|
|
* for a particular modifier, which may be subdivided into bins |
51 |
|
|
* if binv evaluates > 0. If outspec contains a %s in it, this will |
52 |
|
|
* be replaced with the modifier name. If outspec contains a %d in it, |
53 |
|
|
* this will be used to create one output file per bin, otherwise all bins |
54 |
|
|
* will be written to the same file, in order. If the global outfmt |
55 |
greg |
2.19 |
* is 'c', then a common-exponent pixel will be output for each bin value |
56 |
|
|
* and the file will conform to a RADIANCE picture if NCSAMP==3 and |
57 |
|
|
* xres and yres are set. |
58 |
greg |
2.1 |
*/ |
59 |
|
|
typedef struct { |
60 |
|
|
const char *outspec; /* output file specification */ |
61 |
|
|
const char *modname; /* modifier name */ |
62 |
greg |
2.10 |
const char *params; /* parameter list */ |
63 |
greg |
2.1 |
EPNODE *binv; /* bin value expression */ |
64 |
greg |
2.15 |
int bin0; /* starting bin offset */ |
65 |
greg |
2.1 |
int nbins; /* number of contribution bins */ |
66 |
greg |
2.19 |
DCOLORV cbin[1]; /* contribution bins (extends struct) */ |
67 |
greg |
2.1 |
} MODCONT; /* modifier contribution */ |
68 |
|
|
|
69 |
greg |
2.19 |
#define DCOLORSIZ (sizeof(DCOLORV)*NCSAMP) |
70 |
|
|
#define mcsize(nb) (sizeof(MODCONT)-sizeof(DCOLORV)+(nb)*DCOLORSIZ) |
71 |
|
|
#define mcbin(mp,bi) ((mp)->cbin + (bi)*NCSAMP) |
72 |
|
|
|
73 |
greg |
2.1 |
extern LUTAB modconttab; /* modifier contribution table */ |
74 |
|
|
|
75 |
|
|
/* |
76 |
|
|
* The STREAMOUT structure holds an open FILE pointer and a count of |
77 |
|
|
* the number of RGB triplets per record, or 0 if unknown. |
78 |
|
|
*/ |
79 |
|
|
typedef struct { |
80 |
|
|
FILE *ofp; /* output file pointer */ |
81 |
|
|
int outpipe; /* output is to a pipe */ |
82 |
|
|
int reclen; /* triplets/record */ |
83 |
|
|
int xr, yr; /* output resolution for picture */ |
84 |
|
|
} STREAMOUT; |
85 |
|
|
|
86 |
|
|
extern LUTAB ofiletab; /* output stream table */ |
87 |
|
|
|
88 |
|
|
#ifndef MAXPROCESS |
89 |
schorsch |
2.13 |
#if defined(_WIN32) || defined(_WIN64) |
90 |
greg |
2.1 |
#define MAXPROCESS 1 |
91 |
|
|
#else |
92 |
|
|
#define MAXPROCESS 128 |
93 |
|
|
#endif |
94 |
|
|
#endif |
95 |
|
|
|
96 |
greg |
2.17 |
extern char **modname; /* ordered modifier name list */ |
97 |
greg |
2.1 |
extern int nmods; /* number of modifiers */ |
98 |
greg |
2.17 |
extern int modasiz; /* allocated modifier array size */ |
99 |
greg |
2.1 |
|
100 |
|
|
extern char RCCONTEXT[]; /* special evaluation context */ |
101 |
|
|
|
102 |
|
|
extern void process_rcontrib(void); /* trace ray contributions */ |
103 |
|
|
|
104 |
|
|
extern STREAMOUT * getostream(const char *ospec, const char *mname, |
105 |
|
|
int bn, int noopen); |
106 |
|
|
|
107 |
|
|
extern void mod_output(MODCONT *mp); |
108 |
|
|
extern void end_record(void); |
109 |
|
|
|
110 |
|
|
extern MODCONT *addmodifier(char *modn, char *outf, |
111 |
greg |
2.10 |
char *prms, char *binv, int bincnt); |
112 |
greg |
2.1 |
extern void addmodfile(char *fname, char *outf, |
113 |
greg |
2.10 |
char *prms, char *binv, int bincnt); |
114 |
greg |
2.1 |
|
115 |
|
|
extern void reload_output(void); |
116 |
|
|
extern void recover_output(void); |
117 |
|
|
|
118 |
|
|
extern int getvec(FVECT vec); |
119 |
|
|
|
120 |
|
|
extern int in_rchild(void); |
121 |
greg |
2.6 |
extern void end_children(int immed); |
122 |
greg |
2.1 |
|
123 |
greg |
2.2 |
extern void put_zero_record(int ndx); |
124 |
greg |
2.1 |
|
125 |
greg |
2.16 |
extern int morays(void); /* reached end of input? */ |
126 |
|
|
|
127 |
greg |
2.1 |
extern void parental_loop(void); /* controlling process */ |
128 |
|
|
|
129 |
greg |
2.9 |
extern void feeder_loop(void); /* feeder process */ |
130 |
|
|
|
131 |
greg |
2.1 |
extern void rcontrib(void); /* main calculation loop */ |