--- ray/src/gen/mkillum2.c 1994/01/07 14:51:46 2.6 +++ ray/src/gen/mkillum2.c 2003/11/16 10:29:38 2.12 @@ -1,27 +1,35 @@ -/* Copyright (c) 1991 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: mkillum2.c,v 2.12 2003/11/16 10:29:38 schorsch Exp $"; #endif - /* * Routines to do the actual calculation for mkillum */ -#include "mkillum.h" +#include +#include "mkillum.h" #include "face.h" - #include "cone.h" - #include "random.h" +//void o_default(OBJREC *ob, struct illum_args *il, struct rtproc *rt, char *nm); +void o_face(OBJREC *ob, struct illum_args *il, struct rtproc *rt, char *nm); +void o_sphere(OBJREC *ob, struct illum_args *il, struct rtproc *rt, char *nm); +void o_ring(OBJREC *ob, struct illum_args *il, struct rtproc *rt, char *nm); +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); -o_default(ob, il, rt, nm) /* default illum action */ -OBJREC *ob; -struct illum_args *il; -struct rtproc *rt; -char *nm; + +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); @@ -30,11 +38,13 @@ char *nm; } -o_face(ob, il, rt, nm) /* make an illum face */ -OBJREC *ob; -struct illum_args *il; -struct rtproc *rt; -char *nm; +void +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]; @@ -118,7 +128,7 @@ char *nm; objerror(ob, WARNING, "bad aspect"); rt->nrays = 0; freeface(ob); - free((char *)distarr); + free((void *)distarr); o_default(ob, il, rt, nm); return; } @@ -137,16 +147,18 @@ char *nm; printobj(il->altmat, ob); /* clean up */ freeface(ob); - free((char *)distarr); + free((void *)distarr); #undef MAXMISS } -o_sphere(ob, il, rt, nm) /* make an illum sphere */ -register OBJREC *ob; -struct illum_args *il; -struct rtproc *rt; -char *nm; +void +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; @@ -163,8 +175,8 @@ char *nm; nalt = nazi = 1; else { n = 4.*PI * il->sampdens; - nalt = sqrt(n/PI) + .5; - nazi = PI*nalt + .5; + nalt = sqrt(2./PI*n) + .5; + nazi = PI/2.*nalt + .5; } n = nalt*nazi; distarr = (float *)calloc(n, 3*sizeof(float)); @@ -207,15 +219,17 @@ char *nm; } else printobj(il->altmat, ob); /* clean up */ - free((char *)distarr); + free((void *)distarr); } -o_ring(ob, il, rt, nm) /* make an illum ring */ -OBJREC *ob; -struct illum_args *il; -struct rtproc *rt; -char *nm; +void +o_ring( /* make an illum ring */ + OBJREC *ob, + struct illum_args *il, + struct rtproc *rt, + char *nm +) { int dim[3]; int n, nalt, nazi; @@ -276,14 +290,17 @@ char *nm; printobj(il->altmat, ob); /* clean up */ freecone(ob); - free((char *)distarr); + free((void *)distarr); } -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; @@ -296,19 +313,21 @@ 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, + if ( process(&(rt->pd), (char *)rt->buf, (char *)rt->buf, + 3*sizeof(float)*(rt->nrays+1), 6*sizeof(float)*(rt->nrays+1)) < - 3*sizeof(float)*rt->nrays ) + 3*sizeof(float)*(rt->nrays+1) ) error(SYSTEM, "error reading from rtrace process"); i = rt->nrays; while (i--) { @@ -320,8 +339,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; @@ -336,9 +359,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; @@ -350,9 +376,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;