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 |
|
* Program to convert lamp color from table and compute radiance. |
6 |
|
*/ |
7 |
|
|
8 |
|
#include <stdio.h> |
9 |
< |
|
9 |
> |
#include <string.h> |
10 |
|
#include <math.h> |
11 |
|
|
12 |
+ |
#include "standard.h" |
13 |
|
#include "color.h" |
14 |
|
|
17 |
– |
#define PI 3.14159265358979323846 |
18 |
– |
|
19 |
– |
extern char *gets(), *strcpy(); |
20 |
– |
extern float *matchlamp(); |
21 |
– |
|
15 |
|
/* lamp parameters */ |
16 |
|
#define LTYPE 0 |
17 |
|
#define LUNIT 1 |
19 |
|
#define LOUTP 3 |
20 |
|
#define NPARAMS 4 |
21 |
|
|
22 |
< |
int typecheck(), unitcheck(), geomcheck(), outpcheck(); |
22 |
> |
static int typecheck(char *s); |
23 |
> |
static int unitcheck(char *s); |
24 |
> |
static int geomcheck(char *s); |
25 |
> |
static int outpcheck(char *s); |
26 |
> |
static void compute(void); |
27 |
> |
static int getpolygon(void), getsphere(void), getcylinder(void), getring(void); |
28 |
|
|
29 |
+ |
|
30 |
|
float *lampcolor; /* the lamp color (RGB) */ |
31 |
|
double unit2meter; /* conversion from units to meters */ |
32 |
|
double area; /* radiating area for this geometry */ |
38 |
|
int (*check)(); |
39 |
|
char *help; |
40 |
|
} param[NPARAMS] = { |
41 |
< |
{ "lamp type", "D65WHITE", typecheck, |
41 |
> |
{ "lamp type", "WHITE", typecheck, |
42 |
|
"The lamp type is a string which corresponds to one of the types registered\n\ |
43 |
< |
in the lamp table file. A value of \"D65WHITE\" means an uncolored source,\n\ |
43 |
> |
in the lamp table file. A value of \"WHITE\" means an uncolored source,\n\ |
44 |
|
which may be preferable because it results in a color balanced image." }, |
45 |
|
{ "length unit", "meter", unitcheck, |
46 |
|
"Unit must be one of: \"meter\", \"centimeter\", \"foot\", or \"inch\".\n\ |
95 |
|
} |
96 |
|
|
97 |
|
|
98 |
< |
typecheck(s) /* check lamp type */ |
99 |
< |
char *s; |
98 |
> |
static int |
99 |
> |
typecheck( /* check lamp type */ |
100 |
> |
char *s |
101 |
> |
) |
102 |
|
{ |
103 |
|
lampcolor = matchlamp(s); |
104 |
|
return(lampcolor != NULL); |
105 |
|
} |
106 |
|
|
107 |
|
|
108 |
< |
unitcheck(s) /* compute conversion to meters */ |
109 |
< |
char *s; |
108 |
> |
static int |
109 |
> |
unitcheck( /* compute conversion to meters */ |
110 |
> |
char *s |
111 |
> |
) |
112 |
|
{ |
113 |
|
int len = strlen(s); |
114 |
|
|
138 |
|
} |
139 |
|
|
140 |
|
|
141 |
< |
geomcheck(s) /* check/set lamp geometry */ |
142 |
< |
char *s; |
141 |
> |
static int |
142 |
> |
geomcheck( /* check/set lamp geometry */ |
143 |
> |
char *s |
144 |
> |
) |
145 |
|
{ |
146 |
|
int len = strlen(s); |
147 |
|
|
167 |
|
} |
168 |
|
|
169 |
|
|
170 |
< |
outpcheck(s) /* check lumen output value */ |
171 |
< |
register char *s; |
170 |
> |
static int |
171 |
> |
outpcheck( /* check lumen output value */ |
172 |
> |
register char *s |
173 |
> |
) |
174 |
|
{ |
175 |
|
if ((*s < '0' || *s > '9') && *s != '.') |
176 |
|
return(0); |
179 |
|
} |
180 |
|
|
181 |
|
|
182 |
< |
compute() /* compute lamp radiance */ |
182 |
> |
static void |
183 |
> |
compute(void) /* compute lamp radiance */ |
184 |
|
{ |
185 |
|
double whiteval; |
186 |
|
|
214 |
|
} |
215 |
|
|
216 |
|
|
217 |
< |
getpolygon() /* get projected area for a polygon */ |
217 |
> |
static int |
218 |
> |
getpolygon(void) /* get projected area for a polygon */ |
219 |
|
{ |
220 |
|
static double parea = 1.0; |
221 |
|
|
226 |
|
} |
227 |
|
|
228 |
|
|
229 |
< |
getsphere() /* get projected area for a sphere */ |
229 |
> |
static int |
230 |
> |
getsphere(void) /* get projected area for a sphere */ |
231 |
|
{ |
232 |
|
static double radius = 1.0; |
233 |
|
|
238 |
|
} |
239 |
|
|
240 |
|
|
241 |
< |
getcylinder() /* get projected area for a cylinder */ |
241 |
> |
static int |
242 |
> |
getcylinder(void) /* get projected area for a cylinder */ |
243 |
|
{ |
244 |
|
static double length = 1.0, radius = 0.1; |
245 |
|
|
252 |
|
} |
253 |
|
|
254 |
|
|
255 |
< |
getring() /* get projected area for a ring */ |
255 |
> |
static int |
256 |
> |
getring(void) /* get projected area for a ring */ |
257 |
|
{ |
258 |
|
static double radius = 1.0; |
259 |
|
|