| 1 |  | #ifndef lint | 
| 2 | < | static char SCCSid[] = "$SunId$ LBL"; | 
| 2 | > | static const char       RCSid[] = "$Id$"; | 
| 3 |  | #endif | 
| 4 | – |  | 
| 5 | – | /* Copyright (c) 1989 Regents of the University of California */ | 
| 6 | – |  | 
| 4 |  | /* | 
| 5 |  | *  genworm.c - program to generate worms (strings with varying thickness). | 
| 6 |  | * | 
| 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  "fvect.h" | 
| 21 |  |  | 
| 22 |  | #define  XNAME          "X`SYS`"                /* x function name */ | 
| 29 |  | #define  max(a,b)       ((a) > (b) ? (a) : (b)) | 
| 30 |  |  | 
| 31 |  |  | 
| 32 | < | double  funvalue(), l_hermite(), l_bezier(), l_bspline(), argument(); | 
| 32 | > | /* XXX redundant, move to library */ | 
| 33 | > | double  l_hermite(char *), l_bezier(char *), l_bspline(char *); | 
| 34 |  |  | 
| 35 |  |  | 
| 36 | + | static void printhead(int  ac, char  **av); | 
| 37 | + |  | 
| 38 | + |  | 
| 39 | + | int | 
| 40 |  | main(argc, argv) | 
| 41 |  | int  argc; | 
| 42 |  | char  *argv[]; | 
| 43 |  | { | 
| 38 | – | 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 |  |  | 
| 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); | 
| 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 |  |  | 
| 130 | + | void | 
| 131 |  | eputs(msg) | 
| 132 |  | char  *msg; | 
| 133 |  | { | 
| 135 |  | } | 
| 136 |  |  | 
| 137 |  |  | 
| 138 | + | void | 
| 139 |  | wputs(msg) | 
| 140 |  | char  *msg; | 
| 141 |  | { | 
| 143 |  | } | 
| 144 |  |  | 
| 145 |  |  | 
| 146 | + | void | 
| 147 |  | quit(code) | 
| 148 | + | int  code; | 
| 149 |  | { | 
| 150 |  | exit(code); | 
| 151 |  | } | 
| 152 |  |  | 
| 153 |  |  | 
| 154 | < | printhead(ac, av)               /* print command header */ | 
| 155 | < | register int  ac; | 
| 156 | < | register char  **av; | 
| 154 | > | void | 
| 155 | > | printhead(              /* print command header */ | 
| 156 | > | register int  ac, | 
| 157 | > | register char  **av | 
| 158 | > | ) | 
| 159 |  | { | 
| 160 |  | putchar('#'); | 
| 161 |  | while (ac--) { | 
| 167 |  |  | 
| 168 |  |  | 
| 169 |  | double | 
| 170 | < | l_hermite() | 
| 170 | > | l_hermite(char *nm) | 
| 171 |  | { | 
| 172 |  | double  t; | 
| 173 |  |  | 
| 180 |  |  | 
| 181 |  |  | 
| 182 |  | double | 
| 183 | < | l_bezier() | 
| 183 | > | l_bezier(char *nm) | 
| 184 |  | { | 
| 185 |  | double  t; | 
| 186 |  |  | 
| 193 |  |  | 
| 194 |  |  | 
| 195 |  | double | 
| 196 | < | l_bspline() | 
| 196 | > | l_bspline(char *nm) | 
| 197 |  | { | 
| 198 |  | double  t; | 
| 199 |  |  |