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.4 by greg, Sat Feb 22 02:07:23 2003 UTC vs.
Revision 2.8 by greg, Sat Aug 21 11:54:06 2004 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  "resolu.h"
21 + #include  "rterror.h"
22   #include  "fvect.h"
23  
24   #define  XNAME          "X`SYS`"                /* x function name */
# Line 25 | Line 31 | static const char      RCSid[] = "$Id$";
31   #define  max(a,b)       ((a) > (b) ? (a) : (b))
32  
33  
34 < double  funvalue(), l_hermite(), l_bezier(), l_bspline(), argument();
35 < void  quit();
34 > /* XXX redundant, move to library */
35 > double  l_hermite(char *), l_bezier(char *), l_bspline(char *);
36  
37  
38 + int
39   main(argc, argv)
40   int  argc;
41   char  *argv[];
42   {
36        extern long     eclock;
43          char  stmp[256];
44 <        double  t, f, lastr, r;
44 >        double  t, f, lastr = 0, r;
45          FVECT  lastp, p;
46          int  i, nseg;
47  
# Line 67 | Line 73 | char  *argv[];
73          if (nseg <= 0)
74                  goto userror;
75  
76 <        printhead(argc, argv);
76 >        fputs("# ", stdout);
77 >        printargs(argc, argv, stdout);
78          eclock = 0;
79  
80          for (i = 0; i <= nseg; i++) {
# Line 76 | Line 83 | char  *argv[];
83                  p[1] = funvalue(YNAME, 1, &t);
84                  p[2] = funvalue(ZNAME, 1, &t);
85                  r = funvalue(RNAME, 1, &t);
86 <                if (i)
86 >                if (i) {
87                          if (lastr <= r+FTINY && lastr >= r-FTINY) {
88                                  printf("\n%s cylinder %s.c%d\n",
89                                                  argv[1], argv[2], i);
# Line 103 | Line 110 | char  *argv[];
110                                  f = f <= 0.0 ? 0.0 : sqrt(f);
111                                  printf("%18.12g %18.12g\n", f*lastr, f*r);
112                          }
113 +                }
114                  printf("\n%s sphere %s.s%d\n", argv[1], argv[2], i);
115                  printf("0\n0\n4 %18.12g %18.12g %18.12g %18.12g\n",
116                                  p[0], p[1], p[2], r);
117                  VCOPY(lastp, p);
118                  lastr = r;
119          }
120 <        quit(0);
120 >        return 0;
121  
122   userror:
123          fprintf(stderr,
124   "Usage: %s material name x(t) y(t) z(t) r(t) nseg [-e expr] [-f file]\n",
125                          argv[0]);
126 <        quit(1);
126 >        return 1;
127   }
128  
129  
122 void
123 eputs(msg)
124 char  *msg;
125 {
126        fputs(msg, stderr);
127 }
128
129
130 void
131 wputs(msg)
132 char  *msg;
133 {
134        eputs(msg);
135 }
136
137
138 void
139 quit(code)
140 int  code;
141 {
142        exit(code);
143 }
144
145
146 printhead(ac, av)               /* print command header */
147 register int  ac;
148 register char  **av;
149 {
150        putchar('#');
151        while (ac--) {
152                putchar(' ');
153                fputs(*av++, stdout);
154        }
155        putchar('\n');
156 }
157
158
130   double
131 < l_hermite()                    
131 > l_hermite(char *nm)
132   {
133          double  t;
134          
# Line 170 | Line 141 | l_hermite()                    
141  
142  
143   double
144 < l_bezier()
144 > l_bezier(char *nm)
145   {
146          double  t;
147  
# Line 183 | Line 154 | l_bezier()
154  
155  
156   double
157 < l_bspline()
157 > l_bspline(char *nm)
158   {
159          double  t;
160  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines