ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/cv/rad2mgf.c
Revision: 2.6
Committed: Fri Sep 2 16:21:00 1994 UTC (29 years, 7 months ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 2.5: +2 -0 lines
Log Message:
option parsing error

File Contents

# Content
1 /* Copyright (c) 1994 Regents of the University of California */
2
3 #ifndef lint
4 static char SCCSid[] = "$SunId$ LBL";
5 #endif
6
7 /*
8 * Convert Radiance scene description to MGF
9 */
10
11 #include <stdio.h>
12 #include <string.h>
13 #include "fvect.h"
14 #include "object.h"
15 #include "color.h"
16 #include "lookup.h"
17
18 int o_face(), o_cone(), o_sphere(), o_ring(), o_cylinder();
19 int o_instance(), o_source(), o_illum();
20 int o_plastic(), o_metal(), o_glass(), o_mirror(), o_trans(), o_light();
21
22 extern void free();
23 extern char *malloc();
24
25 LUTAB rmats = LU_SINIT(free,NULL); /* defined material table */
26
27 LUTAB rdispatch = LU_SINIT(NULL,NULL); /* function dispatch table */
28
29 char curmat[80]; /* current material */
30 char curobj[128] = "Untitled"; /* current object name */
31
32 double unit_mult = 1.; /* units multiplier */
33
34 #define hasmult (unit_mult < .999 || unit_mult > 1.001)
35
36 /*
37 * Stuff for tracking and reusing vertices:
38 */
39
40 char VKFMT[] = "%+1.9e %+1.9e %+1.9e";
41 #define VKLEN 64
42
43 #define mkvkey(k,v) sprintf(k, VKFMT, (v)[0], (v)[1], (v)[2])
44
45 #define NVERTS 256
46
47 long clock; /* incremented at each vertex request */
48
49 struct vert {
50 long lused; /* when last used (0 if unassigned) */
51 FVECT p; /* track point position only */
52 } vert[NVERTS]; /* our vertex cache */
53
54 LUTAB vertab = LU_SINIT(free,NULL); /* our vertex lookup table */
55
56
57 main(argc, argv)
58 int argc;
59 char **argv;
60 {
61 int i;
62
63 for (i = 1; i < argc && argv[i][0] == '-'; i++)
64 switch (argv[i][1]) {
65 case 'd': /* units */
66 switch (argv[i][2]) {
67 case 'm': /* meters */
68 unit_mult = 1.;
69 break;
70 case 'c': /* centimeters */
71 unit_mult = .01;
72 break;
73 case 'f': /* feet */
74 unit_mult = 12.*.0254;
75 break;
76 case 'i': /* inches */
77 unit_mult = .0254;
78 break;
79 default:
80 goto unkopt;
81 }
82 break;
83 default:
84 goto unkopt;
85 }
86 init();
87 if (i >= argc)
88 rad2mgf(NULL);
89 else
90 for ( ; i < argc; i++)
91 rad2mgf(argv[i]);
92 uninit();
93 exit(0);
94 unkopt:
95 fprintf(stderr, "Usage: %s [-d{m|c|f|i}] file ..\n", argv[0]);
96 exit(1);
97 }
98
99
100 rad2mgf(inp) /* convert a Radiance file to MGF */
101 char *inp;
102 {
103 #define mod buf
104 #define typ (buf+128)
105 #define id (buf+256)
106 #define alias (buf+384)
107 char buf[512];
108 FUNARGS fa;
109 register FILE *fp;
110 register int c;
111
112 if (inp == NULL) {
113 inp = "standard input";
114 fp = stdin;
115 } else if (inp[0] == '!') {
116 if ((fp = popen(inp+1, "r")) == NULL) {
117 fputs(inp, stderr);
118 fputs(": cannot execute\n", stderr);
119 exit(1);
120 }
121 } else if ((fp = fopen(inp, "r")) == NULL) {
122 fputs(inp, stderr);
123 fputs(": cannot open\n", stderr);
124 exit(1);
125 }
126 printf("# Begin conversion from: %s\n", inp);
127 while ((c = getc(fp)) != EOF)
128 switch (c) {
129 case ' ': /* white space */
130 case '\t':
131 case '\n':
132 case '\r':
133 case '\f':
134 break;
135 case '#': /* comment */
136 if (fgets(buf, sizeof(buf), fp) != NULL)
137 printf("# %s", buf);
138 break;
139 case '!': /* inline command */
140 ungetc(c, fp);
141 fgetline(buf, sizeof(buf), fp);
142 rad2mgf(buf);
143 break;
144 default: /* Radiance primitive */
145 ungetc(c, fp);
146 if (fscanf(fp, "%s %s %s", mod, typ, id) != 3) {
147 fputs(inp, stderr);
148 fputs(": unexpected EOF\n", stderr);
149 exit(1);
150 }
151 if (!strcmp(typ, "alias")) {
152 strcpy(alias, "EOF");
153 fscanf(fp, "%s", alias);
154 newmat(id, alias);
155 } else {
156 if (!readfargs(&fa, fp)) {
157 fprintf(stderr,
158 "%s: bad argument syntax for %s \"%s\"\n",
159 inp, typ, id);
160 exit(1);
161 }
162 cvtprim(inp, mod, typ, id, &fa);
163 freefargs(&fa);
164 }
165 break;
166 }
167 printf("# End conversion from: %s\n", inp);
168 if (inp[0] == '!')
169 pclose(fp);
170 else
171 fclose(fp);
172 #undef mod
173 #undef typ
174 #undef id
175 #undef alias
176 }
177
178
179 cvtprim(inp, mod, typ, id, fa) /* process Radiance primitive */
180 char *inp, *mod, *typ, *id;
181 FUNARGS *fa;
182 {
183 int (*df)();
184
185 df = (int (*)())lu_find(&rdispatch, typ)->data;
186 if (df != NULL) { /* convert */
187 if ((*df)(mod, typ, id, fa) < 0) {
188 fprintf(stderr, "%s: bad %s \"%s\"\n", typ, id);
189 exit(1);
190 }
191 } else if (lu_find(&rmats, mod)->data != NULL) /* make alias */
192 newmat(id, mod);
193 }
194
195
196 newmat(id, alias) /* add a modifier to the alias list */
197 char *id;
198 char *alias;
199 {
200 register LUENT *lp, *lpa;
201
202 if (alias != NULL) { /* look up alias */
203 if ((lpa = lu_find(&rmats, alias)) == NULL)
204 goto memerr;
205 if (lpa->data == NULL)
206 alias = NULL; /* doesn't exist! */
207 }
208 if ((lp = lu_find(&rmats, id)) == NULL) /* look up material */
209 goto memerr;
210 if (alias != NULL && lp->data == lpa->key)
211 return; /* alias set already */
212 if (lp->data == NULL) { /* allocate material */
213 if ((lp->key = (char *)malloc(strlen(id)+1)) == NULL)
214 goto memerr;
215 strcpy(lp->key, id);
216 }
217 if (alias == NULL) { /* set this material */
218 lp->data = lp->key;
219 printf("m %s =\n", id);
220 } else { /* set this alias */
221 lp->data = lpa->key;
222 printf("m %s = %s\n", id, alias);
223 }
224 strcpy(curmat, id);
225 return;
226 memerr:
227 fputs("Out of memory in newmat!\n", stderr);
228 exit(1);
229 }
230
231
232 setmat(id) /* set material to this one */
233 char *id;
234 {
235 if (!strcmp(id, curmat)) /* already set? */
236 return;
237 if (!strcmp(id, VOIDID)) /* cannot set */
238 return;
239 printf("m %s\n", id);
240 strcpy(curmat, id);
241 }
242
243
244 setobj(id) /* set object name to this one */
245 char *id;
246 {
247 register char *cp, *cp2;
248 char *end = NULL;
249 int diff = 0;
250 /* use all but final suffix */
251 for (cp = id; *cp; cp++)
252 if (*cp == '.')
253 end = cp;
254 if (end == NULL)
255 end = cp;
256 /* copy to current object */
257 for (cp = id, cp2 = curobj; cp < end; *cp2++ = *cp++)
258 diff += *cp != *cp2;
259 if (!diff && !*cp2)
260 return;
261 *cp2 = '\0';
262 fputs("o\no ", stdout);
263 puts(curobj);
264 }
265
266
267 init() /* initialize dispatch table and output */
268 {
269 lu_init(&vertab, NVERTS);
270 lu_init(&rdispatch, 22);
271 add2dispatch("polygon", o_face);
272 add2dispatch("cone", o_cone);
273 add2dispatch("cup", o_cone);
274 add2dispatch("sphere", o_sphere);
275 add2dispatch("bubble", o_sphere);
276 add2dispatch("cylinder", o_cylinder);
277 add2dispatch("tube", o_cylinder);
278 add2dispatch("ring", o_ring);
279 add2dispatch("instance", o_instance);
280 add2dispatch("plastic", o_plastic);
281 add2dispatch("plastic2", o_plastic);
282 add2dispatch("metal", o_metal);
283 add2dispatch("metal2", o_metal);
284 add2dispatch("glass", o_glass);
285 add2dispatch("trans", o_trans);
286 add2dispatch("trans2", o_trans);
287 add2dispatch("mirror", o_mirror);
288 add2dispatch("light", o_light);
289 add2dispatch("spotlight", o_light);
290 add2dispatch("glow", o_light);
291 add2dispatch("illum", o_illum);
292 puts("# The following was converted from Radiance scene input");
293 if (hasmult)
294 printf("xf -s %.4e\n", unit_mult);
295 printf("o %s\n", curobj);
296 }
297
298
299 uninit() /* mark end of MGF file */
300 {
301 puts("o");
302 if (hasmult)
303 puts("xf");
304 puts("# End of data converted from Radiance scene input");
305 lu_done(&rdispatch);
306 lu_done(&rmats);
307 lu_done(&vertab);
308 }
309
310
311 clrverts() /* clear vertex table */
312 {
313 register int i;
314
315 lu_done(&vertab);
316 for (i = 0; i < NVERTS; i++)
317 vert[i].lused = 0;
318 lu_init(&vertab, NVERTS);
319 }
320
321
322 add2dispatch(name, func) /* add function to dispatch table */
323 char *name;
324 int (*func)();
325 {
326 register LUENT *lp;
327
328 lp = lu_find(&rdispatch, name);
329 if (lp->key != NULL) {
330 fputs(name, stderr);
331 fputs(": duplicate dispatch entry!\n", stderr);
332 exit(1);
333 }
334 lp->key = name;
335 lp->data = (char *)func;
336 }
337
338
339 char *
340 getvertid(vname, vp) /* get/set vertex ID for this point */
341 char *vname;
342 FVECT vp;
343 {
344 char vkey[VKLEN];
345 register LUENT *lp;
346 register int i, vndx;
347
348 clock++; /* increment counter */
349 mkvkey(vkey, vp);
350 if ((lp = lu_find(&vertab, vkey)) == NULL)
351 goto memerr;
352 if (lp->data == NULL) { /* allocate new vertex entry */
353 if (lp->key != NULL) /* reclaim deleted entry */
354 vertab.ndel--;
355 else {
356 if ((lp->key = (char *)malloc(VKLEN)) == NULL)
357 goto memerr;
358 strcpy(lp->key, vkey);
359 }
360 vndx = 0; /* find oldest vertex */
361 for (i = 1; i < NVERTS; i++)
362 if (vert[i].lused < vert[vndx].lused)
363 vndx = i;
364 if (vert[vndx].lused) { /* free old entry first */
365 mkvkey(vkey, vert[vndx].p);
366 lu_delete(&vertab, vkey);
367 }
368 VCOPY(vert[vndx].p, vp); /* assign it */
369 printf("v v%d =\n\tp %.15g %.15g %.15g\n", /* print it */
370 vndx, vp[0], vp[1], vp[2]);
371 lp->data = (char *)&vert[vndx]; /* set it */
372 } else
373 vndx = (struct vert *)lp->data - vert;
374 vert[vndx].lused = clock; /* record this use */
375 sprintf(vname, "v%d", vndx);
376 return(vname);
377 memerr:
378 fputs("Out of memory in getvertid!\n", stderr);
379 exit(1);
380 }
381
382
383 int
384 o_face(mod, typ, id, fa) /* print out a polygon */
385 char *mod, *typ, *id;
386 FUNARGS *fa;
387 {
388 char entbuf[512];
389 register char *cp;
390 register int i;
391
392 if (fa->nfargs < 9 | fa->nfargs % 3)
393 return(-1);
394 setmat(mod);
395 setobj(id);
396 cp = entbuf;
397 *cp++ = 'f';
398 for (i = 0; i < fa->nfargs; i += 3) {
399 *cp++ = ' ';
400 getvertid(cp, fa->farg + i);
401 while (*cp)
402 cp++;
403 }
404 puts(entbuf);
405 return(0);
406 }
407
408
409 int
410 o_cone(mod, typ, id, fa) /* print out a cone */
411 char *mod, *typ, *id;
412 register FUNARGS *fa;
413 {
414 char v1[6], v2[6];
415
416 if (fa->nfargs != 8)
417 return(-1);
418 setmat(mod);
419 setobj(id);
420 getvertid(v1, fa->farg);
421 getvertid(v2, fa->farg + 3);
422 if (typ[1] == 'u') /* cup -> inverted cone */
423 printf("cone %s %.12g %s %.12g\n",
424 v1, -fa->farg[6], v2, -fa->farg[7]);
425 else
426 printf("cone %s %.12g %s %.12g\n",
427 v1, fa->farg[6], v2, fa->farg[7]);
428 return(0);
429 }
430
431
432 int
433 o_sphere(mod, typ, id, fa) /* print out a sphere */
434 char *mod, *typ, *id;
435 register FUNARGS *fa;
436 {
437 char cent[6];
438
439 if (fa->nfargs != 4)
440 return(-1);
441 setmat(mod);
442 setobj(id);
443 printf("sph %s %.12g\n", getvertid(cent, fa->farg),
444 typ[0]=='b' ? -fa->farg[3] : fa->farg[3]);
445 return(0);
446 }
447
448
449 int
450 o_cylinder(mod, typ, id, fa) /* print out a cylinder */
451 char *mod, *typ, *id;
452 register FUNARGS *fa;
453 {
454 char v1[6], v2[6];
455
456 if (fa->nfargs != 7)
457 return(-1);
458 setmat(mod);
459 setobj(id);
460 getvertid(v1, fa->farg);
461 getvertid(v2, fa->farg + 3);
462 printf("cyl %s %.12g %s\n", v1,
463 typ[0]=='t' ? -fa->farg[6] : fa->farg[6], v2);
464 return(0);
465 }
466
467
468 int
469 o_ring(mod, typ, id, fa) /* print out a ring */
470 char *mod, *typ, *id;
471 register FUNARGS *fa;
472 {
473 if (fa->nfargs != 8)
474 return(-1);
475 setmat(mod);
476 setobj(id);
477 printf("v cent =\n\tp %.12g %.12g %.12g\n",
478 fa->farg[0], fa->farg[1], fa->farg[2]);
479 printf("\tn %.12g %.12g %.12g\n",
480 fa->farg[3], fa->farg[4], fa->farg[5]);
481 if (fa->farg[6] < fa->farg[7])
482 printf("ring cent %.12g %.12g\n",
483 fa->farg[6], fa->farg[7]);
484 else
485 printf("ring cent %.12g %.12g\n",
486 fa->farg[7], fa->farg[6]);
487 return(0);
488 }
489
490
491 int
492 o_instance(mod, typ, id, fa) /* convert an instance */
493 char *mod, *typ, *id;
494 FUNARGS *fa;
495 {
496 register int i;
497 register char *cp;
498 char *start = NULL, *end = NULL;
499 /*
500 * We don't really know how to do this, so we just create
501 * a reference to an undefined MGF file and it's the user's
502 * responsibility to create this file and put the appropriate
503 * stuff into it.
504 */
505 if (fa->nsargs < 1)
506 return(-1);
507 setmat(mod); /* only works if surfaces are void */
508 setobj(id);
509 for (cp = fa->sarg[0]; *cp; cp++) /* construct MGF file name */
510 if (*cp == '/')
511 start = cp+1;
512 else if (*cp == '.')
513 end = cp;
514 if (start == NULL)
515 start = fa->sarg[0];
516 if (end == NULL || start >= end)
517 end = cp;
518 fputs("i ", stdout); /* print include entity */
519 for (cp = start; cp < end; cp++)
520 putchar(*cp);
521 fputs(".mgf", stdout); /* add MGF suffix */
522 for (i = 1; i < fa->nsargs; i++) { /* add transform */
523 putchar(' ');
524 fputs(fa->sarg[i], stdout);
525 }
526 putchar('\n');
527 clrverts(); /* vertex id's no longer reliable */
528 return(0);
529 }
530
531
532 int
533 o_source(mod, typ, id, fa) /* convert a source */
534 char *mod, *typ, *id;
535 FUNARGS *fa;
536 {
537 return(0); /* there is no MGF equivalent! */
538 }
539
540
541 int
542 o_illum(mod, typ, id, fa) /* convert an illum material */
543 char *mod, *typ, *id;
544 FUNARGS *fa;
545 {
546 if (fa->nsargs == 1 && strcmp(fa->sarg[0], VOIDID)) {
547 newmat(id, fa->sarg[0]); /* just create alias */
548 return(0);
549 }
550 /* else create invisible material */
551 newmat(id, NULL);
552 puts("\tts 1 0");
553 return(0);
554 }
555
556
557 int
558 o_plastic(mod, typ, id, fa) /* convert a plastic material */
559 char *mod, *typ, *id;
560 register FUNARGS *fa;
561 {
562 COLOR cxyz, rrgb;
563 double d;
564
565 if (fa->nfargs != (typ[7]=='2' ? 6 : 5))
566 return(-1);
567 newmat(id, NULL);
568 rrgb[0] = fa->farg[0]; rrgb[1] = fa->farg[1]; rrgb[2] = fa->farg[2];
569 rgb_cie(cxyz, rrgb);
570 puts("\tc"); /* put diffuse component */
571 d = cxyz[0] + cxyz[1] + cxyz[2];
572 if (d > FTINY)
573 printf("\t\tcxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
574 printf("\trd %.4f\n", cxyz[1]*(1. - fa->farg[3]));
575 if (fa->farg[3] > FTINY) { /* put specular component */
576 puts("\tc");
577 printf("\trs %.4f %.4f\n", fa->farg[3],
578 typ[7]=='2' ? .5*(fa->farg[4] + fa->farg[5]) :
579 fa->farg[4]);
580 }
581 return(0);
582 }
583
584
585 int
586 o_metal(mod, typ, id, fa) /* convert a metal material */
587 char *mod, *typ, *id;
588 register FUNARGS *fa;
589 {
590 COLOR cxyz, rrgb;
591 double d;
592
593 if (fa->nfargs != (typ[5]=='2' ? 6 : 5))
594 return(-1);
595 newmat(id, NULL);
596 rrgb[0] = fa->farg[0]; rrgb[1] = fa->farg[1]; rrgb[2] = fa->farg[2];
597 rgb_cie(cxyz, rrgb);
598 puts("\tc"); /* put diffuse component */
599 d = cxyz[0] + cxyz[1] + cxyz[2];
600 if (d > FTINY)
601 printf("\t\tcxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
602 printf("\trd %.4f\n", cxyz[1]*(1. - fa->farg[3]));
603 /* put specular component */
604 printf("\trs %.4f %.4f\n", cxyz[1]*fa->farg[3],
605 typ[5]=='2' ? .5*(fa->farg[4] + fa->farg[5]) :
606 fa->farg[4]);
607 return(0);
608 }
609
610
611 int
612 o_glass(mod, typ, id, fa) /* convert a glass material */
613 char *mod, *typ, *id;
614 register FUNARGS *fa;
615 {
616 COLOR cxyz, rrgb, trgb;
617 double nrfr = 1.52, F, d;
618 register int i;
619
620 if (fa->nfargs != 3 && fa->nfargs != 4)
621 return(-1);
622 newmat(id, NULL);
623 if (fa->nfargs == 4)
624 nrfr = fa->farg[3];
625 F = (1. - nrfr)/(1. + nrfr); /* use normal incidence */
626 F *= F;
627 for (i = 0; i < 3; i++) {
628 trgb[i] = fa->farg[i] * (1. - F)*(1. - F) /
629 (1. - F*F*fa->farg[i]*fa->farg[i]);
630 rrgb[i] = F * (1. + (1. - 2.*F)*fa->farg[i]) /
631 (1. - F*F*fa->farg[i]*fa->farg[i]);
632 }
633 rgb_cie(cxyz, rrgb); /* put reflected component */
634 puts("\tc");
635 d = cxyz[0] + cxyz[1] + cxyz[2];
636 if (d > FTINY)
637 printf("\t\tcxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
638 printf("\trs %.4f 0\n", cxyz[1]);
639 rgb_cie(cxyz, trgb); /* put transmitted component */
640 puts("\tc");
641 d = cxyz[0] + cxyz[1] + cxyz[2];
642 if (d > FTINY)
643 printf("\t\tcxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
644 printf("\tts %.4f 0\n", cxyz[1]);
645 return(0);
646 }
647
648
649 int
650 o_mirror(mod, typ, id, fa) /* convert a mirror material */
651 char *mod, *typ, *id;
652 register FUNARGS *fa;
653 {
654 COLOR cxyz, rrgb;
655 double d;
656
657 if (fa->nsargs == 1) { /* use alternate material */
658 newmat(id, fa->sarg[0]);
659 return(0);
660 }
661 if (fa->nfargs != 3)
662 return(-1);
663 newmat(id, NULL);
664 rrgb[0] = fa->farg[0]; rrgb[1] = fa->farg[1]; rrgb[2] = fa->farg[2];
665 rgb_cie(cxyz, rrgb);
666 puts("\tc"); /* put specular component */
667 d = cxyz[0] + cxyz[1] + cxyz[2];
668 if (d > FTINY)
669 printf("\t\tcxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
670 printf("\trs %.4f 0\n", cxyz[1]);
671 return(0);
672 }
673
674
675 int
676 o_trans(mod, typ, id, fa) /* convert a trans material */
677 char *mod, *typ, *id;
678 register FUNARGS *fa;
679 {
680 COLOR cxyz, rrgb;
681 double rough, trans, tspec, d;
682
683 if (typ[4] == '2') { /* trans2 */
684 if (fa->nfargs != 8)
685 return(-1);
686 rough = .5*(fa->farg[4] + fa->farg[5]);
687 trans = fa->farg[6];
688 tspec = fa->farg[7];
689 } else { /* trans */
690 if (fa->nfargs != 7)
691 return(-1);
692 rough = fa->farg[4];
693 trans = fa->farg[5];
694 tspec = fa->farg[6];
695 }
696 newmat(id, NULL);
697 rrgb[0] = fa->farg[0]; rrgb[1] = fa->farg[1]; rrgb[2] = fa->farg[2];
698 rgb_cie(cxyz, rrgb);
699 puts("\tc"); /* put transmitted diffuse */
700 d = cxyz[0] + cxyz[1] + cxyz[2];
701 if (d > FTINY)
702 printf("\t\tcxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
703 printf("\ttd %.4f\n", cxyz[1]*trans*(1. - fa->farg[3])*(1. - tspec));
704 /* put transmitted specular */
705 printf("\tts %.4f %.4f\n", cxyz[1]*trans*tspec*(1. - fa->farg[3]), rough);
706 /* put reflected diffuse */
707 printf("\trd %.4f\n", cxyz[1]*(1. - fa->farg[3])*(1. - trans));
708 puts("\tc"); /* put reflected specular */
709 printf("\trs %.4f %.4f\n", fa->farg[3], rough);
710 return(0);
711 }
712
713
714 int
715 o_light(mod, typ, id, fa) /* convert a light type */
716 char *mod, *typ, *id;
717 register FUNARGS *fa;
718 {
719 COLOR cxyz, rrgb;
720 double d;
721
722 if (fa->nfargs < 3)
723 return(-1);
724 newmat(id, NULL);
725 rrgb[0] = fa->farg[0]; rrgb[1] = fa->farg[1]; rrgb[2] = fa->farg[2];
726 rgb_cie(cxyz, rrgb);
727 d = cxyz[0] + cxyz[1] + cxyz[2];
728 puts("\tc");
729 if (d > FTINY)
730 printf("\t\tcxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
731 printf("\ted %.4g\n", cxyz[1]*WHTEFFICACY);
732 return(0);
733 }