--- ray/src/gen/genworm.c 1990/03/07 11:14:39 1.4 +++ ray/src/gen/genworm.c 2003/08/04 22:37:53 2.6 @@ -1,9 +1,6 @@ #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: genworm.c,v 2.6 2003/08/04 22:37:53 greg Exp $"; #endif - -/* Copyright (c) 1989 Regents of the University of California */ - /* * genworm.c - program to generate worms (strings with varying thickness). * @@ -15,22 +12,22 @@ static char SCCSid[] = "$SunId$ LBL"; */ #include - +#include +#include "calcomp.h" #include "fvect.h" -#define XNAME "X_" /* x function name */ -#define YNAME "Y_" /* y function name */ -#define ZNAME "Z_" /* z function name */ -#define RNAME "R_" /* r function name */ +#define XNAME "X`SYS`" /* x function name */ +#define YNAME "Y`SYS`" /* y function name */ +#define ZNAME "Z`SYS`" /* z function name */ +#define RNAME "R`SYS`" /* r function name */ #define PI 3.14159265358979323846 -#define FTINY 1e-7 - #define max(a,b) ((a) > (b) ? (a) : (b)) -double funvalue(), l_hermite(), l_bezier(), l_bspline(), argument(); +double l_hermite(char *), l_bezier(char *), l_bspline(char *); +void quit(); main(argc, argv) @@ -42,35 +39,36 @@ char *argv[]; FVECT lastp, p; int i, nseg; - varset("PI", PI, NULL); - funset("hermite", 5, l_hermite); - funset("bezier", 5, l_bezier); - funset("bspline", 5, l_bspline); + varset("PI", ':', PI); + funset("hermite", 5, ':', l_hermite); + funset("bezier", 5, ':', l_bezier); + funset("bspline", 5, ':', l_bspline); if (argc < 8) goto userror; for (i = 8; i < argc; i++) if (!strcmp(argv[i], "-e")) - scompile(NULL, argv[++i]); + scompile(argv[++i], NULL, 0); else if (!strcmp(argv[i], "-f")) fcompile(argv[++i]); else goto userror; sprintf(stmp, "%s(t)=%s;", XNAME, argv[3]); - scompile(NULL, stmp); + scompile(stmp, NULL, 0); sprintf(stmp, "%s(t)=%s;", YNAME, argv[4]); - scompile(NULL, stmp); + scompile(stmp, NULL, 0); sprintf(stmp, "%s(t)=%s;", ZNAME, argv[5]); - scompile(NULL, stmp); + scompile(stmp, NULL, 0); sprintf(stmp, "%s(t)=%s;", RNAME, argv[6]); - scompile(NULL, stmp); + scompile(stmp, NULL, 0); nseg = atoi(argv[7]); if (nseg <= 0) goto userror; printhead(argc, argv); + eclock = 0; for (i = 0; i <= nseg; i++) { t = (double)i/nseg; @@ -78,7 +76,7 @@ char *argv[]; p[1] = funvalue(YNAME, 1, &t); p[2] = funvalue(ZNAME, 1, &t); r = funvalue(RNAME, 1, &t); - if (i) + if (i) { if (lastr <= r+FTINY && lastr >= r-FTINY) { printf("\n%s cylinder %s.c%d\n", argv[1], argv[2], i); @@ -105,6 +103,7 @@ char *argv[]; f = f <= 0.0 ? 0.0 : sqrt(f); printf("%18.12g %18.12g\n", f*lastr, f*r); } + } printf("\n%s sphere %s.s%d\n", argv[1], argv[2], i); printf("0\n0\n4 %18.12g %18.12g %18.12g %18.12g\n", p[0], p[1], p[2], r); @@ -121,6 +120,7 @@ userror: } +void eputs(msg) char *msg; { @@ -128,6 +128,7 @@ char *msg; } +void wputs(msg) char *msg; { @@ -135,7 +136,9 @@ char *msg; } +void quit(code) +int code; { exit(code); } @@ -155,7 +158,7 @@ register char **av; double -l_hermite() +l_hermite(char *nm) { double t; @@ -168,7 +171,7 @@ l_hermite() double -l_bezier() +l_bezier(char *nm) { double t; @@ -181,7 +184,7 @@ l_bezier() double -l_bspline() +l_bspline(char *nm) { double t;