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

Comparing ray/src/common/spec_rgb.c (file contents):
Revision 2.25 by greg, Wed Aug 19 17:36:37 2020 UTC vs.
Revision 2.26 by greg, Wed Sep 16 00:42:36 2020 UTC

# Line 16 | Line 16 | static const char      RCSid[] = "$Id$";
16  
17   #define CEPS    1e-4                    /* color epsilon */
18  
19 < #define CEQ(v1,v2)      ((v1) <= (v2)+CEPS && (v2) <= (v1)+CEPS)
19 > #define CEQ(v1,v2)      (((v1) <= (v2)+CEPS) & ((v2) <= (v1)+CEPS))
20  
21 < #define XYEQ(c1,c2)     (CEQ((c1)[CIEX],(c2)[CIEX]) && CEQ((c1)[CIEY],(c2)[CIEY]))
21 > #define XYEQ(c1,c2)     (CEQ((c1)[CIEX],(c2)[CIEX]) & CEQ((c1)[CIEY],(c2)[CIEY]))
22  
23  
24   RGBPRIMS  stdprims = STDPRIMS;  /* standard primary chromaticities */
# Line 242 | Line 242 | RGBPRIMS  pr
242   )
243   {
244          int     i, j;
245 <        
245 >                                /* check white point */
246 >        if ((pr[3][CIEX] <= CEPS) | (pr[3][CIEX] >= 1.-CEPS) |
247 >                        (pr[3][CIEY] <= CEPS) | (pr[3][CIEY] >= 1.-CEPS))
248 >                return(0);
249 >        for (i = 3; i--; )      /* check for XYZ color primaries */
250 >                if (!CEQ(pr[i][CIEX],(i==0)) | !CEQ(pr[i][CIEY],(i==1)))
251 >                        break;
252 >        if (i < 0)
253 >                return(-1);     /* flag as XYZ color space */
254 >                                /* check color primaries */
255          for (i = 0; i < 3; i++) {
256                  if ((pr[i][CIEX] <= -2.) | (pr[i][CIEY] <= -2.))
257                          return(0);
# Line 253 | Line 262 | RGBPRIMS  pr
262                  if (pr[i][CIEX] + pr[i][CIEY] >= 3.)
263                          return(0);
264          }
265 <        if ((pr[3][CIEX] <= 0.) | (pr[3][CIEX] >= 1.) |
257 <                        (pr[3][CIEY] <= 0.) | (pr[3][CIEY] >= 1.))
258 <                return(0);
259 <        for (i = 0; i < 4; i++)
265 >        for (i = 0; i < 4; i++) /* make sure space is 3-dimensional */
266                  for (j = i+1; j < 4; j++)
267 <                        if (CEQ(pr[i][CIEX],pr[j][CIEX]) &&
267 >                        if (CEQ(pr[i][CIEX],pr[j][CIEX]) &
268                                          CEQ(pr[i][CIEY],pr[j][CIEY]))
269                                  return(0);
270          return(1);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines