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

Comparing ray/src/util/scanner.c (file contents):
Revision 1.4 by schorsch, Thu Jun 26 00:58:11 2003 UTC vs.
Revision 1.5 by schorsch, Fri Mar 26 23:34:23 2004 UTC

# Line 8 | Line 8 | static const char      RCSid[] = "$Id$";
8   */
9  
10   #include  <stdio.h>
11 <
11 > #include  <string.h>
12   #include  <stdlib.h>
13
13   #include  <ctype.h>
15
14   #include  <signal.h>
15 + #include  <math.h>
16 + #include  <unistd.h> /* XXX pipe() fork() etc, use common/process.c instead */
17  
18   #include  "random.h"
19  
# Line 33 | Line 33 | char  *sourcetemp,                     /* temp files */
33  
34   ANGLE  alpha[181] = {90, AEND};
35   ANGLE  beta[181] = {30, 60, 90, 120, 150, AEND};
36 < ANGLE  gamma[181] = {45, AEND};
36 > ANGLE  sgamma[181] = {45, AEND}; /* gamma() is a function from gnu <math.h> */
37  
38   char  *target;                          /* target file name */
39   double  targetw = 3.0;                  /* target width (inches) */
# Line 42 | Line 42 | int  xres = 16;                                /* x sample resolution */
42   int  yres = 16;                         /* y sample resolution */
43  
44   static void  quit(int code);
45 + static void setscan(ANGLE  *ang, char  *arg);
46 + static void doscan(void);
47 + static void scanend(FILE  *fp);
48 + static void makesource(ANGLE  g);
49 + static void sendsamples(FILE  *fp);
50 + static void writesample(FILE    *fp, ANGLE      a, ANGLE        b);
51 + static FILE * scanstart(ANGLE  g);
52 + static double readsample(FILE  *fp);
53  
54 < main(argc, argv)
55 < int  argc;
56 < char  *argv[];
54 > int
55 > main(
56 >        int  argc,
57 >        char  *argv[]
58 > )
59   {
50        char  *strcat(), *mktemp();
60          int  i;
61  
62   #ifdef SIGHUP
# Line 99 | Line 108 | char  *argv[];
108                          break;
109                  case 'g':
110                          if (!strcmp(argv[i], "-gamma"))
111 <                                setscan(gamma, argv[++i]);
111 >                                setscan(sgamma, argv[++i]);
112                          else
113                                  goto badopt;
114                          break;
# Line 149 | Line 158 | badopt:
158          doscan();
159  
160          quit(0);
161 +        return 0; /* pro forma return */
162   }
163  
164  
165   void
166 < quit(code)                      /* unlink temp files and exit */
167 < int  code;
166 > quit(                   /* unlink temp files and exit */
167 >        int  code
168 > )
169   {
159        int  i;
160
170          unlink(sourcetemp);
171          unlink(octreetemp);
172          exit(code);
173   }
174  
175  
176 < setscan(ang, arg)                       /* set up scan according to arg */
177 < register ANGLE  *ang;
178 < register char  *arg;
176 > static void
177 > setscan(                        /* set up scan according to arg */
178 >        register ANGLE  *ang,
179 >        register char  *arg
180 > )
181   {
182          int  start = 0, finish = -1, step = 1;
183  
# Line 215 | Line 226 | register char  *arg;
226   }
227  
228  
229 < doscan()                                /* do scan for target */
229 > static void
230 > doscan(void)                            /* do scan for target */
231   {
220        FILE  *fopen(), *scanstart();
221        double  readsample();
232          FILE  *fp;
233          ANGLE  *a, *b, *g;
234  
235          printf("Alpha\tBeta\tGamma\tDistribution for \"%s\"\n", target);
236 <        for (g = gamma; *g != AEND; g++) {
236 >        for (g = sgamma; *g != AEND; g++) {
237                  fp = scanstart(*g);
238                  for (b = beta; *b != AEND; b++)         /* read data */
239                          for (a = alpha; *a != AEND; a++)
# Line 234 | Line 244 | doscan()                               /* do scan for target */
244   }
245  
246  
247 < FILE *
248 < scanstart(g)            /* open scanner pipeline */
249 < ANGLE  g;
247 > static FILE *
248 > scanstart(              /* open scanner pipeline */
249 >        ANGLE  g
250 > )
251   {
241        char  *fgets();
252          int  p1[2], p2[2];
253          int  pid;
254          FILE  *fp;
# Line 288 | Line 298 | ANGLE  g;
298   err:
299          fprintf(stderr, "System error in scanstart\n");
300          quit(1);
301 +        return NULL; /* pro forma return */
302   }
303  
304  
305 < scanend(fp)             /* done with scanner input */
306 < FILE  *fp;
305 > static void
306 > scanend(                /* done with scanner input */
307 >        FILE  *fp
308 > )
309   {
310          fclose(fp);
311   }
312  
313  
314 < makesource(g)           /* make a source (output normalized) */
315 < ANGLE  g;
314 > static void
315 > makesource(             /* make a source (output normalized) */
316 >        ANGLE  g
317 > )
318   {
319 <        FILE  *fp, *fopen();
320 <        double  srcdir[3], sin(), cos();
319 >        FILE  *fp;
320 >        double  srcdir[3];
321  
322          srcdir[0] = sin(atorad(g));
323          srcdir[1] = 0.0;
# Line 320 | Line 335 | ANGLE  g;
335   }
336  
337  
338 < sendsamples(fp)                 /* send our samples to fp */
339 < FILE  *fp;
338 > static void
339 > sendsamples(                    /* send our samples to fp */
340 >        FILE  *fp
341 > )
342   {
343          ANGLE  *a, *b;
344  
# Line 331 | Line 348 | FILE  *fp;
348   }
349  
350  
351 < writesample(fp, a, b)           /* write out sample ray grid */
352 < FILE  *fp;
353 < ANGLE  a, b;
351 > static void
352 > writesample(            /* write out sample ray grid */
353 >        FILE    *fp,
354 >        ANGLE   a,
355 >        ANGLE   b
356 > )
357   {
338        double  sin(), cos();
358          float  sp[6];
359          int  i, j;
360  
# Line 359 | Line 378 | ANGLE  a, b;
378   }
379  
380  
381 < double
382 < readsample(fp)                  /* read in sample ray grid */
383 < FILE  *fp;
381 > static double
382 > readsample(                     /* read in sample ray grid */
383 >        FILE  *fp
384 > )
385   {
386          double  sum;
387          float  col[3];

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines