ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/cv/ies2rad.c
(Generate patch)

Comparing ray/src/cv/ies2rad.c (file contents):
Revision 2.12 by greg, Tue Apr 25 21:37:14 1995 UTC vs.
Revision 2.14 by greg, Tue Jun 18 21:28:52 1996 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1992 Regents of the University of California */
1 > /* Copyright (c) 1996 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 12 | Line 12 | static char SCCSid[] = "$SunId$ LBL";
12  
13   #include <stdio.h>
14   #include <math.h>
15 + #include <sys/types.h>
16   #include <ctype.h>
17   #include "color.h"
18   #include "paths.h"
# Line 108 | Line 109 | float  defcolor[3] = {1.,1.,1.};       /* default lamp color
109   float   *lampcolor = defcolor;          /* pointer to current lamp color */
110   double  multiplier = 1.0;               /* multiplier for all light sources */
111   char    units[64] = "meters";           /* output units */
112 + int     out2stdout = 0;                 /* put out to stdout r.t. file */
113   int     instantiate = 0;                /* instantiate geometry */
114   double  illumrad = 0.0;                 /* radius for illum sphere */
115  
# Line 126 | Line 128 | extern char    *strcpy(), *strcat(), *stradd(), *tailtrun
128                  *filename(), *libname(), *fullname(), *malloc(),
129                  *getword(), *atos();
130   extern float    *matchlamp();
131 + extern time_t   fdate();
132  
133   #define scnint(fp,ip)   cvtint(ip,getword(fp))
134   #define scnflt(fp,rp)   cvtflt(rp,getword(fp))
# Line 203 | Line 206 | char   *argv[];
206                  case 'f':               /* lamp data file */
207                          lampdat = argv[++i];
208                          break;
209 <                case 'o':               /* output file name */
209 >                case 'o':               /* output file root name */
210                          outfile = argv[++i];
211                          break;
212 +                case 's':               /* output to stdout */
213 +                        out2stdout = !out2stdout;
214 +                        break;
215                  case 'i':               /* illum */
216                          illumrad = atof(argv[++i]);
217                          break;
# Line 241 | Line 247 | char   *argv[];
247                          exit(ies2rad(NULL, outfile) == 0 ? 0 : 1);
248                  else if (i == argc-1)
249                          exit(ies2rad(argv[i], outfile) == 0 ? 0 : 1);
250 <                else {
251 <                        fprintf(stderr, "%s: single input file required\n",
246 <                                        argv[0]);
247 <                        exit(1);
248 <                }
250 >                else
251 >                        goto needsingle;
252          } else if (i >= argc) {
253                  fprintf(stderr, "%s: missing output file specification\n",
254                                  argv[0]);
255                  exit(1);
256          }
257 +        if (out2stdout && i != argc-1)
258 +                goto needsingle;
259          status = 0;
260          for ( ; i < argc; i++) {
261                  tailtrunc(strcpy(outname,filename(argv[i])));
# Line 258 | Line 263 | char   *argv[];
263                          status = 1;
264          }
265          exit(status);
266 + needsingle:
267 +        fprintf(stderr, "%s: single input file required\n", argv[0]);
268 +        exit(1);
269   }
270  
271  
# Line 464 | Line 472 | char   *inpname, *outname;
472                  perror(inpname);
473                  return(-1);
474          }
475 <        if ((outfp = fopen(fullname(buf,outname,T_RAD), "w")) == NULL) {
475 >        if (out2stdout)
476 >                outfp = stdout;
477 >        else if ((outfp = fopen(fullname(buf,outname,T_RAD), "w")) == NULL) {
478                  perror(buf);
479                  fclose(inpfp);
480                  return(-1);
# Line 1040 | Line 1050 | FILE   *outfp;                 /* close output file upon return */
1050                  strcpy(cp, "| oconv - > ");
1051                  cp += 12;
1052                  fullname(cp,outname,T_OCT);
1053 <                if (system(buf)) {              /* create octree */
1053 >                if (fdate(inpname) > fdate(outname) &&
1054 >                                system(buf)) {          /* create octree */
1055                          fclose(outfp);
1056                          return(-1);
1057                  }
# Line 1054 | Line 1065 | FILE   *outfp;                 /* close output file upon return */
1065                  fprintf(outfp, "0\n0\n");
1066                  fclose(outfp);
1067          } else {                        /* else append to luminaire file */
1057                fclose(outfp);
1068                  if (!FEQ(meters2out, 1.0)) {    /* apply scalefactor */
1069                          sprintf(cp, "| xform -s %f ", meters2out);
1070                          cp += strlen(cp);
1071                  }
1072 <                strcpy(cp, ">> ");              /* append works for DOS? */
1073 <                cp += 3;
1074 <                fullname(cp,outname,T_RAD);
1072 >                if (!out2stdout) {
1073 >                        fclose(outfp);
1074 >                        strcpy(cp, ">> ");      /* append works for DOS? */
1075 >                        cp += 3;
1076 >                        fullname(cp,outname,T_RAD);
1077 >                }
1078                  if (system(buf))
1079                          return(-1);
1080          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines