1 |
< |
/* Copyright (c) 1991 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1992 Regents of the University of California */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
35 |
|
|
36 |
|
char *idprefix = NULL; /* prefix for object identifiers */ |
37 |
|
|
38 |
< |
#define ALIAS NUMOTYPE /* put alias at end of array */ |
38 |
> |
#define ALIAS NUMOTYPE /* put alias at end of array */ |
39 |
|
|
40 |
< |
#define NUMTYPES (NUMOTYPE+1) /* total number of object types */ |
40 |
> |
#define NUMTYPES (NUMOTYPE+1) /* total number of object types */ |
41 |
|
|
42 |
|
FUN ofun[NUMTYPES] = INIT_OTYPE; /* default types and actions */ |
43 |
|
|
45 |
|
|
46 |
|
extern char *malloc(), *fgetword(); |
47 |
|
|
48 |
< |
#define progname (xav[0]) |
48 |
> |
#define progname (xav[0]) |
49 |
|
|
50 |
|
|
51 |
|
main(argc, argv) /* get transform options and transform file */ |
197 |
|
|
198 |
|
|
199 |
|
xfcomm(fname, fin) /* transform a command */ |
200 |
+ |
char *fname; |
201 |
|
FILE *fin; |
202 |
|
{ |
203 |
|
FILE *popen(); |
208 |
|
|
209 |
|
fgetline(buf, sizeof(buf), fin); |
210 |
|
if (expand) { |
211 |
< |
if (xac > 2) { |
212 |
< |
if ((pin = popen(buf+1, "r")) == NULL) { |
213 |
< |
fprintf(stderr, |
214 |
< |
"%s: (%s): cannot execute \"%s\"\n", |
214 |
< |
progname, fname, buf); |
215 |
< |
exit(1); |
216 |
< |
} |
217 |
< |
xform(buf, pin); |
218 |
< |
pclose(pin); |
219 |
< |
} else { |
220 |
< |
fflush(stdout); |
221 |
< |
system(buf+1); |
211 |
> |
if ((pin = popen(buf+1, "r")) == NULL) { |
212 |
> |
fprintf(stderr, "%s: (%s): cannot execute \"%s\"\n", |
213 |
> |
progname, fname, buf); |
214 |
> |
exit(1); |
215 |
|
} |
216 |
+ |
xform(buf, pin); |
217 |
+ |
pclose(pin); |
218 |
|
} else { |
219 |
|
printf("\n%s", buf); |
220 |
|
if (xac > 1) { |
243 |
|
progname, fname, typ); |
244 |
|
exit(1); |
245 |
|
} |
246 |
< |
if (issurface(fn)) |
246 |
> |
if (ismodifier(fn)) |
247 |
> |
printf("\n%s %s ", nam, typ); |
248 |
> |
else |
249 |
|
printf("\n%s %s ", newmod != NULL ? newmod : nam, |
250 |
|
invert ? ofun[tinvers[fn]].funame : typ); |
254 |
– |
else |
255 |
– |
printf("\n%s %s ", nam, typ); |
251 |
|
/* object name */ |
252 |
|
fgetword(nam, sizeof(nam), fin); |
253 |
< |
if (idprefix != NULL && issurface(fn)) |
259 |
< |
printf("%s.%s\n", idprefix, nam); |
260 |
< |
else |
253 |
> |
if (idprefix == NULL || ismodifier(fn)) |
254 |
|
printf("%s\n", nam); |
255 |
+ |
else |
256 |
+ |
printf("%s.%s\n", idprefix, nam); |
257 |
|
/* transform arguments */ |
258 |
|
if ((*ofun[fn].funp)(fin) < 0) { |
259 |
|
fprintf(stderr, "%s: (%s): bad %s \"%s\"\n", |
267 |
|
FILE *fin; |
268 |
|
{ |
269 |
|
register int i; |
270 |
< |
FUNARGS fa; |
270 |
> |
FUNARGS fa; |
271 |
|
|
272 |
|
if (readfargs(&fa, fin) != 1) |
273 |
|
return(-1); |
276 |
|
for (i = 0; i < fa.nsargs; i++) |
277 |
|
printf(" %s", fa.sarg[i]); |
278 |
|
printf("\n"); |
279 |
< |
#ifdef IARGS |
279 |
> |
#ifdef IARGS |
280 |
|
/* integer arguments */ |
281 |
|
printf("%d", fa.niargs); |
282 |
|
for (i = 0; i < fa.niargs; i++) |
299 |
|
FILE *fin; |
300 |
|
{ |
301 |
|
register int i; |
302 |
< |
FUNARGS fa; |
302 |
> |
int resetarr = 0; |
303 |
> |
FUNARGS fa; |
304 |
|
|
305 |
|
if (readfargs(&fa, fin) != 1) |
306 |
|
return(-1); |
307 |
|
/* string arguments */ |
308 |
< |
printf("%d", fa.nsargs + xac-xfa); |
308 |
> |
if (xac > xfa && strcmp(xav[xfa], "-i")) |
309 |
> |
resetarr = 2; |
310 |
> |
printf("%d", fa.nsargs + resetarr + xac-xfa); |
311 |
|
for (i = 0; i < fa.nsargs; i++) |
312 |
|
printf(" %s", fa.sarg[i]); |
313 |
+ |
if (resetarr) |
314 |
+ |
printf(" -i 1"); |
315 |
|
for (i = xfa; i < xac; i++) /* add xf arguments */ |
316 |
|
printf(" %s", xav[i]); |
317 |
|
printf("\n"); |
318 |
< |
#ifdef IARGS |
318 |
> |
#ifdef IARGS |
319 |
|
/* integer arguments */ |
320 |
|
printf("%d", fa.niargs); |
321 |
|
for (i = 0; i < fa.niargs; i++) |
363 |
|
m_glow(fin) /* transform arguments for proximity light */ |
364 |
|
FILE *fin; |
365 |
|
{ |
366 |
< |
FUNARGS fa; |
366 |
> |
FUNARGS fa; |
367 |
|
|
368 |
|
if (readfargs(&fa, fin) != 1) |
369 |
|
return(-1); |
382 |
|
FILE *fin; |
383 |
|
{ |
384 |
|
FVECT v; |
385 |
< |
FUNARGS fa; |
385 |
> |
FUNARGS fa; |
386 |
|
|
387 |
|
if (readfargs(&fa, fin) != 1) |
388 |
|
return(-1); |
401 |
|
m_dielectric(fin) /* transform arguments for dielectric */ |
402 |
|
FILE *fin; |
403 |
|
{ |
404 |
< |
double pow(); |
405 |
< |
FUNARGS fa; |
404 |
> |
double pow(); |
405 |
> |
FUNARGS fa; |
406 |
|
|
407 |
|
if (readfargs(&fa, fin) != 1) |
408 |
|
return(-1); |
422 |
|
m_interface(fin) /* transform arguments for interface */ |
423 |
|
FILE *fin; |
424 |
|
{ |
425 |
< |
double pow(); |
426 |
< |
FUNARGS fa; |
425 |
> |
double pow(); |
426 |
> |
FUNARGS fa; |
427 |
|
|
428 |
|
if (readfargs(&fa, fin) != 1) |
429 |
|
return(-1); |
450 |
|
{ |
451 |
|
int i; |
452 |
|
FVECT v; |
453 |
< |
FUNARGS fa; |
453 |
> |
FUNARGS fa; |
454 |
|
|
455 |
|
if (readfargs(&fa, fin) != 1) |
456 |
|
return(-1); |
457 |
< |
if (fa.nfargs != 9 && fa.nfargs != 11 && fa.nfargs != 15) |
457 |
> |
if (fa.nfargs < 9) |
458 |
|
return(-1); |
459 |
|
/* string arguments */ |
460 |
|
printf("%d", fa.nsargs); |
469 |
|
printf(" %18.12g %18.12g %18.12g\n", v[0], v[1], v[2]); |
470 |
|
/* down vector */ |
471 |
|
multv3(v, fa.farg+6, tot.xfm); |
472 |
< |
printf(" %18.12g %18.12g %18.12g\n", v[0], v[1], v[2]); |
473 |
< |
/* forground and background */ |
474 |
< |
if (fa.nfargs == 11) |
475 |
< |
printf(" %18.12g %18.12g\n", fa.farg[9], fa.farg[10]); |
476 |
< |
else if (fa.nfargs == 15) { |
477 |
< |
printf(" %18.12g %18.12g %18.12g\n", |
478 |
< |
fa.farg[9], fa.farg[10], fa.farg[11]); |
479 |
< |
printf(" %18.12g %18.12g %18.12g\n", |
480 |
< |
fa.farg[12], fa.farg[13], fa.farg[14]); |
472 |
> |
printf(" %18.12g %18.12g %18.12g", v[0], v[1], v[2]); |
473 |
> |
/* remaining arguments */ |
474 |
> |
for (i = 9; i < fa.nfargs; i++) { |
475 |
> |
if (i%3 == 0) |
476 |
> |
putchar('\n'); |
477 |
> |
printf(" %18.12g", fa.farg[i]); |
478 |
|
} |
479 |
+ |
putchar('\n'); |
480 |
|
freefargs(&fa); |
481 |
|
return(0); |
482 |
|
} |
486 |
|
FILE *fin; |
487 |
|
{ |
488 |
|
FVECT dv; |
489 |
< |
FUNARGS fa; |
489 |
> |
FUNARGS fa; |
490 |
|
|
491 |
|
if (readfargs(&fa, fin) != 1) |
492 |
|
return(-1); |
507 |
|
FILE *fin; |
508 |
|
{ |
509 |
|
FVECT cent; |
510 |
< |
double rad; |
511 |
< |
FUNARGS fa; |
510 |
> |
double rad; |
511 |
> |
FUNARGS fa; |
512 |
|
|
513 |
|
if (readfargs(&fa, fin) != 1) |
514 |
|
return(-1); |
515 |
|
if (fa.nsargs != 0 || fa.nfargs != 4) |
516 |
|
return(-1); |
517 |
|
|
518 |
< |
multp3(cent, fa.farg, tot.xfm); /* transform center */ |
518 |
> |
multp3(cent, fa.farg, tot.xfm); /* transform center */ |
519 |
|
|
520 |
|
rad = fa.farg[3] * tot.sca; /* scale radius */ |
521 |
|
|
532 |
|
{ |
533 |
|
FVECT p; |
534 |
|
register int i; |
535 |
< |
FUNARGS fa; |
535 |
> |
FUNARGS fa; |
536 |
|
|
537 |
|
if (readfargs(&fa, fin) != 1) |
538 |
|
return(-1); |
557 |
|
FILE *fin; |
558 |
|
{ |
559 |
|
FVECT p0, p1; |
560 |
< |
double r0, r1; |
561 |
< |
FUNARGS fa; |
560 |
> |
double r0, r1; |
561 |
> |
FUNARGS fa; |
562 |
|
|
563 |
|
if (readfargs(&fa, fin) != 1) |
564 |
|
return(-1); |
584 |
|
FILE *fin; |
585 |
|
{ |
586 |
|
FVECT p0, p1; |
587 |
< |
double rad; |
588 |
< |
FUNARGS fa; |
587 |
> |
double rad; |
588 |
> |
FUNARGS fa; |
589 |
|
|
590 |
|
if (readfargs(&fa, fin) != 1) |
591 |
|
return(-1); |
609 |
|
FILE *fin; |
610 |
|
{ |
611 |
|
FVECT p0, pd; |
612 |
< |
double r0, r1; |
613 |
< |
FUNARGS fa; |
612 |
> |
double r0, r1; |
613 |
> |
FUNARGS fa; |
614 |
|
|
615 |
|
if (readfargs(&fa, fin) != 1) |
616 |
|
return(-1); |