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