9 |
|
* orientation. |
10 |
|
*/ |
11 |
|
|
12 |
< |
#include <stdio.h> |
13 |
< |
#include <string.h> |
14 |
< |
#include <stdlib.h> |
12 |
> |
#include "rtio.h" |
13 |
> |
#include <stdlib.h> |
14 |
|
#include <math.h> |
15 |
|
#include <ctype.h> |
16 |
|
|
35 |
|
int iscomplete = 0; /* polygon is already completed */ |
36 |
|
double crad = 0.0; /* radius for corners (sign from lvdir) */ |
37 |
|
|
38 |
< |
extern double compute_rounding(); |
38 |
> |
static double compute_rounding(void); |
39 |
|
|
40 |
|
|
41 |
|
static void |
42 |
< |
readverts(fname) /* read vertices from a file */ |
44 |
< |
char *fname; |
42 |
> |
readverts(char *fname) /* read vertices from a file */ |
43 |
|
{ |
44 |
|
FILE *fp; |
45 |
|
|
56 |
|
|
57 |
|
|
58 |
|
static void |
59 |
< |
side(n0, n1) /* print single side */ |
62 |
< |
register int n0, n1; |
59 |
> |
side(int n0, int n1) /* print single side */ |
60 |
|
{ |
61 |
|
printf("\n%s polygon %s.%d\n", pmtype, pname, n0+1); |
62 |
|
printf("0\n0\n12\n"); |
72 |
|
|
73 |
|
|
74 |
|
static void |
75 |
< |
rside(n0, n1) /* print side with rounded edge */ |
79 |
< |
register int n0, n1; |
75 |
> |
rside(int n0, int n1) /* print side with rounded edge */ |
76 |
|
{ |
77 |
|
double s, c, t[3]; |
78 |
|
|
122 |
|
|
123 |
|
|
124 |
|
static double |
125 |
< |
compute_rounding() /* compute vectors for rounding operations */ |
125 |
> |
compute_rounding(void) /* compute vectors for rounding operations */ |
126 |
|
{ |
127 |
< |
register int i; |
128 |
< |
register double *v0, *v1; |
127 |
> |
int i; |
128 |
> |
double *v0, *v1; |
129 |
|
double l, asum; |
130 |
|
|
131 |
|
v0 = vert[nverts-1]; |
166 |
|
|
167 |
|
|
168 |
|
static void |
169 |
< |
printends() /* print ends of prism */ |
169 |
> |
printends(void) /* print ends of prism */ |
170 |
|
{ |
171 |
< |
register int i; |
171 |
> |
int i; |
172 |
|
/* bottom face */ |
173 |
|
printf("\n%s polygon %s.b\n", pmtype, pname); |
174 |
|
printf("0\n0\n%d\n", nverts*3); |
185 |
|
|
186 |
|
|
187 |
|
static void |
188 |
< |
printrends() /* print ends of prism with rounding */ |
188 |
> |
printrends(void) /* print ends of prism with rounding */ |
189 |
|
{ |
190 |
< |
register int i; |
190 |
> |
int i; |
191 |
|
double c0[3], c1[3], cl[3]; |
192 |
|
/* bottom face */ |
193 |
|
printf("\n%s polygon %s.b\n", pmtype, pname); |
265 |
|
|
266 |
|
|
267 |
|
static void |
268 |
< |
printsides(round) /* print prism sides */ |
273 |
< |
int round; |
268 |
> |
printsides(int round) /* print prism sides */ |
269 |
|
{ |
270 |
< |
register int i; |
270 |
> |
int i; |
271 |
|
|
272 |
|
for (i = 0; i < nverts-1; i++) |
273 |
|
if (round) |
274 |
|
rside(i, i+1); |
275 |
|
else |
276 |
|
side(i, i+1); |
277 |
< |
if (!iscomplete) |
277 |
> |
if (!iscomplete) { |
278 |
|
if (round) |
279 |
|
rside(nverts-1, 0); |
280 |
|
else |
281 |
|
side(nverts-1, 0); |
287 |
– |
} |
288 |
– |
|
289 |
– |
|
290 |
– |
static void |
291 |
– |
printhead(ac, av) /* print command header */ |
292 |
– |
register int ac; |
293 |
– |
register char **av; |
294 |
– |
{ |
295 |
– |
putchar('#'); |
296 |
– |
while (ac--) { |
297 |
– |
putchar(' '); |
298 |
– |
fputs(*av++, stdout); |
282 |
|
} |
300 |
– |
putchar('\n'); |
283 |
|
} |
284 |
|
|
285 |
|
|
286 |
< |
main(argc, argv) |
287 |
< |
int argc; |
306 |
< |
char **argv; |
286 |
> |
int |
287 |
> |
main(int argc, char **argv) |
288 |
|
{ |
289 |
|
int an; |
290 |
|
|
357 |
|
} |
358 |
|
crad *= lvdir; /* simplifies formulas */ |
359 |
|
compute_rounding(); |
360 |
< |
printhead(argc, argv); |
360 |
> |
fputs("# ", stdout); |
361 |
> |
printargs(argc, argv, stdout); |
362 |
|
if (do_ends) |
363 |
|
printrends(); |
364 |
|
printsides(1); |
365 |
|
} else { |
366 |
< |
printhead(argc, argv); |
366 |
> |
fputs("# ", stdout); |
367 |
> |
printargs(argc, argv, stdout); |
368 |
|
if (do_ends) |
369 |
|
printends(); |
370 |
|
printsides(0); |
371 |
|
} |
372 |
< |
exit(0); |
372 |
> |
return(0); |
373 |
|
userr: |
374 |
|
fprintf(stderr, "Usage: %s material name ", argv[0]); |
375 |
|
fprintf(stderr, "{ - | vfile | N v1 v2 .. vN } "); |
376 |
|
fprintf(stderr, "[-l lvect][-r radius][-c][-e]\n"); |
377 |
< |
exit(1); |
377 |
> |
return(1); |
378 |
|
} |
379 |
|
|