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 |
|
* makedist.c - program to make a source distribution. |
6 |
|
* |
15 |
|
* Default axes are (x1,x2,x3) = (x,y,z). |
16 |
|
*/ |
17 |
|
|
18 |
< |
#include <stdio.h> |
18 |
> |
#include <stdlib.h> |
19 |
> |
#include <unistd.h> |
20 |
> |
#include <stdio.h> |
21 |
> |
#include <string.h> |
22 |
> |
#include <sys/types.h> |
23 |
> |
#include <sys/wait.h> |
24 |
|
|
25 |
+ |
#include "rtmath.h" |
26 |
|
#include "random.h" |
24 |
– |
|
27 |
|
#include "setscan.h" |
28 |
|
|
29 |
|
#ifndef BSD |
30 |
|
#define vfork fork |
31 |
|
#endif |
32 |
|
|
31 |
– |
#define FTINY 1e-7 |
32 |
– |
|
33 |
– |
#define PI 3.14159265358979324 |
34 |
– |
|
33 |
|
#define atorad(a) ((PI/180.0) * (a)) |
34 |
|
|
35 |
|
char *rtargv[128] = {"rtrace", "-h"}; |
37 |
|
|
38 |
|
#define passarg(s) (rtargv[rtargc++] = s) |
39 |
|
|
42 |
– |
/* default angles */ |
40 |
|
ANGLE alpha[181] = {10, 25, 40, 55, 70, 85, AEND}; |
41 |
|
ANGLE beta[361] = {0,30,60,90,120,150,180,210,240,270,300,330,AEND}; |
42 |
|
|
55 |
|
|
56 |
|
char *progname; /* program name */ |
57 |
|
|
58 |
+ |
static void printargs(int ac, char **av, FILE *fp); |
59 |
+ |
static void fixaxes(void); |
60 |
+ |
static int doscan(void); |
61 |
+ |
static FILE * scanstart(void); |
62 |
+ |
static int scanend(FILE *fp); |
63 |
+ |
static void sendsamples(FILE *fp); |
64 |
+ |
static void writesample(FILE *fp, ANGLE a, ANGLE b); |
65 |
+ |
static double readsample(FILE *fp); |
66 |
|
|
67 |
< |
main(argc, argv) |
68 |
< |
int argc; |
69 |
< |
char *argv[]; |
67 |
> |
|
68 |
> |
int |
69 |
> |
main( |
70 |
> |
int argc, |
71 |
> |
char *argv[] |
72 |
> |
) |
73 |
|
{ |
74 |
|
int i; |
75 |
|
|
218 |
|
|
219 |
|
fixaxes(); |
220 |
|
|
221 |
< |
if (header) |
222 |
< |
if (userformat > 0) |
221 |
> |
if (header) { |
222 |
> |
if (userformat > 0) { |
223 |
|
printf("Alpha\tBeta\tRadiance\n"); |
224 |
< |
else { |
224 |
> |
} else { |
225 |
|
printargs(argc, argv, stdout); |
226 |
|
putchar('\n'); |
227 |
|
} |
228 |
+ |
} |
229 |
|
|
230 |
|
if (doscan() == -1) |
231 |
|
exit(1); |
234 |
|
} |
235 |
|
|
236 |
|
|
237 |
< |
printargs(ac, av, fp) /* print arguments to a file */ |
238 |
< |
int ac; |
239 |
< |
char **av; |
240 |
< |
FILE *fp; |
237 |
> |
static void |
238 |
> |
printargs( /* print arguments to a file */ |
239 |
> |
int ac, |
240 |
> |
char **av, |
241 |
> |
FILE *fp |
242 |
> |
) |
243 |
|
{ |
244 |
|
while (ac-- > 0) { |
245 |
|
fputs(*av++, fp); |
249 |
|
} |
250 |
|
|
251 |
|
|
252 |
< |
fixaxes() /* make sure axes are OK */ |
252 |
> |
static void |
253 |
> |
fixaxes(void) /* make sure axes are OK */ |
254 |
|
{ |
243 |
– |
extern double normalize(), fdot(); |
255 |
|
double d; |
256 |
|
register int i; |
257 |
|
|
271 |
|
} |
272 |
|
|
273 |
|
|
274 |
< |
doscan() /* do scan for target */ |
274 |
> |
static int |
275 |
> |
doscan(void) /* do scan for target */ |
276 |
|
{ |
277 |
|
FILE *fopen(), *scanstart(); |
278 |
|
double readsample(); |
290 |
|
} |
291 |
|
|
292 |
|
|
293 |
< |
FILE * |
294 |
< |
scanstart() /* open scanner pipeline */ |
293 |
> |
static FILE * |
294 |
> |
scanstart(void) /* open scanner pipeline */ |
295 |
|
{ |
296 |
|
int status; |
297 |
|
char *fgets(); |
346 |
|
} |
347 |
|
|
348 |
|
|
349 |
< |
scanend(fp) /* done with scanner input */ |
350 |
< |
FILE *fp; |
349 |
> |
static int |
350 |
> |
scanend( /* done with scanner input */ |
351 |
> |
FILE *fp |
352 |
> |
) |
353 |
|
{ |
354 |
|
int status; |
355 |
|
|
362 |
|
} |
363 |
|
|
364 |
|
|
365 |
< |
sendsamples(fp) /* send our samples to fp */ |
366 |
< |
FILE *fp; |
365 |
> |
static void |
366 |
> |
sendsamples( /* send our samples to fp */ |
367 |
> |
FILE *fp |
368 |
> |
) |
369 |
|
{ |
370 |
|
ANGLE *a, *b; |
371 |
|
|
375 |
|
} |
376 |
|
|
377 |
|
|
378 |
< |
writesample(fp, a, b) /* write out sample ray grid */ |
379 |
< |
FILE *fp; |
380 |
< |
ANGLE a, b; |
378 |
> |
static void |
379 |
> |
writesample( /* write out sample ray grid */ |
380 |
> |
FILE *fp, |
381 |
> |
ANGLE a, |
382 |
> |
ANGLE b |
383 |
> |
) |
384 |
|
{ |
385 |
|
double sin(), cos(); |
386 |
|
float sp[6]; |
416 |
|
} |
417 |
|
|
418 |
|
|
419 |
< |
double |
420 |
< |
readsample(fp) /* read in sample ray grid */ |
421 |
< |
FILE *fp; |
419 |
> |
static double |
420 |
> |
readsample( /* read in sample ray grid */ |
421 |
> |
FILE *fp |
422 |
> |
) |
423 |
|
{ |
424 |
|
float col[3]; |
425 |
|
double sum; |