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

Comparing ray/src/gen/genworm.c (file contents):
Revision 2.7 by schorsch, Sun Nov 16 10:29:38 2003 UTC vs.
Revision 2.13 by greg, Tue Dec 10 17:22:39 2024 UTC

# Line 12 | Line 12 | static const char      RCSid[] = "$Id$";
12   */
13  
14   #include  <stdlib.h>
15 #include  <stdio.h>
15   #include  <math.h>
17 #include  <string.h>
16  
17   #include  "calcomp.h"
18 + #include  "rtio.h"
19 + #include  "resolu.h"
20 + #include  "rterror.h"
21   #include  "fvect.h"
22  
23   #define  XNAME          "X`SYS`"                /* x function name */
# Line 33 | Line 34 | static const char      RCSid[] = "$Id$";
34   double  l_hermite(char *), l_bezier(char *), l_bspline(char *);
35  
36  
36 static void printhead(int  ac, char  **av);
37
38
37   int
38   main(argc, argv)
39   int  argc;
# Line 46 | Line 44 | char  *argv[];
44          FVECT  lastp, p;
45          int  i, nseg;
46  
47 +        esupport |= E_VARIABLE|E_FUNCTION|E_RCONST;
48 +        esupport &= ~(E_OUTCHAN|E_INCHAN);
49          varset("PI", ':', PI);
50          funset("hermite", 5, ':', l_hermite);
51          funset("bezier", 5, ':', l_bezier);
# Line 57 | Line 57 | char  *argv[];
57          for (i = 8; i < argc; i++)
58                  if (!strcmp(argv[i], "-e"))
59                          scompile(argv[++i], NULL, 0);
60 <                else if (!strcmp(argv[i], "-f"))
61 <                        fcompile(argv[++i]);
62 <                else
60 >                else if (!strcmp(argv[i], "-f")) {
61 >                        char  *fpath = getpath(argv[++i], getrlibpath(), 0);
62 >                        if (fpath == NULL) {
63 >                                fprintf(stderr, "%s: cannot find file '%s'\n",
64 >                                                argv[0], argv[i]);
65 >                                quit(1);
66 >                        }
67 >                        fcompile(fpath);
68 >                } else
69                          goto userror;
70  
71          sprintf(stmp, "%s(t)=%s;", XNAME, argv[3]);
# Line 70 | Line 76 | char  *argv[];
76          scompile(stmp, NULL, 0);
77          sprintf(stmp, "%s(t)=%s;", RNAME, argv[6]);
78          scompile(stmp, NULL, 0);
79 <        nseg = atoi(argv[7]);
79 >        nseg = eval(argv[7]) + .5;
80          if (nseg <= 0)
81                  goto userror;
82  
83 <        printhead(argc, argv);
84 <        eclock = 0;
83 >        fputs("# ", stdout);
84 >        printargs(argc, argv, stdout);
85 >        eclock = 1;
86  
87          for (i = 0; i <= nseg; i++) {
88                  t = (double)i/nseg;
# Line 124 | Line 131 | userror:
131   "Usage: %s material name x(t) y(t) z(t) r(t) nseg [-e expr] [-f file]\n",
132                          argv[0]);
133          return 1;
127 }
128
129
130 void
131 eputs(msg)
132 char  *msg;
133 {
134        fputs(msg, stderr);
135 }
136
137
138 void
139 wputs(msg)
140 char  *msg;
141 {
142        eputs(msg);
143 }
144
145
146 void
147 quit(code)
148 int  code;
149 {
150        exit(code);
151 }
152
153
154 void
155 printhead(              /* print command header */
156        register int  ac,
157        register char  **av
158 )
159 {
160        putchar('#');
161        while (ac--) {
162                putchar(' ');
163                fputs(*av++, stdout);
164        }
165        putchar('\n');
134   }
135  
136  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines