5 |
|
* Program to convert lamp color from table and compute radiance. |
6 |
|
*/ |
7 |
|
|
8 |
– |
#include <stdio.h> |
9 |
– |
#include <string.h> |
8 |
|
#include <math.h> |
9 |
|
|
10 |
< |
#include "standard.h" |
10 |
> |
#include "rtmath.h" |
11 |
> |
#include "rtio.h" |
12 |
|
#include "color.h" |
13 |
|
|
14 |
|
/* lamp parameters */ |
24 |
|
static int outpcheck(char *s); |
25 |
|
static void compute(void); |
26 |
|
static int getpolygon(void), getsphere(void), getcylinder(void), getring(void); |
27 |
+ |
static int getd(char *name, double *dp, char *help); |
28 |
|
|
29 |
|
|
30 |
|
float *lampcolor; /* the lamp color (RGB) */ |
56 |
|
}; |
57 |
|
|
58 |
|
|
59 |
< |
main(argc, argv) |
60 |
< |
int argc; |
61 |
< |
char *argv[]; |
59 |
> |
int |
60 |
> |
main( |
61 |
> |
int argc, |
62 |
> |
char *argv[] |
63 |
> |
) |
64 |
|
{ |
65 |
|
char *lamptab = "lamp.tab"; |
66 |
|
char buf[64]; |
77 |
|
while (i < NPARAMS) { |
78 |
|
printf("Enter %s [%s]: ", param[i].name, |
79 |
|
param[i].value); |
80 |
< |
if (gets(buf) == NULL) |
80 |
> |
if (fgetline(buf, sizeof(buf), stdin) == NULL) |
81 |
|
exit(0); |
82 |
|
if (buf[0] == '?') { |
83 |
|
puts(param[i].help); |
99 |
|
|
100 |
|
static int |
101 |
|
typecheck( /* check lamp type */ |
102 |
< |
char *s |
102 |
> |
char *s |
103 |
|
) |
104 |
|
{ |
105 |
|
lampcolor = matchlamp(s); |
109 |
|
|
110 |
|
static int |
111 |
|
unitcheck( /* compute conversion to meters */ |
112 |
< |
char *s |
112 |
> |
char *s |
113 |
|
) |
114 |
|
{ |
115 |
|
int len = strlen(s); |
142 |
|
|
143 |
|
static int |
144 |
|
geomcheck( /* check/set lamp geometry */ |
145 |
< |
char *s |
145 |
> |
char *s |
146 |
|
) |
147 |
|
{ |
148 |
|
int len = strlen(s); |
171 |
|
|
172 |
|
static int |
173 |
|
outpcheck( /* check lumen output value */ |
174 |
< |
register char *s |
174 |
> |
register char *s |
175 |
|
) |
176 |
|
{ |
177 |
|
if ((*s < '0' || *s > '9') && *s != '.') |
195 |
|
} |
196 |
|
|
197 |
|
|
198 |
< |
getd(name, dp, help) /* get a positive double from stdin */ |
199 |
< |
char *name; |
200 |
< |
double *dp; |
201 |
< |
char *help; |
198 |
> |
static int |
199 |
> |
getd( /* get a positive double from stdin */ |
200 |
> |
char *name, |
201 |
> |
double *dp, |
202 |
> |
char *help |
203 |
> |
) |
204 |
|
{ |
205 |
|
char buf[32]; |
206 |
|
again: |
207 |
|
printf("%s [%g]: ", name, *dp); |
208 |
< |
if (gets(buf) == NULL) |
208 |
> |
if (fgets(buf, sizeof(buf), stdin) == NULL) |
209 |
|
return(0); |
210 |
|
if (buf[0] == '?') { |
211 |
|
puts(help); |