| 2 |
|
static const char RCSid[] = "$Id$"; |
| 3 |
|
#endif |
| 4 |
|
/* |
| 5 |
< |
* rtmain.c - main for rtrace per-ray calculation program |
| 5 |
> |
* rxtmain.c - main for per-ray calculation program |
| 6 |
|
*/ |
| 7 |
|
|
| 8 |
|
#include "copyright.h" |
| 43 |
|
char *tralist[MAXMODLIST]; /* list of modifers to trace (or no) */ |
| 44 |
|
int traincl = -1; /* include == 1, exclude == 0 */ |
| 45 |
|
|
| 46 |
+ |
double (*sens_curve)(SCOLOR scol) = NULL; /* spectral conversion for 1-channel */ |
| 47 |
+ |
double out_scalefactor = 1; /* output calibration scale factor */ |
| 48 |
+ |
RGBPRIMP out_prims = stdprims; /* output color primitives (NULL if spectral) */ |
| 49 |
+ |
static RGBPRIMS our_prims; /* private output color primitives */ |
| 50 |
+ |
|
| 51 |
|
static void onsig(int signo); |
| 52 |
|
static void sigdie(int signo, const char *msg); |
| 53 |
|
static void printdefaults(void); |
| 54 |
|
|
| 55 |
< |
#define RATRACE_FEATURES "IrradianceCalc\nIrradianceCalc\nDistanceLimiting\n" \ |
| 56 |
< |
"HessianAmbientCache\nAmbientAveraging\n" \ |
| 57 |
< |
"AmbientValueSharing\nAdaptiveShadowTesting\n" \ |
| 58 |
< |
"Outputs=o,d,v,V,w,W,l,L,c,p,n,N,s,m,M,r,x,R,X,~\n" |
| 55 |
> |
#define RXTRACE_FEATURES "IrradianceCalc\nIrradianceCalc\nDistanceLimiting\n" \ |
| 56 |
> |
"HessianAmbientCache\nAmbientAveraging\n" \ |
| 57 |
> |
"AmbientValueSharing\nAdaptiveShadowTesting\n" \ |
| 58 |
> |
"Outputs=o,d,v,V,w,W,l,L,c,p,n,N,s,m,M,r,x,R,X,~\n" \ |
| 59 |
> |
"OutputCS=RGB,XYZ,Y,S,M,prims,spec\n" |
| 60 |
|
|
| 61 |
|
int |
| 62 |
|
main(int argc, char *argv[]) |
| 75 |
|
int rval; |
| 76 |
|
int i; |
| 77 |
|
/* global program name */ |
| 78 |
< |
progname = argv[0] = fixargv0(argv[0]); |
| 78 |
> |
progname = argv[0]; |
| 79 |
|
/* feature check only? */ |
| 80 |
< |
strcat(RFeatureList, RATRACE_FEATURES); |
| 80 |
> |
strcat(RFeatureList, RXTRACE_FEATURES); |
| 81 |
|
if (argc > 1 && !strcmp(argv[1], "-features")) |
| 82 |
|
return feature_status(argc-2, argv+2); |
| 83 |
|
/* add trace notify function */ |
| 227 |
|
goto badopt; |
| 228 |
|
} |
| 229 |
|
break; |
| 230 |
+ |
case 'p': /* value output */ |
| 231 |
+ |
switch (argv[i][2]) { |
| 232 |
+ |
case 'R': /* standard RGB output */ |
| 233 |
+ |
if (strcmp(argv[i]+2, "RGB")) |
| 234 |
+ |
goto badopt; |
| 235 |
+ |
out_prims = stdprims; |
| 236 |
+ |
out_scalefactor = 1; |
| 237 |
+ |
sens_curve = NULL; |
| 238 |
+ |
break; |
| 239 |
+ |
case 'X': /* XYZ output */ |
| 240 |
+ |
if (strcmp(argv[i]+2, "XYZ")) |
| 241 |
+ |
goto badopt; |
| 242 |
+ |
out_prims = xyzprims; |
| 243 |
+ |
out_scalefactor = WHTEFFICACY; |
| 244 |
+ |
sens_curve = NULL; |
| 245 |
+ |
break; |
| 246 |
+ |
case 'c': { |
| 247 |
+ |
int j; |
| 248 |
+ |
check(3,"ffffffff"); |
| 249 |
+ |
rval = 0; |
| 250 |
+ |
for (j = 0; j < 8; j++) { |
| 251 |
+ |
our_prims[0][j] = atof(argv[++i]); |
| 252 |
+ |
rval |= fabs(our_prims[0][j]-stdprims[0][j]) > .001; |
| 253 |
+ |
} |
| 254 |
+ |
if (rval) { |
| 255 |
+ |
if (!colorprimsOK(our_prims)) |
| 256 |
+ |
error(USER, "illegal primary chromaticities"); |
| 257 |
+ |
out_prims = our_prims; |
| 258 |
+ |
} else |
| 259 |
+ |
out_prims = stdprims; |
| 260 |
+ |
out_scalefactor = 1; |
| 261 |
+ |
sens_curve = NULL; |
| 262 |
+ |
} break; |
| 263 |
+ |
case 'Y': /* photopic response */ |
| 264 |
+ |
if (argv[i][3]) |
| 265 |
+ |
goto badopt; |
| 266 |
+ |
sens_curve = scolor_photopic; |
| 267 |
+ |
out_scalefactor = WHTEFFICACY; |
| 268 |
+ |
break; |
| 269 |
+ |
case 'S': /* scotopic response */ |
| 270 |
+ |
if (argv[i][3]) |
| 271 |
+ |
goto badopt; |
| 272 |
+ |
sens_curve = scolor_scotopic; |
| 273 |
+ |
out_scalefactor = WHTSCOTOPIC; |
| 274 |
+ |
break; |
| 275 |
+ |
case 'M': /* melanopic response */ |
| 276 |
+ |
if (argv[i][3]) |
| 277 |
+ |
goto badopt; |
| 278 |
+ |
sens_curve = scolor_melanopic; |
| 279 |
+ |
out_scalefactor = WHTMELANOPIC; |
| 280 |
+ |
break; |
| 281 |
+ |
default: |
| 282 |
+ |
goto badopt; |
| 283 |
+ |
} |
| 284 |
+ |
break; |
| 285 |
+ |
#if MAXCSAMP>3 |
| 286 |
+ |
case 'c': /* output spectral results */ |
| 287 |
+ |
if (argv[i][2] != 'o') |
| 288 |
+ |
goto badopt; |
| 289 |
+ |
rval = (out_prims == NULL) & (sens_curve == NULL); |
| 290 |
+ |
check_bool(3,rval); |
| 291 |
+ |
if (rval) { |
| 292 |
+ |
out_prims = NULL; |
| 293 |
+ |
sens_curve = NULL; |
| 294 |
+ |
} else if (out_prims == NULL) |
| 295 |
+ |
out_prims = stdprims; |
| 296 |
+ |
break; |
| 297 |
+ |
#endif |
| 298 |
|
default: |
| 299 |
|
goto badopt; |
| 300 |
|
} |
| 472 |
|
case '~': printf(" tilde"); break; |
| 473 |
|
} |
| 474 |
|
putchar('\n'); |
| 475 |
+ |
if (sens_curve == scolor_photopic) |
| 476 |
+ |
printf("-pY\t\t\t\t# photopic output\n"); |
| 477 |
+ |
else if (sens_curve == scolor_scotopic) |
| 478 |
+ |
printf("-pS\t\t\t\t# scotopic output\n"); |
| 479 |
+ |
else if (sens_curve == scolor_melanopic) |
| 480 |
+ |
printf("-pM\t\t\t\t# melanopic output\n"); |
| 481 |
+ |
else if (out_prims == stdprims) |
| 482 |
+ |
printf("-pRGB\t\t\t\t# standard RGB color output\n"); |
| 483 |
+ |
else if (out_prims == xyzprims) |
| 484 |
+ |
printf("-pXYZ\t\t\t\t# CIE XYZ color output\n"); |
| 485 |
+ |
else if (out_prims != NULL) |
| 486 |
+ |
printf("-pc %.4f %.4f %.4f %.4f %.4f %.4f %.4f %.4f\t# output color primaries and white point\n", |
| 487 |
+ |
out_prims[RED][0], out_prims[RED][1], |
| 488 |
+ |
out_prims[GRN][0], out_prims[GRN][1], |
| 489 |
+ |
out_prims[BLU][0], out_prims[BLU][1], |
| 490 |
+ |
out_prims[WHT][0], out_prims[WHT][1]); |
| 491 |
+ |
if ((sens_curve == NULL) & (NCSAMP > 3)) |
| 492 |
+ |
printf(out_prims != NULL ? "-co-\t\t\t\t# output tristimulus colors\n" : |
| 493 |
+ |
"-co+\t\t\t\t# output spectral values\n"); |
| 494 |
|
printf(erract[WARNING].pf != NULL ? |
| 495 |
|
"-w+\t\t\t\t# warning messages on\n" : |
| 496 |
|
"-w-\t\t\t\t# warning messages off\n"); |