1 |
– |
/* Copyright (c) 1996 Regents of the University of California */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
6 |
– |
|
4 |
|
/* |
5 |
|
* Convert IES luminaire data to Radiance description |
6 |
|
* |
7 |
|
* 07Apr90 Greg Ward |
8 |
+ |
* |
9 |
+ |
* Fixed correction factor for flat sources 29Oct2001 GW |
10 |
|
*/ |
11 |
|
|
12 |
|
#include <stdio.h> |
13 |
+ |
#include <string.h> |
14 |
|
#include <math.h> |
15 |
|
#include <sys/types.h> |
16 |
|
#include <ctype.h> |
17 |
+ |
|
18 |
+ |
#include "rtio.h" |
19 |
|
#include "color.h" |
20 |
|
#include "paths.h" |
21 |
|
|
81 |
|
#define U_METERS 2 |
82 |
|
/* string lengths */ |
83 |
|
#define MAXLINE 132 |
84 |
< |
#define MAXWORD 76 |
84 |
> |
#define RMAXWORD 76 |
85 |
|
/* file types */ |
86 |
|
#define T_RAD ".rad" |
87 |
|
#define T_DST ".dat" |
126 |
|
int gargc; /* global argc (minus filenames) */ |
127 |
|
char **gargv; /* global argv */ |
128 |
|
|
127 |
– |
extern char *strcpy(), *strcat(), *stradd(), *tailtrunc(), *filetrunc(), |
128 |
– |
*filename(), *libname(), *fullname(), *malloc(), |
129 |
– |
*getword(), *atos(); |
130 |
– |
extern float *matchlamp(); |
131 |
– |
extern time_t fdate(); |
129 |
|
|
130 |
|
#define scnint(fp,ip) cvtint(ip,getword(fp)) |
131 |
|
#define scnflt(fp,rp) cvtflt(rp,getword(fp)) |
132 |
|
#define isint isflt /* IES allows real as integer */ |
133 |
|
|
134 |
|
|
135 |
< |
main(argc, argv) |
136 |
< |
int argc; |
137 |
< |
char *argv[]; |
135 |
> |
static int ies2rad(char *inpname, char *outname); |
136 |
> |
static void initlamps(void); |
137 |
> |
static int dosource(SRCINFO *sinf, FILE *in, FILE *out, char *mod, char *name); |
138 |
> |
static int dotilt(FILE *in, FILE *out, char *dir, char *tltspec, |
139 |
> |
char *dfltname, char *tltid); |
140 |
> |
static int cvgeometry(char *inpname, SRCINFO *sinf, char *outname, FILE *outfp); |
141 |
> |
static int cvtint(int *ip, char *wrd); |
142 |
> |
static int cvdata(FILE *in, FILE *out, int ndim, int npts[], double mult, |
143 |
> |
double lim[][2]); |
144 |
> |
static int cvtflt(double *rp, char *wrd); |
145 |
> |
static int makeshape(SRCINFO *shp, double width, double length, double height); |
146 |
> |
static int putsource(SRCINFO *shp, FILE *fp, char *mod, char *name, |
147 |
> |
int dolower, int doupper, int dosides); |
148 |
> |
static void putrectsrc(SRCINFO *shp, FILE *fp, char *mod, char *name, int up); |
149 |
> |
static void putsides(SRCINFO *shp, FILE *fp, char *mod, char *name); |
150 |
> |
static void putdisksrc(SRCINFO *shp, FILE *fp, char *mod, char *name, int up); |
151 |
> |
static void putspheresrc(SRCINFO *shp, FILE *fp, char *mod, char *name); |
152 |
> |
static void putrect(SRCINFO *shp, FILE *fp, char *mod, char *name, char *suffix, |
153 |
> |
int a, int b, int c, int d); |
154 |
> |
static void putpoint(SRCINFO *shp, FILE *fp, int p); |
155 |
> |
static void putcyl(SRCINFO *shp, FILE *fp, char *mod, char *name); |
156 |
> |
static char * tailtrunc(char *name); |
157 |
> |
static char * filename(char *path); |
158 |
> |
static char * libname(char *path, char *fname, char *suffix); |
159 |
> |
static char * getword(FILE *fp); |
160 |
> |
static char * fullnam(char *path, char *fname, char *suffix); |
161 |
> |
|
162 |
> |
|
163 |
> |
int |
164 |
> |
main( |
165 |
> |
int argc, |
166 |
> |
char *argv[] |
167 |
> |
) |
168 |
|
{ |
169 |
|
char *outfile = NULL; |
170 |
|
int status; |
171 |
< |
char outname[MAXWORD]; |
171 |
> |
char outname[RMAXWORD]; |
172 |
|
double d1; |
173 |
|
int i; |
174 |
|
|
295 |
|
exit(1); |
296 |
|
} |
297 |
|
|
298 |
< |
|
299 |
< |
initlamps() /* set up lamps */ |
298 |
> |
void |
299 |
> |
initlamps(void) /* set up lamps */ |
300 |
|
{ |
301 |
|
float *lcol; |
302 |
|
int status; |
337 |
|
|
338 |
|
|
339 |
|
char * |
340 |
< |
stradd(dst, src, sep) /* add a string at dst */ |
341 |
< |
register char *dst, *src; |
342 |
< |
int sep; |
340 |
> |
stradd( /* add a string at dst */ |
341 |
> |
register char *dst, |
342 |
> |
register char *src, |
343 |
> |
int sep |
344 |
> |
) |
345 |
|
{ |
346 |
|
if (src && *src) { |
347 |
|
do |
356 |
|
|
357 |
|
|
358 |
|
char * |
359 |
< |
fullname(path, fname, suffix) /* return full path name */ |
360 |
< |
char *path, *fname, *suffix; |
359 |
> |
fullnam( /* return full path name */ |
360 |
> |
char *path, |
361 |
> |
char *fname, |
362 |
> |
char *suffix |
363 |
> |
) |
364 |
|
{ |
365 |
|
if (prefdir != NULL && abspath(prefdir)) |
366 |
|
libname(path, fname, suffix); |
374 |
|
|
375 |
|
|
376 |
|
char * |
377 |
< |
libname(path, fname, suffix) /* return library relative name */ |
378 |
< |
char *path, *fname, *suffix; |
377 |
> |
libname( /* return library relative name */ |
378 |
> |
char *path, |
379 |
> |
char *fname, |
380 |
> |
char *suffix |
381 |
> |
) |
382 |
|
{ |
383 |
|
if (abspath(fname)) |
384 |
|
strcpy(stradd(path, fname, 0), suffix); |
390 |
|
|
391 |
|
|
392 |
|
char * |
393 |
< |
filename(path) /* get final component of pathname */ |
394 |
< |
register char *path; |
393 |
> |
filename( /* get final component of pathname */ |
394 |
> |
register char *path |
395 |
> |
) |
396 |
|
{ |
397 |
|
register char *cp; |
398 |
|
|
404 |
|
|
405 |
|
|
406 |
|
char * |
407 |
< |
filetrunc(path) /* truncate filename at end of path */ |
408 |
< |
char *path; |
407 |
> |
filetrunc( /* truncate filename at end of path */ |
408 |
> |
char *path |
409 |
> |
) |
410 |
|
{ |
411 |
|
register char *p1, *p2; |
412 |
|
|
421 |
|
|
422 |
|
|
423 |
|
char * |
424 |
< |
tailtrunc(name) /* truncate tail of filename */ |
425 |
< |
char *name; |
424 |
> |
tailtrunc( /* truncate tail of filename */ |
425 |
> |
char *name |
426 |
> |
) |
427 |
|
{ |
428 |
|
register char *p1, *p2; |
429 |
|
|
439 |
|
} |
440 |
|
|
441 |
|
|
442 |
< |
blanktrunc(s) /* truncate spaces at end of line */ |
443 |
< |
char *s; |
442 |
> |
void |
443 |
> |
blanktrunc( /* truncate spaces at end of line */ |
444 |
> |
char *s |
445 |
> |
) |
446 |
|
{ |
447 |
|
register char *cp; |
448 |
|
|
454 |
|
} |
455 |
|
|
456 |
|
|
457 |
< |
k_match(kwd, hdl) /* header line matches keyword? */ |
458 |
< |
register char *kwd, *hdl; |
457 |
> |
int |
458 |
> |
k_match( /* header line matches keyword? */ |
459 |
> |
register char *kwd, |
460 |
> |
register char *hdl |
461 |
> |
) |
462 |
|
{ |
463 |
|
if (!*hdl++ == '[') |
464 |
|
return(0); |
465 |
|
while (islower(*hdl) ? toupper(*hdl) == *kwd++ : *hdl == *kwd++) |
466 |
|
if (!*hdl++) |
467 |
|
return(0); |
468 |
< |
return(!*kwd & *hdl == ']'); |
468 |
> |
return((!*kwd) & (*hdl == ']')); |
469 |
|
} |
470 |
|
|
471 |
|
|
472 |
|
char * |
473 |
< |
keyargs(hdl) /* return keyword arguments */ |
474 |
< |
register char *hdl; |
473 |
> |
keyargs( /* return keyword arguments */ |
474 |
> |
register char *hdl |
475 |
> |
) |
476 |
|
{ |
477 |
|
while (*hdl && *hdl++ != ']') |
478 |
|
; |
482 |
|
} |
483 |
|
|
484 |
|
|
485 |
< |
putheader(out) /* print header */ |
486 |
< |
FILE *out; |
485 |
> |
void |
486 |
> |
putheader( /* print header */ |
487 |
> |
FILE *out |
488 |
> |
) |
489 |
|
{ |
490 |
|
register int i; |
491 |
|
|
500 |
|
} |
501 |
|
|
502 |
|
|
503 |
< |
ies2rad(inpname, outname) /* convert IES file */ |
504 |
< |
char *inpname, *outname; |
503 |
> |
int |
504 |
> |
ies2rad( /* convert IES file */ |
505 |
> |
char *inpname, |
506 |
> |
char *outname |
507 |
> |
) |
508 |
|
{ |
509 |
|
SRCINFO srcinfo; |
510 |
< |
char buf[MAXLINE], tltid[MAXWORD]; |
510 |
> |
char buf[MAXLINE], tltid[RMAXWORD]; |
511 |
|
char geomfile[128]; |
512 |
|
FILE *inpfp, *outfp; |
513 |
|
int lineno = 0; |
523 |
|
} |
524 |
|
if (out2stdout) |
525 |
|
outfp = stdout; |
526 |
< |
else if ((outfp = fopen(fullname(buf,outname,T_RAD), "w")) == NULL) { |
526 |
> |
else if ((outfp = fopen(fullnam(buf,outname,T_RAD), "w")) == NULL) { |
527 |
|
perror(buf); |
528 |
|
fclose(inpfp); |
529 |
|
return(-1); |
566 |
|
fprintf(stderr, "%s: not in IES format\n", inpname); |
567 |
|
goto readerr; |
568 |
|
} |
569 |
< |
atos(tltid, MAXWORD, buf+TLTSTRLEN); |
569 |
> |
atos(tltid, RMAXWORD, buf+TLTSTRLEN); |
570 |
|
if (inpfp == stdin) |
571 |
|
buf[0] = '\0'; |
572 |
|
else |
589 |
|
readerr: |
590 |
|
fclose(inpfp); |
591 |
|
fclose(outfp); |
592 |
< |
unlink(fullname(buf,outname,T_RAD)); |
592 |
> |
unlink(fullnam(buf,outname,T_RAD)); |
593 |
|
return(-1); |
594 |
|
} |
595 |
|
|
596 |
|
|
597 |
< |
dotilt(in, out, dir, tltspec, dfltname, tltid) /* convert tilt data */ |
598 |
< |
FILE *in, *out; |
599 |
< |
char *dir, *tltspec, *dfltname, *tltid; |
597 |
> |
int |
598 |
> |
dotilt( /* convert tilt data */ |
599 |
> |
FILE *in, |
600 |
> |
FILE *out, |
601 |
> |
char *dir, |
602 |
> |
char *tltspec, |
603 |
> |
char *dfltname, |
604 |
> |
char *tltid |
605 |
> |
) |
606 |
|
{ |
607 |
|
int nangles, tlt_type; |
608 |
< |
double minmax[2]; |
609 |
< |
char buf[MAXPATH], tltname[MAXWORD]; |
608 |
> |
double minmax[1][2]; |
609 |
> |
char buf[PATH_MAX], tltname[RMAXWORD]; |
610 |
|
FILE *datin, *datout; |
611 |
|
|
612 |
|
if (!strcmp(tltspec, TLTNONE)) { |
627 |
|
tailtrunc(strcpy(tltname,filename(tltspec))); |
628 |
|
} |
629 |
|
if (datin != NULL) { |
630 |
< |
if ((datout = fopen(fullname(buf,tltname,T_TLT),"w")) == NULL) { |
630 |
> |
if ((datout = fopen(fullnam(buf,tltname,T_TLT),"w")) == NULL) { |
631 |
|
perror(buf); |
632 |
|
if (datin != in) |
633 |
|
fclose(datin); |
639 |
|
fclose(datout); |
640 |
|
if (datin != in) |
641 |
|
fclose(datin); |
642 |
< |
unlink(fullname(buf,tltname,T_TLT)); |
642 |
> |
unlink(fullnam(buf,tltname,T_TLT)); |
643 |
|
return(-1); |
644 |
|
} |
645 |
|
fclose(datout); |
651 |
|
switch (tlt_type) { |
652 |
|
case TLT_VERT: /* vertical */ |
653 |
|
fprintf(out, "4 noop %s tilt.cal %s\n", buf, |
654 |
< |
minmax[1]>90.+FTINY ? "tilt_ang" : "tilt_ang2"); |
654 |
> |
minmax[0][1]>90.+FTINY ? "tilt_ang" : "tilt_ang2"); |
655 |
|
break; |
656 |
|
case TLT_H0: /* horiz. in 0 deg. plane */ |
657 |
|
fprintf(out, "6 noop %s tilt.cal %s -rz 90\n", buf, |
658 |
< |
minmax[1]>90.+FTINY ? "tilt_xang" : "tilt_xang2"); |
658 |
> |
minmax[0][1]>90.+FTINY ? "tilt_xang" : "tilt_xang2"); |
659 |
|
break; |
660 |
|
case TLT_H90: |
661 |
|
fprintf(out, "4 noop %s tilt.cal %s\n", buf, |
662 |
< |
minmax[1]>90.+FTINY ? "tilt_xang" : "tilt_xang2"); |
662 |
> |
minmax[0][1]>90.+FTINY ? "tilt_xang" : "tilt_xang2"); |
663 |
|
break; |
664 |
|
default: |
665 |
|
fprintf(stderr, |
673 |
|
} |
674 |
|
|
675 |
|
|
676 |
< |
dosource(sinf, in, out, mod, name) /* create source and distribution */ |
677 |
< |
SRCINFO *sinf; |
678 |
< |
FILE *in, *out; |
679 |
< |
char *mod, *name; |
676 |
> |
int |
677 |
> |
dosource( /* create source and distribution */ |
678 |
> |
SRCINFO *sinf, |
679 |
> |
FILE *in, |
680 |
> |
FILE *out, |
681 |
> |
char *mod, |
682 |
> |
char *name |
683 |
> |
) |
684 |
|
{ |
685 |
< |
char buf[MAXPATH], id[MAXWORD]; |
685 |
> |
char buf[PATH_MAX], id[RMAXWORD]; |
686 |
|
FILE *datout; |
687 |
|
double mult, bfactor, pfactor, width, length, height, wattage; |
688 |
|
double bounds[2][2]; |
689 |
|
int nangles[2], pmtype, unitype; |
690 |
|
double d1; |
691 |
+ |
int doupper, dolower, dosides; |
692 |
|
|
693 |
|
if (!isint(getword(in)) || !isflt(getword(in)) || !scnflt(in,&mult) |
694 |
|
|| !scnint(in,&nangles[0]) || !scnint(in,&nangles[1]) |
713 |
|
fprintf(stderr, "dosource: illegal source dimensions"); |
714 |
|
return(-1); |
715 |
|
} |
716 |
< |
if ((datout = fopen(fullname(buf,name,T_DST), "w")) == NULL) { |
716 |
> |
if ((datout = fopen(fullnam(buf,name,T_DST), "w")) == NULL) { |
717 |
|
perror(buf); |
718 |
|
return(-1); |
719 |
|
} |
720 |
|
if (cvdata(in, datout, 2, nangles, 1./WHTEFFICACY, bounds) != 0) { |
721 |
|
fprintf(stderr, "dosource: bad distribution data\n"); |
722 |
|
fclose(datout); |
723 |
< |
unlink(fullname(buf,name,T_DST)); |
723 |
> |
unlink(fullnam(buf,name,T_DST)); |
724 |
|
return(-1); |
725 |
|
} |
726 |
|
fclose(datout); |
736 |
|
fprintf(out, "7 "); |
737 |
|
else |
738 |
|
fprintf(out, "5 "); |
739 |
+ |
dolower = (bounds[0][0] < 90.); |
740 |
+ |
doupper = (bounds[0][1] > 90.); |
741 |
+ |
dosides = (doupper & dolower && sinf->h > MINDIM); |
742 |
|
fprintf(out, "%s %s source.cal ", |
743 |
|
sinf->type==SPHERE ? "corr" : |
744 |
+ |
!dosides ? "flatcorr" : |
745 |
|
sinf->type==DISK ? "cylcorr" : "boxcorr", |
746 |
|
libname(buf,name,T_DST)); |
747 |
|
if (pmtype == PM_B) { |
750 |
|
else |
751 |
|
fprintf(out, "srcB_horiz "); |
752 |
|
fprintf(out, "srcB_vert "); |
753 |
< |
} else { |
753 |
> |
} else /* pmtype == PM_A */ { |
754 |
|
if (nangles[1] >= 2) { |
755 |
|
d1 = bounds[1][1] - bounds[1][0]; |
756 |
|
if (d1 <= 90.+FTINY) |
757 |
|
fprintf(out, "src_phi4 "); |
758 |
< |
else if (d1 <= 180.+FTINY) |
759 |
< |
fprintf(out, "src_phi2 "); |
760 |
< |
else |
758 |
> |
else if (d1 <= 180.+FTINY) { |
759 |
> |
if (FEQ(bounds[1][0],90.)) |
760 |
> |
fprintf(out, "src_phi2+90 "); |
761 |
> |
else |
762 |
> |
fprintf(out, "src_phi2 "); |
763 |
> |
} else |
764 |
|
fprintf(out, "src_phi "); |
765 |
|
fprintf(out, "src_theta "); |
766 |
|
if (FEQ(bounds[1][0],90.) && FEQ(bounds[1][1],270.)) |
768 |
|
} else |
769 |
|
fprintf(out, "src_theta "); |
770 |
|
} |
771 |
< |
if (sinf->type == SPHERE) |
771 |
> |
if (!dosides || sinf->type == SPHERE) |
772 |
|
fprintf(out, "\n0\n1 %g\n", sinf->mult/sinf->area); |
773 |
|
else if (sinf->type == DISK) |
774 |
|
fprintf(out, "\n0\n3 %g %g %g\n", sinf->mult, |
775 |
< |
sinf->l, sinf->h); |
775 |
> |
sinf->w, sinf->h); |
776 |
|
else |
777 |
|
fprintf(out, "\n0\n4 %g %g %g %g\n", sinf->mult, |
778 |
|
sinf->l, sinf->w, sinf->h); |
779 |
|
if (putsource(sinf, out, id, filename(name), |
780 |
< |
bounds[0][0]<90., bounds[0][1]>90.) != 0) |
780 |
> |
dolower, doupper, dosides) != 0) |
781 |
|
return(-1); |
782 |
|
return(0); |
783 |
|
} |
784 |
|
|
785 |
|
|
786 |
< |
putsource(shp, fp, mod, name, dolower, doupper) /* put out source */ |
787 |
< |
SRCINFO *shp; |
788 |
< |
FILE *fp; |
789 |
< |
char *mod, *name; |
790 |
< |
int dolower, doupper; |
786 |
> |
int |
787 |
> |
putsource( /* put out source */ |
788 |
> |
SRCINFO *shp, |
789 |
> |
FILE *fp, |
790 |
> |
char *mod, |
791 |
> |
char *name, |
792 |
> |
int dolower, |
793 |
> |
int doupper, |
794 |
> |
int dosides |
795 |
> |
) |
796 |
|
{ |
797 |
< |
int dosides = doupper && dolower && shp->h > MINDIM; |
726 |
< |
char lname[MAXWORD]; |
797 |
> |
char lname[RMAXWORD]; |
798 |
|
|
799 |
|
strcat(strcpy(lname, name), "_light"); |
800 |
|
fprintf(fp, "\n%s %s %s\n", mod, |
826 |
|
} |
827 |
|
|
828 |
|
|
829 |
< |
makeshape(shp, width, length, height) /* make source shape */ |
830 |
< |
register SRCINFO *shp; |
831 |
< |
double width, length, height; |
829 |
> |
int |
830 |
> |
makeshape( /* make source shape */ |
831 |
> |
register SRCINFO *shp, |
832 |
> |
double width, |
833 |
> |
double length, |
834 |
> |
double height |
835 |
> |
) |
836 |
|
{ |
837 |
|
if (illumrad/meters2out >= MINDIM/2.) { |
838 |
|
shp->isillum = 1; |
879 |
|
} |
880 |
|
|
881 |
|
|
882 |
< |
putrectsrc(shp, fp, mod, name, up) /* rectangular source */ |
883 |
< |
SRCINFO *shp; |
884 |
< |
FILE *fp; |
885 |
< |
char *mod, *name; |
886 |
< |
int up; |
882 |
> |
void |
883 |
> |
putrectsrc( /* rectangular source */ |
884 |
> |
SRCINFO *shp, |
885 |
> |
FILE *fp, |
886 |
> |
char *mod, |
887 |
> |
char *name, |
888 |
> |
int up |
889 |
> |
) |
890 |
|
{ |
891 |
|
if (up) |
892 |
|
putrect(shp, fp, mod, name, ".u", 4, 5, 7, 6); |
895 |
|
} |
896 |
|
|
897 |
|
|
898 |
< |
putsides(shp, fp, mod, name) /* put out sides of box */ |
899 |
< |
register SRCINFO *shp; |
900 |
< |
FILE *fp; |
901 |
< |
char *mod, *name; |
898 |
> |
void |
899 |
> |
putsides( /* put out sides of box */ |
900 |
> |
register SRCINFO *shp, |
901 |
> |
FILE *fp, |
902 |
> |
char *mod, |
903 |
> |
char *name |
904 |
> |
) |
905 |
|
{ |
906 |
|
putrect(shp, fp, mod, name, ".1", 0, 1, 5, 4); |
907 |
|
putrect(shp, fp, mod, name, ".2", 1, 3, 7, 5); |
910 |
|
} |
911 |
|
|
912 |
|
|
913 |
< |
putrect(shp, fp, mod, name, suffix, a, b, c, d) /* put out a rectangle */ |
914 |
< |
SRCINFO *shp; |
915 |
< |
FILE *fp; |
916 |
< |
char *mod, *name, *suffix; |
917 |
< |
int a, b, c, d; |
913 |
> |
void |
914 |
> |
putrect( /* put out a rectangle */ |
915 |
> |
SRCINFO *shp, |
916 |
> |
FILE *fp, |
917 |
> |
char *mod, |
918 |
> |
char *name, |
919 |
> |
char *suffix, |
920 |
> |
int a, |
921 |
> |
int b, |
922 |
> |
int c, |
923 |
> |
int d |
924 |
> |
) |
925 |
|
{ |
926 |
|
fprintf(fp, "\n%s polygon %s%s\n0\n0\n12\n", mod, name, suffix); |
927 |
|
putpoint(shp, fp, a); |
931 |
|
} |
932 |
|
|
933 |
|
|
934 |
< |
putpoint(shp, fp, p) /* put out a point */ |
935 |
< |
register SRCINFO *shp; |
936 |
< |
FILE *fp; |
937 |
< |
int p; |
934 |
> |
void |
935 |
> |
putpoint( /* put out a point */ |
936 |
> |
register SRCINFO *shp, |
937 |
> |
FILE *fp, |
938 |
> |
int p |
939 |
> |
) |
940 |
|
{ |
941 |
|
static double mult[2] = {-.5, .5}; |
942 |
|
|
947 |
|
} |
948 |
|
|
949 |
|
|
950 |
< |
putdisksrc(shp, fp, mod, name, up) /* put out a disk source */ |
951 |
< |
register SRCINFO *shp; |
952 |
< |
FILE *fp; |
953 |
< |
char *mod, *name; |
954 |
< |
int up; |
950 |
> |
void |
951 |
> |
putdisksrc( /* put out a disk source */ |
952 |
> |
register SRCINFO *shp, |
953 |
> |
FILE *fp, |
954 |
> |
char *mod, |
955 |
> |
char *name, |
956 |
> |
int up |
957 |
> |
) |
958 |
|
{ |
959 |
|
if (up) { |
960 |
|
fprintf(fp, "\n%s ring %s.u\n", mod, name); |
972 |
|
} |
973 |
|
|
974 |
|
|
975 |
< |
putcyl(shp, fp, mod, name) /* put out a cylinder */ |
976 |
< |
register SRCINFO *shp; |
977 |
< |
FILE *fp; |
978 |
< |
char *mod, *name; |
975 |
> |
void |
976 |
> |
putcyl( /* put out a cylinder */ |
977 |
> |
register SRCINFO *shp, |
978 |
> |
FILE *fp, |
979 |
> |
char *mod, |
980 |
> |
char *name |
981 |
> |
) |
982 |
|
{ |
983 |
|
fprintf(fp, "\n%s cylinder %s.c\n", mod, name); |
984 |
|
fprintf(fp, "0\n0\n7\n"); |
988 |
|
} |
989 |
|
|
990 |
|
|
991 |
< |
putspheresrc(shp, fp, mod, name) /* put out a sphere source */ |
992 |
< |
SRCINFO *shp; |
993 |
< |
FILE *fp; |
994 |
< |
char *mod, *name; |
991 |
> |
void |
992 |
> |
putspheresrc( /* put out a sphere source */ |
993 |
> |
SRCINFO *shp, |
994 |
> |
FILE *fp, |
995 |
> |
char *mod, |
996 |
> |
char *name |
997 |
> |
) |
998 |
|
{ |
999 |
|
fprintf(fp, "\n%s sphere %s.s\n", mod, name); |
1000 |
|
fprintf(fp, "0\n0\n4 0 0 0 %g\n", .5*shp->w*meters2out); |
1001 |
|
} |
1002 |
|
|
1003 |
|
|
1004 |
< |
cvdata(in, out, ndim, npts, mult, lim) /* convert data */ |
1005 |
< |
FILE *in, *out; |
1006 |
< |
int ndim, npts[]; |
1007 |
< |
double mult, lim[][2]; |
1004 |
> |
int |
1005 |
> |
cvdata( /* convert data */ |
1006 |
> |
FILE *in, |
1007 |
> |
FILE *out, |
1008 |
> |
int ndim, |
1009 |
> |
int npts[], |
1010 |
> |
double mult, |
1011 |
> |
double lim[][2] |
1012 |
> |
) |
1013 |
|
{ |
1014 |
|
double *pt[4]; |
1015 |
|
register int i, j; |
1054 |
|
putc('\n', out); |
1055 |
|
} |
1056 |
|
} |
1057 |
< |
free((char *)pt[i]); |
1057 |
> |
free((void *)pt[i]); |
1058 |
|
} |
1059 |
|
for (i = 0; i < total; i++) { |
1060 |
|
if (i%4 == 0) |
1069 |
|
|
1070 |
|
|
1071 |
|
char * |
1072 |
< |
getword(fp) /* scan a word from fp */ |
1073 |
< |
register FILE *fp; |
1072 |
> |
getword( /* scan a word from fp */ |
1073 |
> |
register FILE *fp |
1074 |
> |
) |
1075 |
|
{ |
1076 |
< |
static char word[MAXWORD]; |
1076 |
> |
static char wrd[RMAXWORD]; |
1077 |
|
register char *cp; |
1078 |
|
register int c; |
1079 |
|
|
1080 |
|
while (isspace(c=getc(fp))) |
1081 |
|
; |
1082 |
< |
for (cp = word; c != EOF && cp < word+MAXWORD-1; |
1082 |
> |
for (cp = wrd; c != EOF && cp < wrd+RMAXWORD-1; |
1083 |
|
*cp++ = c, c = getc(fp)) |
1084 |
|
if (isspace(c) || c == ',') { |
1085 |
|
while (isspace(c)) |
1086 |
|
c = getc(fp); |
1087 |
< |
if (c != EOF & c != ',') |
1087 |
> |
if ((c != EOF) & (c != ',')) |
1088 |
|
ungetc(c, fp); |
1089 |
|
*cp = '\0'; |
1090 |
< |
return(word); |
1090 |
> |
return(wrd); |
1091 |
|
} |
1092 |
|
*cp = '\0'; |
1093 |
< |
return(cp > word ? word : NULL); |
1093 |
> |
return(cp > wrd ? wrd : NULL); |
1094 |
|
} |
1095 |
|
|
1096 |
|
|
1097 |
< |
cvtint(ip, word) /* convert a word to an integer */ |
1098 |
< |
int *ip; |
1099 |
< |
char *word; |
1097 |
> |
int |
1098 |
> |
cvtint( /* convert a word to an integer */ |
1099 |
> |
int *ip, |
1100 |
> |
char *wrd |
1101 |
> |
) |
1102 |
|
{ |
1103 |
< |
if (word == NULL || !isint(word)) |
1103 |
> |
if (wrd == NULL || !isint(wrd)) |
1104 |
|
return(0); |
1105 |
< |
*ip = atoi(word); |
1105 |
> |
*ip = atoi(wrd); |
1106 |
|
return(1); |
1107 |
|
} |
1108 |
|
|
1109 |
|
|
1110 |
< |
cvtflt(rp, word) /* convert a word to a double */ |
1111 |
< |
double *rp; |
1112 |
< |
char *word; |
1110 |
> |
int |
1111 |
> |
cvtflt( /* convert a word to a double */ |
1112 |
> |
double *rp, |
1113 |
> |
char *wrd |
1114 |
> |
) |
1115 |
|
{ |
1116 |
< |
if (word == NULL || !isflt(word)) |
1116 |
> |
if (wrd == NULL || !isflt(wrd)) |
1117 |
|
return(0); |
1118 |
< |
*rp = atof(word); |
1118 |
> |
*rp = atof(wrd); |
1119 |
|
return(1); |
1120 |
|
} |
1121 |
|
|
1122 |
|
|
1123 |
< |
cvgeometry(inpname, sinf, outname, outfp) |
1124 |
< |
char *inpname; |
1125 |
< |
register SRCINFO *sinf; |
1126 |
< |
char *outname; |
1127 |
< |
FILE *outfp; /* close output file upon return */ |
1123 |
> |
int |
1124 |
> |
cvgeometry( |
1125 |
> |
char *inpname, |
1126 |
> |
register SRCINFO *sinf, |
1127 |
> |
char *outname, |
1128 |
> |
FILE *outfp /* close output file upon return */ |
1129 |
> |
) |
1130 |
|
{ |
1131 |
|
char buf[256]; |
1132 |
|
register char *cp; |
1149 |
|
if (instantiate) { /* instantiate octree */ |
1150 |
|
strcpy(cp, "| oconv - > "); |
1151 |
|
cp += 12; |
1152 |
< |
fullname(cp,outname,T_OCT); |
1152 |
> |
fullnam(cp,outname,T_OCT); |
1153 |
|
if (fdate(inpname) > fdate(outname) && |
1154 |
|
system(buf)) { /* create octree */ |
1155 |
|
fclose(outfp); |
1173 |
|
fclose(outfp); |
1174 |
|
strcpy(cp, ">> "); /* append works for DOS? */ |
1175 |
|
cp += 3; |
1176 |
< |
fullname(cp,outname,T_RAD); |
1176 |
> |
fullnam(cp,outname,T_RAD); |
1177 |
|
} |
1178 |
|
if (system(buf)) |
1179 |
|
return(-1); |