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

Comparing ray/src/cv/rad2mgf.c (file contents):
Revision 2.21 by schorsch, Mon Oct 27 10:26:45 2003 UTC vs.
Revision 2.22 by schorsch, Sat Nov 15 16:29:11 2003 UTC

# Line 18 | Line 18 | static const char      RCSid[] = "$Id$";
18  
19   #define C_1SIDEDTHICK   0.005
20  
21 int     o_face(), o_cone(), o_sphere(), o_ring(), o_cylinder();
22 int     o_instance(), o_illum();
23 int     o_plastic(), o_metal(), o_glass(), o_dielectric(),
24        o_mirror(), o_trans(), o_light();
21  
22   LUTAB   rmats = LU_SINIT(free,NULL);            /* defined material table */
23  
# Line 54 | Line 50 | struct vert {
50  
51   LUTAB   vertab = LU_SINIT(free,NULL);   /* our vertex lookup table */
52  
53 + static void rad2mgf(char *inp);
54 + static void cvtprim(char *inp, char *mod, char *typ, char *id, FUNARGS *fa);
55 + static void newmat(char *id, char *alias);
56 + static void setmat(char *id);
57 + static void setobj(char *id);
58 + static void init(void);
59 + static void uninit(void);
60 + static void clrverts(void);
61 + static void add2dispatch(char *name, int (*func)());
62 + static char *getvertid(char *vname, FVECT vp);
63 + static int o_unsupported(char *mod, char *typ, char *id, FUNARGS *fa);
64 + static int o_face(char *mod, char *typ, char *id, FUNARGS *fa);
65 + static int o_cone(char *mod, char *typ, char *id, FUNARGS *fa);
66 + static int o_sphere(char *mod, char *typ, char *id, FUNARGS *fa);
67 + static int o_cylinder(char *mod, char *typ, char *id, FUNARGS *fa);
68 + static int o_ring(char *mod, char *typ, char *id, FUNARGS *fa);
69 + static int o_instance(char *mod, char *typ, char *id, FUNARGS *fa);
70 + static int o_illum(char *mod, char *typ, char *id, FUNARGS *fa);
71 + static int o_plastic(char *mod, char *typ, char *id, FUNARGS *fa);
72 + static int o_metal(char *mod, char *typ, char *id, FUNARGS *fa);
73 + static int o_glass(char *mod, char *typ, char *id, FUNARGS *fa);
74 + static int o_dielectric(char *mod, char *typ, char *id, FUNARGS *fa);
75 + static int o_mirror(char *mod, char *typ, char *id, FUNARGS *fa);
76 + static int o_trans(char *mod, char *typ, char *id, FUNARGS *fa);
77 + static int o_light(char *mod, char *typ, char *id, FUNARGS *fa);
78  
79 < main(argc, argv)
80 < int     argc;
81 < char    **argv;
79 >
80 > int
81 > main(
82 >        int     argc,
83 >        char    **argv
84 > )
85   {
86          int     i;
87  
# Line 98 | Line 122 | unkopt:
122   }
123  
124  
125 < rad2mgf(inp)            /* convert a Radiance file to MGF */
126 < char    *inp;
125 > void
126 > rad2mgf(                /* convert a Radiance file to MGF */
127 >        char    *inp
128 > )
129   {
130   #define mod     buf
131   #define typ     (buf+128)
# Line 177 | Line 203 | char   *inp;
203   }
204  
205  
206 < cvtprim(inp, mod, typ, id, fa)  /* process Radiance primitive */
207 < char    *inp, *mod, *typ, *id;
208 < FUNARGS *fa;
206 > void
207 > cvtprim(        /* process Radiance primitive */
208 >        char    *inp,
209 >        char    *mod,
210 >        char    *typ,
211 >        char    *id,
212 >        FUNARGS *fa
213 > )
214   {
215          int     (*df)();
216  
217          df = (int (*)())lu_find(&rdispatch, typ)->data;
218          if (df != NULL) {                               /* convert */
219                  if ((*df)(mod, typ, id, fa) < 0) {
220 <                        fprintf(stderr, "%s: bad %s \"%s\"\n", typ, id);
220 >                        fprintf(stderr, "%s: bad %s \"%s\"\n", "rat2mgf", typ, id);
221                          exit(1);
222                  }
223          } else {                                        /* unsupported */
# Line 197 | Line 228 | FUNARGS        *fa;
228   }
229  
230  
231 < newmat(id, alias)               /* add a modifier to the alias list */
232 < char    *id;
233 < char    *alias;
231 > void
232 > newmat(         /* add a modifier to the alias list */
233 >        char    *id,
234 >        char    *alias
235 > )
236   {
237          register LUENT  *lp, *lpa;
238  
# Line 233 | Line 266 | memerr:
266   }
267  
268  
269 < setmat(id)                      /* set material to this one */
270 < char    *id;
269 > void
270 > setmat(                 /* set material to this one */
271 >        char    *id
272 > )
273   {
274          if (!strcmp(id, curmat))        /* already set? */
275                  return;
# Line 245 | Line 280 | char   *id;
280   }
281  
282  
283 < setobj(id)                      /* set object name to this one */
284 < char    *id;
283 > void
284 > setobj(                 /* set object name to this one */
285 >        char    *id
286 > )
287   {
288          register char   *cp, *cp2;
289          char    *end = NULL;
# Line 276 | Line 313 | char   *id;
313   }
314  
315  
316 < init()                  /* initialize dispatch table and output */
316 > void
317 > init(void)                      /* initialize dispatch table and output */
318   {
319          lu_init(&vertab, NVERTS);
320          lu_init(&rdispatch, 22);
# Line 310 | Line 348 | init()                 /* initialize dispatch table and output */
348   }
349  
350  
351 < uninit()                        /* mark end of MGF file */
351 > void
352 > uninit(void)                    /* mark end of MGF file */
353   {
354          puts("o");
355          if (hasmult)
# Line 322 | Line 361 | uninit()                       /* mark end of MGF file */
361   }
362  
363  
364 < clrverts()                      /* clear vertex table */
364 > void
365 > clrverts(void)                  /* clear vertex table */
366   {
367          register int    i;
368  
# Line 333 | Line 373 | clrverts()                     /* clear vertex table */
373   }
374  
375  
376 < add2dispatch(name, func)        /* add function to dispatch table */
377 < char    *name;
378 < int     (*func)();
376 > void
377 > add2dispatch(   /* add function to dispatch table */
378 >        char    *name,
379 >        int     (*func)()
380 > )
381   {
382          register LUENT  *lp;
383  
# Line 351 | Line 393 | int    (*func)();
393  
394  
395   char *
396 < getvertid(vname, vp)            /* get/set vertex ID for this point */
397 < char    *vname;
398 < FVECT   vp;
396 > getvertid(              /* get/set vertex ID for this point */
397 >        char    *vname,
398 >        FVECT   vp
399 > )
400   {
401          static char     vkey[VKLEN];
402          register LUENT  *lp;
# Line 395 | Line 438 | memerr:
438  
439  
440   int
441 < o_unsupported(mod, typ, id, fa)         /* mark unsupported primitive */
442 < char    *mod, *typ, *id;
443 < FUNARGS *fa;
441 > o_unsupported(          /* mark unsupported primitive */
442 >        char    *mod,
443 >        char    *typ,
444 >        char    *id,
445 >        FUNARGS *fa
446 > )
447   {
448          register int    i;
449  
# Line 422 | Line 468 | FUNARGS        *fa;
468  
469  
470   int
471 < o_face(mod, typ, id, fa)                /* print out a polygon */
472 < char    *mod, *typ, *id;
473 < FUNARGS *fa;
471 > o_face(         /* print out a polygon */
472 >        char    *mod,
473 >        char    *typ,
474 >        char    *id,
475 >        FUNARGS *fa
476 > )
477   {
478          char    entbuf[2048], *linestart;
479          register char   *cp;
# Line 453 | Line 502 | FUNARGS        *fa;
502  
503  
504   int
505 < o_cone(mod, typ, id, fa)        /* print out a cone */
506 < char    *mod, *typ, *id;
507 < register FUNARGS        *fa;
505 > o_cone( /* print out a cone */
506 >        char    *mod,
507 >        char    *typ,
508 >        char    *id,
509 >        register FUNARGS        *fa
510 > )
511   {
512          char    v1[6], v2[6];
513  
# Line 476 | Line 528 | register FUNARGS       *fa;
528  
529  
530   int
531 < o_sphere(mod, typ, id, fa)      /* print out a sphere */
532 < char    *mod, *typ, *id;
533 < register FUNARGS        *fa;
531 > o_sphere(       /* print out a sphere */
532 >        char    *mod,
533 >        char    *typ,
534 >        char    *id,
535 >        register FUNARGS        *fa
536 > )
537   {
538          char    cent[6];
539  
# Line 493 | Line 548 | register FUNARGS       *fa;
548  
549  
550   int
551 < o_cylinder(mod, typ, id, fa)    /* print out a cylinder */
552 < char    *mod, *typ, *id;
553 < register FUNARGS        *fa;
551 > o_cylinder(     /* print out a cylinder */
552 >        char    *mod,
553 >        char    *typ,
554 >        char    *id,
555 >        register FUNARGS        *fa
556 > )
557   {
558          char    v1[6], v2[6];
559  
# Line 512 | Line 570 | register FUNARGS       *fa;
570  
571  
572   int
573 < o_ring(mod, typ, id, fa)        /* print out a ring */
574 < char    *mod, *typ, *id;
575 < register FUNARGS        *fa;
573 > o_ring( /* print out a ring */
574 >        char    *mod,
575 >        char    *typ,
576 >        char    *id,
577 >        register FUNARGS        *fa
578 > )
579   {
580          if (fa->nfargs != 8)
581                  return(-1);
# Line 535 | Line 596 | register FUNARGS       *fa;
596  
597  
598   int
599 < o_instance(mod, typ, id, fa)    /* convert an instance (or mesh) */
600 < char    *mod, *typ, *id;
601 < FUNARGS *fa;
599 > o_instance(     /* convert an instance (or mesh) */
600 >        char    *mod,
601 >        char    *typ,
602 >        char    *id,
603 >        FUNARGS *fa
604 > )
605   {
606          register int    i;
607          register char   *cp;
# Line 576 | Line 640 | FUNARGS        *fa;
640  
641  
642   int
643 < o_illum(mod, typ, id, fa)       /* convert an illum material */
644 < char    *mod, *typ, *id;
645 < FUNARGS *fa;
643 > o_illum(        /* convert an illum material */
644 >        char    *mod,
645 >        char    *typ,
646 >        char    *id,
647 >        FUNARGS *fa
648 > )
649   {
650          if (fa->nsargs == 1 && strcmp(fa->sarg[0], VOIDID)) {
651                  newmat(id, fa->sarg[0]);        /* just create alias */
# Line 592 | Line 659 | FUNARGS        *fa;
659  
660  
661   int
662 < o_plastic(mod, typ, id, fa)     /* convert a plastic material */
663 < char    *mod, *typ, *id;
664 < register FUNARGS        *fa;
662 > o_plastic(      /* convert a plastic material */
663 >        char    *mod,
664 >        char    *typ,
665 >        char    *id,
666 >        register FUNARGS        *fa
667 > )
668   {
669          COLOR   cxyz, rrgb;
670          double  d;
# Line 620 | Line 690 | register FUNARGS       *fa;
690  
691  
692   int
693 < o_metal(mod, typ, id, fa)       /* convert a metal material */
694 < char    *mod, *typ, *id;
695 < register FUNARGS        *fa;
693 > o_metal(        /* convert a metal material */
694 >        char    *mod,
695 >        char    *typ,
696 >        char    *id,
697 >        register FUNARGS        *fa
698 > )
699   {
700          COLOR   cxyz, rrgb;
701          double  d;
# Line 646 | Line 719 | register FUNARGS       *fa;
719  
720  
721   int
722 < o_glass(mod, typ, id, fa)       /* convert a glass material */
723 < char    *mod, *typ, *id;
724 < register FUNARGS        *fa;
722 > o_glass(        /* convert a glass material */
723 >        char    *mod,
724 >        char    *typ,
725 >        char    *id,
726 >        register FUNARGS        *fa
727 > )
728   {
729          COLOR   cxyz, rrgb, trgb;
730          double  nrfr = 1.52, F, d;
# Line 685 | Line 761 | register FUNARGS       *fa;
761  
762  
763   int
764 < o_dielectric(mod, typ, id, fa)  /* convert a dielectric material */
765 < char    *mod, *typ, *id;
766 < register FUNARGS        *fa;
764 > o_dielectric(   /* convert a dielectric material */
765 >        char    *mod,
766 >        char    *typ,
767 >        char    *id,
768 >        register FUNARGS        *fa
769 > )
770   {
771          COLOR   cxyz, trgb;
772          double  F, d;
# Line 715 | Line 794 | register FUNARGS       *fa;
794  
795  
796   int
797 < o_mirror(mod, typ, id, fa)      /* convert a mirror material */
798 < char    *mod, *typ, *id;
799 < register FUNARGS        *fa;
797 > o_mirror(       /* convert a mirror material */
798 >        char    *mod,
799 >        char    *typ,
800 >        char    *id,
801 >        register FUNARGS        *fa
802 > )
803   {
804          COLOR   cxyz, rrgb;
805          double  d;
# Line 741 | Line 823 | register FUNARGS       *fa;
823  
824  
825   int
826 < o_trans(mod, typ, id, fa)       /* convert a trans material */
827 < char    *mod, *typ, *id;
828 < register FUNARGS        *fa;
826 > o_trans(        /* convert a trans material */
827 >        char    *mod,
828 >        char    *typ,
829 >        char    *id,
830 >        register FUNARGS        *fa
831 > )
832   {
833          COLOR   cxyz, rrgb;
834          double  rough, trans, tspec, d;
# Line 780 | Line 865 | register FUNARGS       *fa;
865  
866  
867   int
868 < o_light(mod, typ, id, fa)               /* convert a light type */
869 < char    *mod, *typ, *id;
870 < register FUNARGS        *fa;
868 > o_light(                /* convert a light type */
869 >        char    *mod,
870 >        char    *typ,
871 >        char    *id,
872 >        register FUNARGS        *fa
873 > )
874   {
875          COLOR   cxyz, rrgb;
876          double  d;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines