5 |
|
* rpmain.c - main for rpict batch rendering program |
6 |
|
*/ |
7 |
|
|
8 |
< |
/* ==================================================================== |
9 |
< |
* The Radiance Software License, Version 1.0 |
10 |
< |
* |
11 |
< |
* Copyright (c) 1990 - 2002 The Regents of the University of California, |
12 |
< |
* through Lawrence Berkeley National Laboratory. All rights reserved. |
13 |
< |
* |
14 |
< |
* Redistribution and use in source and binary forms, with or without |
15 |
< |
* modification, are permitted provided that the following conditions |
16 |
< |
* are met: |
17 |
< |
* |
18 |
< |
* 1. Redistributions of source code must retain the above copyright |
19 |
< |
* notice, this list of conditions and the following disclaimer. |
20 |
< |
* |
21 |
< |
* 2. Redistributions in binary form must reproduce the above copyright |
22 |
< |
* notice, this list of conditions and the following disclaimer in |
23 |
< |
* the documentation and/or other materials provided with the |
24 |
< |
* distribution. |
25 |
< |
* |
26 |
< |
* 3. The end-user documentation included with the redistribution, |
27 |
< |
* if any, must include the following acknowledgment: |
28 |
< |
* "This product includes Radiance software |
29 |
< |
* (http://radsite.lbl.gov/) |
30 |
< |
* developed by the Lawrence Berkeley National Laboratory |
31 |
< |
* (http://www.lbl.gov/)." |
32 |
< |
* Alternately, this acknowledgment may appear in the software itself, |
33 |
< |
* if and wherever such third-party acknowledgments normally appear. |
34 |
< |
* |
35 |
< |
* 4. The names "Radiance," "Lawrence Berkeley National Laboratory" |
36 |
< |
* and "The Regents of the University of California" must |
37 |
< |
* not be used to endorse or promote products derived from this |
38 |
< |
* software without prior written permission. For written |
39 |
< |
* permission, please contact [email protected]. |
40 |
< |
* |
41 |
< |
* 5. Products derived from this software may not be called "Radiance", |
42 |
< |
* nor may "Radiance" appear in their name, without prior written |
43 |
< |
* permission of Lawrence Berkeley National Laboratory. |
44 |
< |
* |
45 |
< |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED |
46 |
< |
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
47 |
< |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
48 |
< |
* DISCLAIMED. IN NO EVENT SHALL Lawrence Berkeley National Laboratory OR |
49 |
< |
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
50 |
< |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
51 |
< |
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
52 |
< |
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
53 |
< |
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
54 |
< |
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
55 |
< |
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
56 |
< |
* SUCH DAMAGE. |
57 |
< |
* ==================================================================== |
58 |
< |
* |
59 |
< |
* This software consists of voluntary contributions made by many |
60 |
< |
* individuals on behalf of Lawrence Berkeley National Laboratory. For more |
61 |
< |
* information on Lawrence Berkeley National Laboratory, please see |
62 |
< |
* <http://www.lbl.gov/>. |
63 |
< |
*/ |
8 |
> |
#include "copyright.h" |
9 |
|
|
10 |
< |
#include "ray.h" |
10 |
> |
#include <time.h> |
11 |
> |
#include <signal.h> |
12 |
|
|
13 |
+ |
#include "platform.h" |
14 |
+ |
#include "rtprocess.h" /* getpid() */ |
15 |
+ |
#include "ray.h" |
16 |
|
#include "source.h" |
68 |
– |
|
17 |
|
#include "ambient.h" |
70 |
– |
|
18 |
|
#include "random.h" |
72 |
– |
|
19 |
|
#include "paths.h" |
74 |
– |
|
75 |
– |
#include <sys/types.h> |
76 |
– |
|
77 |
– |
#include <signal.h> |
78 |
– |
|
20 |
|
#include "view.h" |
21 |
|
|
81 |
– |
#include "paths.h" |
22 |
|
/* persistent processes define */ |
23 |
|
#ifdef F_SETLKW |
24 |
|
#define PERSIST 1 /* normal persist */ |
27 |
|
#endif |
28 |
|
|
29 |
|
char *progname; /* argv[0] */ |
90 |
– |
|
30 |
|
char *octname; /* octree name */ |
92 |
– |
|
31 |
|
char *sigerr[NSIG]; /* signal error messages */ |
94 |
– |
|
32 |
|
char *shm_boundary = NULL; /* boundary of shared memory */ |
96 |
– |
|
33 |
|
char *errfile = NULL; /* error output file */ |
34 |
|
|
35 |
|
extern time_t time(); |
49 |
|
|
50 |
|
extern double mblur; /* motion blur parameter */ |
51 |
|
|
52 |
< |
void onsig(); |
117 |
< |
void sigdie(); |
118 |
< |
void printdefaults(); |
52 |
> |
extern double dblur; /* depth-of-field blur parameter */ |
53 |
|
|
54 |
+ |
static void onsig(int signo); |
55 |
+ |
static void sigdie(int signo, char *msg); |
56 |
+ |
static void printdefaults(void); |
57 |
|
|
58 |
+ |
|
59 |
|
int |
60 |
< |
main(argc, argv) |
123 |
< |
int argc; |
124 |
< |
char *argv[]; |
60 |
> |
main(int argc, char *argv[]) |
61 |
|
{ |
62 |
|
#define check(ol,al) if (argv[i][ol] || \ |
63 |
|
badarg(argc-i-1,argv+i+1,al)) \ |
154 |
|
check(3,"f"); |
155 |
|
mblur = atof(argv[++i]); |
156 |
|
break; |
157 |
+ |
case 'd': /* aperture */ |
158 |
+ |
check(3,"f"); |
159 |
+ |
dblur = atof(argv[++i]); |
160 |
+ |
break; |
161 |
|
default: |
162 |
|
goto badopt; |
163 |
|
} |
226 |
|
/* initialize object types */ |
227 |
|
initotypes(); |
228 |
|
/* initialize urand */ |
229 |
+ |
srandom(rand_samp ? (long)time(0) : 0L); |
230 |
|
initurand(2048); |
231 |
|
/* set up signal handling */ |
232 |
|
sigdie(SIGINT, "Interrupt"); |
233 |
+ |
#ifdef SIGHUP |
234 |
|
sigdie(SIGHUP, "Hangup"); |
235 |
+ |
#endif |
236 |
|
sigdie(SIGTERM, "Terminate"); |
237 |
+ |
#ifdef SIGPIPE |
238 |
|
sigdie(SIGPIPE, "Broken pipe"); |
239 |
+ |
#endif |
240 |
+ |
#ifdef SIGALRM |
241 |
|
sigdie(SIGALRM, "Alarm clock"); |
242 |
+ |
#endif |
243 |
|
#ifdef SIGXCPU |
244 |
|
sigdie(SIGXCPU, "CPU limit exceeded"); |
245 |
|
sigdie(SIGXFSZ, "File size exceeded"); |
280 |
|
#endif |
281 |
|
if (outfile != NULL) |
282 |
|
openheader(); |
283 |
< |
#ifdef MSDOS |
284 |
< |
setmode(fileno(stdout), O_BINARY); |
283 |
> |
#ifdef _WIN32 |
284 |
> |
SET_FILE_BINARY(stdout); |
285 |
|
if (octname == NULL) |
286 |
< |
setmode(fileno(stdin), O_BINARY); |
286 |
> |
SET_FILE_BINARY(stdin); |
287 |
|
#endif |
288 |
|
readoct(octname, loadflags, &thescene, NULL); |
289 |
|
nsceneobjs = nobjects; |
291 |
|
if (loadflags & IO_INFO) { /* print header */ |
292 |
|
printargs(i, argv, stdout); |
293 |
|
printf("SOFTWARE= %s\n", VersionID); |
347 |
– |
fputnow(stdout); |
294 |
|
} |
295 |
|
|
296 |
|
marksources(); /* find and mark sources */ |
319 |
|
} |
320 |
|
} |
321 |
|
runagain: |
322 |
< |
if (persist) |
322 |
> |
if (persist) { |
323 |
|
if (outfile == NULL) /* if out to stdout */ |
324 |
|
dupheader(); /* send header */ |
325 |
|
else /* if out to file */ |
326 |
|
duped1 = dup(fileno(stdout)); /* hang onto pipe */ |
327 |
+ |
} |
328 |
|
#endif |
329 |
|
/* batch render picture(s) */ |
330 |
|
rpict(seqstart, outfile, zfile, recover); |
355 |
|
badopt: |
356 |
|
sprintf(errmsg, "command line error at '%s'", argv[i]); |
357 |
|
error(USER, errmsg); |
358 |
+ |
return 1; /* pro forma return */ |
359 |
|
|
360 |
|
#undef check |
361 |
|
#undef bool |
363 |
|
|
364 |
|
|
365 |
|
void |
366 |
< |
wputs(s) /* warning output function */ |
367 |
< |
char *s; |
366 |
> |
wputs( /* warning output function */ |
367 |
> |
char *s |
368 |
> |
) |
369 |
|
{ |
370 |
|
int lasterrno = errno; |
371 |
|
eputs(s); |
374 |
|
|
375 |
|
|
376 |
|
void |
377 |
< |
eputs(s) /* put string to stderr */ |
378 |
< |
register char *s; |
377 |
> |
eputs( /* put string to stderr */ |
378 |
> |
register char *s |
379 |
> |
) |
380 |
|
{ |
381 |
|
static int midline = 0; |
382 |
|
|
394 |
|
} |
395 |
|
|
396 |
|
|
397 |
< |
void |
398 |
< |
onsig(signo) /* fatal signal */ |
399 |
< |
int signo; |
397 |
> |
static void |
398 |
> |
onsig( /* fatal signal */ |
399 |
> |
int signo |
400 |
> |
) |
401 |
|
{ |
402 |
|
static int gotsig = 0; |
403 |
|
|
404 |
|
if (gotsig++) /* two signals and we're gone! */ |
405 |
|
_exit(signo); |
406 |
|
|
407 |
+ |
#ifdef SIGALRM /* XXX how critical is this? */ |
408 |
|
alarm(15); /* allow 15 seconds to clean up */ |
409 |
|
signal(SIGALRM, SIG_DFL); /* make certain we do die */ |
410 |
+ |
#endif |
411 |
|
eputs("signal - "); |
412 |
|
eputs(sigerr[signo]); |
413 |
|
eputs("\n"); |
415 |
|
} |
416 |
|
|
417 |
|
|
418 |
< |
void |
419 |
< |
sigdie(signo, msg) /* set fatal signal */ |
420 |
< |
int signo; |
421 |
< |
char *msg; |
418 |
> |
static void |
419 |
> |
sigdie( /* set fatal signal */ |
420 |
> |
int signo, |
421 |
> |
char *msg |
422 |
> |
) |
423 |
|
{ |
424 |
|
if (signal(signo, onsig) == SIG_IGN) |
425 |
|
signal(signo, SIG_IGN); |
427 |
|
} |
428 |
|
|
429 |
|
|
430 |
< |
void |
431 |
< |
printdefaults() /* print default values to stdout */ |
430 |
> |
static void |
431 |
> |
printdefaults(void) /* print default values to stdout */ |
432 |
|
{ |
479 |
– |
register char *cp; |
480 |
– |
|
433 |
|
printf("-vt%c\t\t\t\t# view type %s\n", ourview.type, |
434 |
|
ourview.type==VT_PER ? "perspective" : |
435 |
|
ourview.type==VT_PAR ? "parallel" : |
454 |
|
printf("-pa %f\t\t\t# pixel aspect ratio\n", pixaspect); |
455 |
|
printf("-pj %f\t\t\t# pixel jitter\n", dstrpix); |
456 |
|
printf("-pm %f\t\t\t# pixel motion\n", mblur); |
457 |
+ |
printf("-pd %f\t\t\t# pixel depth-of-field\n", dblur); |
458 |
|
printf("-ps %-9d\t\t\t# pixel sample\n", psample); |
459 |
|
printf("-pt %f\t\t\t# pixel threshold\n", maxdiff); |
460 |
|
printf("-t %-9d\t\t\t# time between reports\n", ralrm); |