ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/gen/mkillum2.c
(Generate patch)

Comparing ray/src/gen/mkillum2.c (file contents):
Revision 2.6 by greg, Fri Jan 7 14:51:46 1994 UTC vs.
Revision 2.13 by greg, Fri Nov 21 07:15:30 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1991 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   * Routines to do the actual calculation for mkillum
6   */
7  
8 < #include  "mkillum.h"
8 > #include <string.h>
9  
10 + #include  "mkillum.h"
11   #include  "face.h"
14
12   #include  "cone.h"
16
13   #include  "random.h"
14  
15  
16 < o_default(ob, il, rt, nm)       /* default illum action */
17 < OBJREC  *ob;
18 < struct illum_args  *il;
19 < struct rtproc  *rt;
20 < char  *nm;
16 > int o_default(FUN_ARGLIST);
17 > int o_face(FUN_ARGLIST);
18 > int o_sphere(FUN_ARGLIST);
19 > int o_ring(FUN_ARGLIST);
20 > void raysamp(float res[3], FVECT org, FVECT dir, struct rtproc *rt);
21 > void rayflush(struct rtproc *rt);
22 > void mkaxes(FVECT u, FVECT v, FVECT n);
23 > void rounddir(FVECT dv, double alt, double azi);
24 > void flatdir(FVECT dv, double alt, double azi);
25 >
26 >
27 > int /* XXX type conflict with otypes.h */
28 > o_default(      /* default illum action */
29 >        OBJREC  *ob,
30 >        struct illum_args  *il,
31 >        struct rtproc  *rt,
32 >        char  *nm
33 > )
34   {
35          sprintf(errmsg, "(%s): cannot make illum for %s \"%s\"",
36                          nm, ofun[ob->otype].funame, ob->oname);
37          error(WARNING, errmsg);
38          printobj(il->altmat, ob);
39 +        return(1);
40   }
41  
42  
43 < o_face(ob, il, rt, nm)          /* make an illum face */
44 < OBJREC  *ob;
45 < struct illum_args  *il;
46 < struct rtproc  *rt;
47 < char  *nm;
43 > int
44 > o_face(         /* make an illum face */
45 >        OBJREC  *ob,
46 >        struct illum_args  *il,
47 >        struct rtproc  *rt,
48 >        char  *nm
49 > )
50   {
51   #define MAXMISS         (5*n*il->nsamps)
52          int  dim[3];
# Line 51 | Line 63 | char  *nm;
63          fa = getface(ob);
64          if (fa->area == 0.0) {
65                  freeface(ob);
66 <                o_default(ob, il, rt, nm);
55 <                return;
66 >                return(o_default(ob, il, rt, nm));
67          }
68                                  /* set up sampling */
69          if (il->sampdens <= 0)
# Line 118 | Line 129 | char  *nm;
129                          objerror(ob, WARNING, "bad aspect");
130                          rt->nrays = 0;
131                          freeface(ob);
132 <                        free((char *)distarr);
133 <                        o_default(ob, il, rt, nm);
123 <                        return;
132 >                        free((void *)distarr);
133 >                        return(o_default(ob, il, rt, nm));
134                      }
135                      for (j = 0; j < 3; j++)
136                          org[j] += .001*fa->norm[j];
# Line 137 | Line 147 | char  *nm;
147                  printobj(il->altmat, ob);
148                                  /* clean up */
149          freeface(ob);
150 <        free((char *)distarr);
150 >        free((void *)distarr);
151   #undef MAXMISS
152   }
153  
154  
155 < o_sphere(ob, il, rt, nm)        /* make an illum sphere */
156 < register OBJREC  *ob;
157 < struct illum_args  *il;
158 < struct rtproc  *rt;
159 < char  *nm;
155 > int
156 > o_sphere(       /* make an illum sphere */
157 >        register OBJREC  *ob,
158 >        struct illum_args  *il,
159 >        struct rtproc  *rt,
160 >        char  *nm
161 > )
162   {
163          int  dim[3];
164          int  n, nalt, nazi;
# Line 163 | Line 175 | char  *nm;
175                  nalt = nazi = 1;
176          else {
177                  n = 4.*PI * il->sampdens;
178 <                nalt = sqrt(n/PI) + .5;
179 <                nazi = PI*nalt + .5;
178 >                nalt = sqrt(2./PI*n) + .5;
179 >                nazi = PI/2.*nalt + .5;
180          }
181          n = nalt*nazi;
182          distarr = (float *)calloc(n, 3*sizeof(float));
# Line 207 | Line 219 | char  *nm;
219          } else
220                  printobj(il->altmat, ob);
221                                  /* clean up */
222 <        free((char *)distarr);
222 >        free((void *)distarr);
223 >        return(1);
224   }
225  
226  
227 < o_ring(ob, il, rt, nm)          /* make an illum ring */
228 < OBJREC  *ob;
229 < struct illum_args  *il;
230 < struct rtproc  *rt;
231 < char  *nm;
227 > int
228 > o_ring(         /* make an illum ring */
229 >        OBJREC  *ob,
230 >        struct illum_args  *il,
231 >        struct rtproc  *rt,
232 >        char  *nm
233 > )
234   {
235          int  dim[3];
236          int  n, nalt, nazi;
# Line 276 | Line 291 | char  *nm;
291                  printobj(il->altmat, ob);
292                                  /* clean up */
293          freecone(ob);
294 <        free((char *)distarr);
294 >        free((void *)distarr);
295 >        return(1);
296   }
297  
298  
299 < raysamp(res, org, dir, rt)      /* compute a ray sample */
300 < float  res[3];
301 < FVECT  org, dir;
302 < register struct rtproc  *rt;
299 > void
300 > raysamp(        /* compute a ray sample */
301 >        float  res[3],
302 >        FVECT  org,
303 >        FVECT  dir,
304 >        register struct rtproc  *rt
305 > )
306   {
307          register float  *fp;
308  
# Line 296 | Line 315 | register struct rtproc  *rt;
315   }
316  
317  
318 < rayflush(rt)                    /* flush buffered rays */
319 < register struct rtproc  *rt;
318 > void
319 > rayflush(                       /* flush buffered rays */
320 >        register struct rtproc  *rt
321 > )
322   {
323          register int  i;
324  
325          if (rt->nrays <= 0)
326                  return;
327 <        bzero(rt->buf+6*rt->nrays, 6*sizeof(float));
327 >        memset(rt->buf+6*rt->nrays, '\0', 6*sizeof(float));
328          errno = 0;
329 <        if ( process(rt->pd, (char *)rt->buf, (char *)rt->buf,
330 <                        3*sizeof(float)*rt->nrays,
329 >        if ( process(&(rt->pd), (char *)rt->buf, (char *)rt->buf,
330 >                        3*sizeof(float)*(rt->nrays+1),
331                          6*sizeof(float)*(rt->nrays+1)) <
332 <                        3*sizeof(float)*rt->nrays )
332 >                        3*sizeof(float)*(rt->nrays+1) )
333                  error(SYSTEM, "error reading from rtrace process");
334          i = rt->nrays;
335          while (i--) {
# Line 320 | Line 341 | register struct rtproc  *rt;
341   }
342  
343  
344 < mkaxes(u, v, n)                 /* compute u and v to go with n */
345 < FVECT  u, v, n;
344 > void
345 > mkaxes(                 /* compute u and v to go with n */
346 >        FVECT  u,
347 >        FVECT  v,
348 >        FVECT  n
349 > )
350   {
351          register int  i;
352  
# Line 336 | Line 361 | FVECT  u, v, n;
361   }
362  
363  
364 < rounddir(dv, alt, azi)          /* compute uniform spherical direction */
365 < register FVECT  dv;
366 < double  alt, azi;
364 > void
365 > rounddir(               /* compute uniform spherical direction */
366 >        register FVECT  dv,
367 >        double  alt,
368 >        double  azi
369 > )
370   {
371          double  d1, d2;
372  
# Line 350 | Line 378 | double  alt, azi;
378   }
379  
380  
381 < flatdir(dv, alt, azi)           /* compute uniform hemispherical direction */
382 < register FVECT  dv;
383 < double  alt, azi;
381 > void
382 > flatdir(                /* compute uniform hemispherical direction */
383 >        register FVECT  dv,
384 >        double  alt,
385 >        double  azi
386 > )
387   {
388          double  d1, d2;
389  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines