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.3 by greg, Fri Jul 8 16:39:22 1994 UTC vs.
Revision 2.8 by greg, Mon Dec 12 12:09:28 1994 UTC

# Line 15 | Line 15 | static char SCCSid[] = "$SunId$ LBL";
15   #include "color.h"
16   #include "lookup.h"
17  
18 + #define PI      3.14159265358979323846
19 +
20   int     o_face(), o_cone(), o_sphere(), o_ring(), o_cylinder();
21   int     o_instance(), o_source(), o_illum();
22   int     o_plastic(), o_metal(), o_glass(), o_mirror(), o_trans(), o_light();
# Line 33 | Line 35 | double unit_mult = 1.;                         /* units multiplier */
35  
36   #define hasmult         (unit_mult < .999 || unit_mult > 1.001)
37  
38 + /*
39 + * Stuff for tracking and reusing vertices:
40 + */
41  
42 + char    VKFMT[] = "%+1.9e %+1.9e %+1.9e";
43 + #define VKLEN           64
44 +
45 + #define mkvkey(k,v)     sprintf(k, VKFMT, (v)[0], (v)[1], (v)[2])
46 +
47 + #define NVERTS          256
48 +
49 + long    vclock;         /* incremented at each vertex request */
50 +
51 + struct vert {
52 +        long    lused;          /* when last used (0 if unassigned) */
53 +        FVECT   p;              /* track point position only */
54 + } vert[NVERTS];         /* our vertex cache */
55 +
56 + LUTAB   vertab = LU_SINIT(free,NULL);   /* our vertex lookup table */
57 +
58 +
59   main(argc, argv)
60   int     argc;
61   char    **argv;
# Line 60 | Line 82 | char   **argv;
82                                  goto unkopt;
83                          }
84                          break;
85 +                default:
86 +                        goto unkopt;
87                  }
88          init();
89          if (i >= argc)
# Line 244 | Line 268 | char   *id;
268  
269   init()                  /* initialize dispatch table and output */
270   {
271 +        lu_init(&vertab, NVERTS);
272          lu_init(&rdispatch, 22);
273          add2dispatch("polygon", o_face);
274          add2dispatch("cone", o_cone);
# Line 281 | Line 306 | uninit()                       /* mark end of MGF file */
306          puts("# End of data converted from Radiance scene input");
307          lu_done(&rdispatch);
308          lu_done(&rmats);
309 +        lu_done(&vertab);
310   }
311  
312  
313 + clrverts()                      /* clear vertex table */
314 + {
315 +        register int    i;
316 +
317 +        lu_done(&vertab);
318 +        for (i = 0; i < NVERTS; i++)
319 +                vert[i].lused = 0;
320 +        lu_init(&vertab, NVERTS);
321 + }
322 +
323 +
324   add2dispatch(name, func)        /* add function to dispatch table */
325   char    *name;
326   int     (*func)();
# Line 301 | Line 338 | int    (*func)();
338   }
339  
340  
304 /*
305 * Stuff for tracking and reusing vertices:
306 */
307
308 char    VKFMT[] = "%+1.9e %+1.9e %+1.9e";
309 #define VKLEN           64
310
311 #define mkvkey(k,v)     sprintf(k, VKFMT, (v)[0], (v)[1], (v)[2])
312
313 #define NVERTS          256
314
315 long    clock;          /* incremented at each vertex request */
316
317 struct vert {
318        long    lused;          /* when last used (0 if unassigned) */
319        FVECT   p;              /* track point position only */
320 } vert[NVERTS];
321
322 LUTAB   vertab = LU_SINIT(free,NULL);   /* our vertex lookup table */
323
324
341   char *
342   getvertid(vname, vp)            /* get/set vertex ID for this point */
343   char    *vname;
# Line 331 | Line 347 | FVECT  vp;
347          register LUENT  *lp;
348          register int    i, vndx;
349  
350 <        if (!vertab.tsiz && !lu_init(&vertab, NVERTS))
335 <                goto memerr;
336 <        clock++;                        /* increment counter */
350 >        vclock++;                       /* increment counter */
351          mkvkey(vkey, vp);
352          if ((lp = lu_find(&vertab, vkey)) == NULL)
353                  goto memerr;
# Line 359 | Line 373 | FVECT  vp;
373                  lp->data = (char *)&vert[vndx];                 /* set it */
374          } else
375                  vndx = (struct vert *)lp->data - vert;
376 <        vert[vndx].lused = clock;               /* record this use */
376 >        vert[vndx].lused = vclock;              /* record this use */
377          sprintf(vname, "v%d", vndx);
378          return(vname);
379   memerr:
# Line 512 | Line 526 | FUNARGS        *fa;
526                  fputs(fa->sarg[i], stdout);
527          }
528          putchar('\n');
529 +        clrverts();                     /* vertex id's no longer reliable */
530          return(0);
531   }
532  
# Line 715 | Line 730 | register FUNARGS       *fa;
730          puts("\tc");
731          if (d > FTINY)
732                  printf("\t\tcxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
733 <        printf("\ted %.4g\n", cxyz[1]*WHTEFFICACY);
733 >        printf("\ted %.4g\n", cxyz[1]*(PI*WHTEFFICACY));
734          return(0);
735   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines