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

Comparing ray/src/cv/lampcolor.c (file contents):
Revision 2.5 by saba, Tue Jul 5 15:49:51 1994 UTC vs.
Revision 2.10 by greg, Thu Mar 18 05:22:00 2004 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   * 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 "rtmath.h"
13 + #include "rtio.h"
14   #include "color.h"
15  
17 #define PI      3.14159265358979323846
18
19 extern char     *gets(), *strcpy();
20 extern float    *matchlamp();
21
16                                  /* lamp parameters */
17   #define LTYPE           0
18   #define LUNIT           1
# Line 26 | Line 20 | extern float   *matchlamp();
20   #define LOUTP           3
21   #define NPARAMS         4
22  
23 < int     typecheck(), unitcheck(), geomcheck(), outpcheck();
23 > static int typecheck(char *s);
24 > static int unitcheck(char *s);
25 > static int geomcheck(char *s);
26 > static int outpcheck(char *s);
27 > static void compute(void);
28 > static int getpolygon(void), getsphere(void), getcylinder(void), getring(void);
29 > static int getd(char *name, double *dp, char *help);
30  
31 +
32   float   *lampcolor;             /* the lamp color (RGB) */
33   double  unit2meter;             /* conversion from units to meters */
34   double  area;                   /* radiating area for this geometry */
# Line 57 | Line 58 | for fluorescent fixtures." },
58   };
59  
60  
61 < main(argc, argv)
62 < int     argc;
63 < char    *argv[];
61 > int
62 > main(
63 >        int     argc,
64 >        char    *argv[]
65 > )
66   {
67          char    *lamptab = "lamp.tab";
68          char    buf[64];
# Line 76 | Line 79 | char   *argv[];
79                  while (i < NPARAMS) {
80                          printf("Enter %s [%s]: ", param[i].name,
81                                          param[i].value);
82 <                        if (gets(buf) == NULL)
82 >                        if (fgetline(buf, sizeof(buf), stdin) == NULL)
83                                  exit(0);
84                          if (buf[0] == '?') {
85                                  puts(param[i].help);
# Line 96 | Line 99 | char   *argv[];
99   }
100  
101  
102 < typecheck(s)                    /* check lamp type */
103 < char    *s;
102 > static int
103 > typecheck(                      /* check lamp type */
104 >        char    *s
105 > )
106   {
107          lampcolor = matchlamp(s);
108          return(lampcolor != NULL);
109   }
110  
111  
112 < unitcheck(s)                    /* compute conversion to meters */
113 < char    *s;
112 > static int
113 > unitcheck(                      /* compute conversion to meters */
114 >        char    *s
115 > )
116   {
117          int     len = strlen(s);
118  
# Line 135 | Line 142 | char   *s;
142   }
143  
144  
145 < geomcheck(s)                    /* check/set lamp geometry */
146 < char    *s;
145 > static int
146 > geomcheck(                      /* check/set lamp geometry */
147 >        char    *s
148 > )
149   {
150          int     len = strlen(s);
151  
# Line 162 | Line 171 | char   *s;
171   }
172  
173  
174 < outpcheck(s)                    /* check lumen output value */
175 < register char   *s;
174 > static int
175 > outpcheck(                      /* check lumen output value */
176 >        register char   *s
177 > )
178   {
179          if ((*s < '0' || *s > '9') && *s != '.')
180                  return(0);
# Line 172 | Line 183 | register char  *s;
183   }
184  
185  
186 < compute()                       /* compute lamp radiance */
186 > static void
187 > compute(void)                   /* compute lamp radiance */
188   {
189          double  whiteval;
190  
# Line 185 | Line 197 | compute()                      /* compute lamp radiance */
197   }
198  
199  
200 < getd(name, dp, help)            /* get a positive double from stdin */
201 < char    *name;
202 < double  *dp;
203 < char    *help;
200 > static int
201 > getd(           /* get a positive double from stdin */
202 >        char    *name,
203 >        double  *dp,
204 >        char    *help
205 > )
206   {
207          char    buf[32];
208   again:
209          printf("%s [%g]: ", name, *dp);
210 <        if (gets(buf) == NULL)
210 >        if (fgets(buf, sizeof(buf), stdin) == NULL)
211                  return(0);
212          if (buf[0] == '?') {
213                  puts(help);
# Line 206 | Line 220 | again:
220   }
221  
222  
223 < getpolygon()                    /* get projected area for a polygon */
223 > static int
224 > getpolygon(void)                        /* get projected area for a polygon */
225   {
226          static double   parea = 1.0;
227  
# Line 217 | Line 232 | getpolygon()                   /* get projected area for a polygon */
232   }
233  
234  
235 < getsphere()                     /* get projected area for a sphere */
235 > static int
236 > getsphere(void)                 /* get projected area for a sphere */
237   {
238          static double   radius = 1.0;
239  
# Line 228 | Line 244 | getsphere()                    /* get projected area for a sphere */
244   }
245  
246  
247 < getcylinder()                   /* get projected area for a cylinder */
247 > static int
248 > getcylinder(void)                       /* get projected area for a cylinder */
249   {
250          static double   length = 1.0, radius = 0.1;
251  
# Line 241 | Line 258 | getcylinder()                  /* get projected area for a cylinder *
258   }
259  
260  
261 < getring()                       /* get projected area for a ring */
261 > static int
262 > getring(void)                   /* get projected area for a ring */
263   {
264          static double   radius = 1.0;
265  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines