--- ray/src/cv/ies2rad.c 2003/11/15 13:29:23 2.23 +++ ray/src/cv/ies2rad.c 2015/08/01 23:27:04 2.27 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: ies2rad.c,v 2.23 2003/11/15 13:29:23 schorsch Exp $"; +static const char RCSid[] = "$Id: ies2rad.c,v 2.27 2015/08/01 23:27:04 greg Exp $"; #endif /* * Convert IES luminaire data to Radiance description @@ -76,6 +76,7 @@ int filerev = FIRSTREV; /* photometric types */ #define PM_C 1 #define PM_B 2 +#define PM_A 3 /* unit types */ #define U_FEET 1 #define U_METERS 2 @@ -338,8 +339,8 @@ initlamps(void) /* set up lamps */ char * stradd( /* add a string at dst */ - register char *dst, - register char *src, + char *dst, + char *src, int sep ) { @@ -391,10 +392,10 @@ libname( /* return library relative name */ char * filename( /* get final component of pathname */ - register char *path + char *path ) { - register char *cp; + char *cp; for (cp = path; *path; path++) if (ISDIRSEP(*path)) @@ -408,7 +409,7 @@ filetrunc( /* truncate filename at end of path */ char *path ) { - register char *p1, *p2; + char *p1, *p2; for (p1 = p2 = path; *p2; p2++) if (ISDIRSEP(*p2)) @@ -425,7 +426,7 @@ tailtrunc( /* truncate tail of filename */ char *name ) { - register char *p1, *p2; + char *p1, *p2; for (p1 = filename(name); *p1 == '.'; p1++) ; @@ -444,7 +445,7 @@ blanktrunc( /* truncate spaces at end of line */ char *s ) { - register char *cp; + char *cp; for (cp = s; *cp; cp++) ; @@ -456,11 +457,11 @@ blanktrunc( /* truncate spaces at end of line */ int k_match( /* header line matches keyword? */ - register char *kwd, - register char *hdl + char *kwd, + char *hdl ) { - if (!*hdl++ == '[') + if (*hdl++ != '[') return(0); while (islower(*hdl) ? toupper(*hdl) == *kwd++ : *hdl == *kwd++) if (!*hdl++) @@ -471,7 +472,7 @@ k_match( /* header line matches keyword? */ char * keyargs( /* return keyword arguments */ - register char *hdl + char *hdl ) { while (*hdl && *hdl++ != ']') @@ -487,7 +488,7 @@ putheader( /* print header */ FILE *out ) { - register int i; + int i; putc('#', out); for (i = 0; i < gargc; i++) { @@ -699,6 +700,11 @@ dosource( /* create source and distribution */ fprintf(stderr, "dosource: bad lamp specification\n"); return(-1); } + if (pmtype != PM_C && pmtype != PM_B) { + fprintf(stderr, "dosource: unsupported photometric type (%d)\n", + pmtype); + return(-1); + } sinf->mult = multiplier*mult*bfactor*pfactor; if (nangles[0] < 2 || nangles[1] < 1) { fprintf(stderr, "dosource: too few measured angles\n"); @@ -736,8 +742,8 @@ dosource( /* create source and distribution */ fprintf(out, "7 "); else fprintf(out, "5 "); - dolower = (bounds[0][0] < 90.); - doupper = (bounds[0][1] > 90.); + dolower = (bounds[0][0] < 90.-FTINY); + doupper = (bounds[0][1] > 90.+FTINY); dosides = (doupper & dolower && sinf->h > MINDIM); fprintf(out, "%s %s source.cal ", sinf->type==SPHERE ? "corr" : @@ -750,7 +756,7 @@ dosource( /* create source and distribution */ else fprintf(out, "srcB_horiz "); fprintf(out, "srcB_vert "); - } else /* pmtype == PM_A */ { + } else /* pmtype == PM_C */ { if (nangles[1] >= 2) { d1 = bounds[1][1] - bounds[1][0]; if (d1 <= 90.+FTINY) @@ -828,7 +834,7 @@ putsource( /* put out source */ int makeshape( /* make source shape */ - register SRCINFO *shp, + SRCINFO *shp, double width, double length, double height @@ -897,7 +903,7 @@ putrectsrc( /* rectangular source */ void putsides( /* put out sides of box */ - register SRCINFO *shp, + SRCINFO *shp, FILE *fp, char *mod, char *name @@ -933,7 +939,7 @@ putrect( /* put out a rectangle */ void putpoint( /* put out a point */ - register SRCINFO *shp, + SRCINFO *shp, FILE *fp, int p ) @@ -949,7 +955,7 @@ putpoint( /* put out a point */ void putdisksrc( /* put out a disk source */ - register SRCINFO *shp, + SRCINFO *shp, FILE *fp, char *mod, char *name, @@ -974,7 +980,7 @@ putdisksrc( /* put out a disk source */ void putcyl( /* put out a cylinder */ - register SRCINFO *shp, + SRCINFO *shp, FILE *fp, char *mod, char *name @@ -1012,7 +1018,7 @@ cvdata( /* convert data */ ) { double *pt[4]; - register int i, j; + int i, j; double val; int total; @@ -1070,12 +1076,12 @@ cvdata( /* convert data */ char * getword( /* scan a word from fp */ - register FILE *fp + FILE *fp ) { static char wrd[RMAXWORD]; - register char *cp; - register int c; + char *cp; + int c; while (isspace(c=getc(fp))) ; @@ -1123,13 +1129,13 @@ cvtflt( /* convert a word to a double */ int cvgeometry( char *inpname, - register SRCINFO *sinf, + SRCINFO *sinf, char *outname, FILE *outfp /* close output file upon return */ ) { char buf[256]; - register char *cp; + char *cp; if (inpname == NULL || !inpname[0]) { /* no geometry file */ fclose(outfp); @@ -1139,7 +1145,7 @@ cvgeometry( strcpy(buf, "mgf2rad "); /* build mgf2rad command */ cp = buf+8; if (!FEQ(sinf->mult, 1.0)) { - sprintf(cp, "-m %f ", sinf->mult); + sprintf(cp, "-e %f ", sinf->mult); cp += strlen(cp); } sprintf(cp, "-g %f %s ",