--- ray/src/gen/mkillum2.c 2003/06/26 00:58:09 2.10 +++ ray/src/gen/mkillum2.c 2003/11/21 07:15:30 2.13 @@ -1,34 +1,52 @@ #ifndef lint -static const char RCSid[] = "$Id: mkillum2.c,v 2.10 2003/06/26 00:58:09 schorsch Exp $"; +static const char RCSid[] = "$Id: mkillum2.c,v 2.13 2003/11/21 07:15:30 greg Exp $"; #endif /* * Routines to do the actual calculation for mkillum */ +#include + #include "mkillum.h" #include "face.h" #include "cone.h" #include "random.h" -o_default(ob, il, rt, nm) /* default illum action */ -OBJREC *ob; -struct illum_args *il; -struct rtproc *rt; -char *nm; +int o_default(FUN_ARGLIST); +int o_face(FUN_ARGLIST); +int o_sphere(FUN_ARGLIST); +int o_ring(FUN_ARGLIST); +void raysamp(float res[3], FVECT org, FVECT dir, struct rtproc *rt); +void rayflush(struct rtproc *rt); +void mkaxes(FVECT u, FVECT v, FVECT n); +void rounddir(FVECT dv, double alt, double azi); +void flatdir(FVECT dv, double alt, double azi); + + +int /* XXX type conflict with otypes.h */ +o_default( /* default illum action */ + OBJREC *ob, + struct illum_args *il, + struct rtproc *rt, + char *nm +) { sprintf(errmsg, "(%s): cannot make illum for %s \"%s\"", nm, ofun[ob->otype].funame, ob->oname); error(WARNING, errmsg); printobj(il->altmat, ob); + return(1); } -o_face(ob, il, rt, nm) /* make an illum face */ -OBJREC *ob; -struct illum_args *il; -struct rtproc *rt; -char *nm; +int +o_face( /* make an illum face */ + OBJREC *ob, + struct illum_args *il, + struct rtproc *rt, + char *nm +) { #define MAXMISS (5*n*il->nsamps) int dim[3]; @@ -45,8 +63,7 @@ char *nm; fa = getface(ob); if (fa->area == 0.0) { freeface(ob); - o_default(ob, il, rt, nm); - return; + return(o_default(ob, il, rt, nm)); } /* set up sampling */ if (il->sampdens <= 0) @@ -113,8 +130,7 @@ char *nm; rt->nrays = 0; freeface(ob); free((void *)distarr); - o_default(ob, il, rt, nm); - return; + return(o_default(ob, il, rt, nm)); } for (j = 0; j < 3; j++) org[j] += .001*fa->norm[j]; @@ -136,11 +152,13 @@ char *nm; } -o_sphere(ob, il, rt, nm) /* make an illum sphere */ -register OBJREC *ob; -struct illum_args *il; -struct rtproc *rt; -char *nm; +int +o_sphere( /* make an illum sphere */ + register OBJREC *ob, + struct illum_args *il, + struct rtproc *rt, + char *nm +) { int dim[3]; int n, nalt, nazi; @@ -202,14 +220,17 @@ char *nm; printobj(il->altmat, ob); /* clean up */ free((void *)distarr); + return(1); } -o_ring(ob, il, rt, nm) /* make an illum ring */ -OBJREC *ob; -struct illum_args *il; -struct rtproc *rt; -char *nm; +int +o_ring( /* make an illum ring */ + OBJREC *ob, + struct illum_args *il, + struct rtproc *rt, + char *nm +) { int dim[3]; int n, nalt, nazi; @@ -271,13 +292,17 @@ char *nm; /* clean up */ freecone(ob); free((void *)distarr); + return(1); } -raysamp(res, org, dir, rt) /* compute a ray sample */ -float res[3]; -FVECT org, dir; -register struct rtproc *rt; +void +raysamp( /* compute a ray sample */ + float res[3], + FVECT org, + FVECT dir, + register struct rtproc *rt +) { register float *fp; @@ -290,14 +315,16 @@ register struct rtproc *rt; } -rayflush(rt) /* flush buffered rays */ -register struct rtproc *rt; +void +rayflush( /* flush buffered rays */ + register struct rtproc *rt +) { register int i; if (rt->nrays <= 0) return; - bzero(rt->buf+6*rt->nrays, 6*sizeof(float)); + memset(rt->buf+6*rt->nrays, '\0', 6*sizeof(float)); errno = 0; if ( process(&(rt->pd), (char *)rt->buf, (char *)rt->buf, 3*sizeof(float)*(rt->nrays+1), @@ -314,8 +341,12 @@ register struct rtproc *rt; } -mkaxes(u, v, n) /* compute u and v to go with n */ -FVECT u, v, n; +void +mkaxes( /* compute u and v to go with n */ + FVECT u, + FVECT v, + FVECT n +) { register int i; @@ -330,9 +361,12 @@ FVECT u, v, n; } -rounddir(dv, alt, azi) /* compute uniform spherical direction */ -register FVECT dv; -double alt, azi; +void +rounddir( /* compute uniform spherical direction */ + register FVECT dv, + double alt, + double azi +) { double d1, d2; @@ -344,9 +378,12 @@ double alt, azi; } -flatdir(dv, alt, azi) /* compute uniform hemispherical direction */ -register FVECT dv; -double alt, azi; +void +flatdir( /* compute uniform hemispherical direction */ + register FVECT dv, + double alt, + double azi +) { double d1, d2;