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.5 by schorsch, Mon Jul 21 22:30:18 2003 UTC vs.
Revision 2.11 by greg, Sat Dec 7 02:21:42 2019 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines