--- ray/src/util/rad.c 2004/09/09 20:08:21 2.77 +++ ray/src/util/rad.c 2008/03/11 12:42:07 2.84 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rad.c,v 2.77 2004/09/09 20:08:21 greg Exp $"; +static const char RCSid[] = "$Id: rad.c,v 2.84 2008/03/11 12:42:07 greg Exp $"; #endif /* * Executive program for oconv, rpict and pfilt @@ -472,7 +472,7 @@ static void oconv(void) /* run oconv and mkillum if necessary */ { static char illumtmp[] = "ilXXXXXX"; - char combuf[PATH_MAX], ocopts[64], mkopts[64]; + char combuf[PATH_MAX], ocopts[64], mkopts[1024]; oconvopts(ocopts); /* get options */ if (octreedate < scenedate) { /* check date on original octree */ @@ -599,12 +599,17 @@ oconvopts( /* get oconv options */ static void mkillumopts( /* get mkillum options */ - register char *mo + char *mo ) { /* BEWARE: This may be called via setdefaults(), so no assumptions */ - *mo = '\0'; + if (nprocs > 1) { + sprintf(mo, " -n %d", nprocs); + while (*mo) + mo++; + } else + *mo = '\0'; if (vdef(MKILLUM)) addarg(mo, vval(MKILLUM)); } @@ -1007,9 +1012,19 @@ specview( /* get proper view spec from vs */ } else if (*vs == 'z') { zpos = -1; vs++; } - viewtype = 'v'; - if((*vs == 'v') | (*vs == 'l') | (*vs == 'a') | (*vs == 'h') | (*vs == 'c')) + switch (*vs) { + case VT_PER: + case VT_PAR: + case VT_ANG: + case VT_HEM: + case VT_PLS: + case VT_CYL: viewtype = *vs++; + break; + default: + viewtype = VT_PER; + break; + } cp = viewopts; if ((!*vs || isspace(*vs)) && (xpos|ypos|zpos)) { /* got one! */ *cp++ = '-'; *cp++ = 'v'; *cp++ = 't'; *cp++ = viewtype; @@ -1051,19 +1066,20 @@ specview( /* get proper view spec from vs */ } cp = addarg(cp, vup[upax+3]); switch (viewtype) { - case 'v': + case VT_PER: cp = addarg(cp, "-vh 45 -vv 45"); break; - case 'l': + case VT_PAR: d = sqrt(dim[0]*dim[0]+dim[1]*dim[1]+dim[2]*dim[2]); sprintf(cp, " -vh %.2g -vv %.2g", d, d); cp += strlen(cp); break; - case 'a': - case 'h': + case VT_ANG: + case VT_HEM: + case VT_PLS: cp = addarg(cp, "-vh 180 -vv 180"); break; - case 'c': + case VT_CYL: cp = addarg(cp, "-vh 180 -vv 90"); break; } @@ -1140,6 +1156,11 @@ myprintview( /* print out selected view */ VIEW vwr; char buf[128]; register char *cp; +#ifdef _WIN32 +/* XXX Should we allow something like this for all platforms? */ +/* XXX Or is it still required at all? */ +again: +#endif if (vopts == NULL) return(-1); #ifdef _WIN32 @@ -1312,10 +1333,10 @@ rpict( /* run rpict and pfilt for each view */ /* rpict persistent mode */ if (!silent) printf("\t%s\n", combuf); + fflush(stdout); sprintf(combuf, "rpict%s %s %s%s%s %s > %s", rep, rppopt, res, po, opts, oct1name, rawfile); - fflush(stdout); fp = popen(combuf, "w"); if (fp == NULL) goto rperror; @@ -1353,7 +1374,7 @@ rpict( /* run rpict and pfilt for each view */ } wait_process(1); /* wait for children to finish */ if (pfile != NULL) { /* clean up rpict persistent mode */ - int pid; + RT_PID pid; fp = fopen(pfile, "r"); if (fp != NULL) { if (fscanf(fp, "%*s %d", &pid) != 1 || @@ -1396,7 +1417,7 @@ runcom( /* run command */ printf("\t%s\n", cs); if (!nprocs) return(0); - fflush(stdout); /* flush output and pass to shell */ + fflush(NULL); /* flush output and pass to shell */ return(system(cs)); } @@ -1432,7 +1453,7 @@ mvfile( /* move a file */ static int next_process(void) /* fork the next process (max. nprocs) */ { - int child_pid; + RT_PID child_pid; if (nprocs <= 1) return(0); /* it's us or no one */ @@ -1443,7 +1464,7 @@ next_process(void) /* fork the next process (max. np } if (children_running >= nprocs) wait_process(0); /* wait for someone to finish */ - fflush(stdout); + fflush(NULL); /* flush output */ child_pid = fork(); /* split process */ if (child_pid == 0) { /* we're the child */ children_running = -1; @@ -1463,7 +1484,7 @@ wait_process( /* wait for process(es) to finish */ ) { int ourstatus = 0; - int pid, status; + RT_PID pid, status; if (all) all = children_running; @@ -1500,7 +1521,7 @@ int all; } int kill(pid, sig) /* win|unix_process.c should also wait and kill */ -int pid, sig; +RT_PID pid, sig; { return 0; }