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