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

Comparing ray/src/gen/xform.c (file contents):
Revision 1.10 by greg, Wed Jan 24 09:16:03 1990 UTC vs.
Revision 1.11 by greg, Thu Dec 13 11:51:17 1990 UTC

# Line 16 | Line 16 | static char SCCSid[] = "$SunId$ LBL";
16  
17   #include  <ctype.h>
18  
19 + #include  "otypes.h"
20  
20 typedef struct {
21        char  *funame;                  /* function name */
22        int  (*funp)();                 /* pointer to function */
23 }  FUN;
24
21   int  xac;                               /* global xform argument count */
22   char  **xav;                            /* global xform argument pointer */
23   int  xfa;                               /* start of xf arguments */
# Line 34 | Line 30 | int  expand = 0;                       /* boolean true to expand commands
30  
31   char  *idprefix = NULL;                 /* prefix for object identifiers */
32  
33 < extern int  o_source();
38 < extern int  o_sphere();
39 < extern int  o_face();
40 < extern int  o_cone();
41 < extern int  o_cylinder();
42 < extern int  o_ring();
43 < extern int  m_glow();
44 < extern int  m_spot();
45 < extern int  m_dielectric();
46 < extern int  m_interface();
47 < extern int  text();
48 < extern int  alias();
49 < extern int  passargs();
50 < extern int  addxform();
33 > #define  ALIAS          NUMOTYPE        /* put alias at end of array */
34  
35 < FUN  ofun[] = {
53 <        { "source", o_source },
54 <        { "sphere", o_sphere },
55 <        { "bubble", o_sphere },
56 <        { "polygon", o_face },
57 <        { "cone", o_cone },
58 <        { "cup", o_cone },
59 <        { "cylinder", o_cylinder },
60 <        { "tube", o_cylinder },
61 <        { "ring", o_ring },
62 <        { "instance", addxform },
63 <        { "alias", alias },
64 <        { "antimatter", passargs },
65 <        { "glow", m_glow },
66 <        { "spotlight", m_spot },
67 <        { "dielectric", m_dielectric },
68 <        { "interface", m_interface },
69 <        { "colortext", text },
70 <        { "brighttext", text },
71 <        { "texfunc", addxform },
72 <        { "texdata", addxform },
73 <        { "colorfunc", addxform },
74 <        { "brightfunc", addxform },
75 <        { "colorpict", addxform },
76 <        { "colordata", addxform },
77 <        { "brightdata", addxform },
78 <        { "mixfunc", addxform },
79 <        { "mixdata", addxform },
80 <        { "mixtext", text },
81 <        { "light", passargs },
82 <        { "illum", passargs },
83 <        { "plastic", passargs },
84 <        { "metal", passargs },
85 <        { "trans", passargs },
86 <        { "glass", passargs },
87 <        { 0 }                                   /* terminator */
88 < };
35 > #define  NUMTYPES       (NUMOTYPE+1)    /* total number of object types */
36  
37 < #define  issurface(t)           ((t)<=9)
37 > FUN  ofun[NUMTYPES] = INIT_OTYPE;       /* default types and actions */
38  
39   typedef struct {
40          short  nsargs;                  /* # of string arguments */
# Line 118 | Line 65 | char  *argv[];
65                  if (!strcmp(argv[a], "-a"))
66                          return(doarray(argc, argv, a));
67  
68 +        initotypes();
69 +
70          for (a = 1; a < argc; a++) {
71                  if (argv[a][0] == '-')
72                          switch (argv[a][1]) {
# Line 309 | Line 258 | FILE  *fin;
258   }
259  
260  
261 < passargs(fin)                   /* pass on arguments unchanged */
261 > o_default(fin)                  /* pass on arguments unchanged */
262   FILE  *fin;
263   {
264          register int  i;
# Line 373 | Line 322 | register char  *ofname;
322   {
323          register int  i;
324  
325 <        for (i = 0; ofun[i].funame != NULL; i++)
325 >        for (i = 0; i < NUMTYPES; i++)
326                  if (!strcmp(ofun[i].funame, ofname))
327                          return(i);
328  
# Line 733 | Line 682 | register FUNARGS  *fa;
682          if (fa->nfargs)
683                  free(fa->farg);
684          free(fa);
685 + }
686 +
687 +
688 + initotypes()                    /* initialize ofun[] array */
689 + {
690 +        extern int  o_source();
691 +        extern int  o_sphere();
692 +        extern int  o_face();
693 +        extern int  o_cone();
694 +        extern int  o_cylinder();
695 +        extern int  o_ring();
696 +        extern int  m_glow();
697 +        extern int  m_spot();
698 +        extern int  m_dielectric();
699 +        extern int  m_interface();
700 +        extern int  text();
701 +        extern int  alias();
702 +        extern int  passargs();
703 +        extern int  addxform();
704 +        register int  i;
705 +
706 +        if (ofun[OBJ_SOURCE].funp == o_source)
707 +                return;                 /* done already */
708 +                                        /* alias is additional */
709 +        ofun[ALIAS].funame = ALIASID;
710 +        ofun[ALIAS].flags = 0;
711 +                                        /* functions get new transform */
712 +        for (i = 0; i < NUMTYPES; i++)
713 +                if (hasfunc(i))
714 +                        ofun[i].funp = addxform;
715 +                                        /* special cases */
716 +        ofun[OBJ_SOURCE].funp = o_source;
717 +        ofun[OBJ_SPHERE].funp =
718 +        ofun[OBJ_BUBBLE].funp = o_sphere;
719 +        ofun[OBJ_FACE].funp = o_face;
720 +        ofun[OBJ_CONE].funp =
721 +        ofun[OBJ_CUP].funp = o_cone;
722 +        ofun[OBJ_CYLINDER].funp =
723 +        ofun[OBJ_TUBE].funp = o_cylinder;
724 +        ofun[OBJ_RING].funp = o_ring;
725 +        ofun[OBJ_INSTANCE].funp = addxform;
726 +        ofun[MAT_GLOW].funp = m_glow;
727 +        ofun[MAT_SPOT].funp = m_spot;
728 +        ofun[MAT_DIELECTRIC].funp = m_dielectric;
729 +        ofun[MAT_INTERFACE].funp = m_interface;
730 +        ofun[PAT_CTEXT].funp =
731 +        ofun[PAT_BTEXT].funp =
732 +        ofun[MIX_TEXT].funp = text;
733 +        ofun[ALIAS].funp = alias;
734   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines