9 |
|
|
10 |
|
#define _USE_MATH_DEFINES |
11 |
|
#include <stdlib.h> |
12 |
– |
#include <string.h> |
12 |
|
#include <math.h> |
13 |
|
#include "rtio.h" |
14 |
|
#include "resolu.h" |
53 |
|
/* current input direction */ |
54 |
|
double theta_in_deg, phi_in_deg; |
55 |
|
|
56 |
+ |
/* header line sharing callback */ |
57 |
+ |
int (*sir_headshare)(char *s) = NULL; |
58 |
+ |
|
59 |
|
/* Register new input direction */ |
60 |
|
int |
61 |
|
new_input_direction(double new_theta, double new_phi) |
312 |
|
} |
313 |
|
res += val; |
314 |
|
} |
315 |
< |
if ((rbf_colorimetry == RBCtristimulus) & (res > 1e-6)) { |
315 |
> |
sv->cieY = res / COSF(outvec[2]); |
316 |
> |
if (sv->cieY < bsdf_min) { /* never return less than bsdf_min */ |
317 |
> |
sv->cieY = bsdf_min; |
318 |
> |
} else if (rbf_colorimetry == RBCtristimulus) { |
319 |
|
C_CHROMA cres = (int)(usum/res + frandom()); |
320 |
|
cres |= (int)(vsum/res + frandom()) << 8; |
321 |
|
c_decodeChroma(&sv->spec, cres); |
322 |
|
} |
318 |
– |
sv->cieY = res / COSF(outvec[2]); |
319 |
– |
if (sv->cieY < bsdf_min) /* never return less than bsdf_min */ |
320 |
– |
sv->cieY = bsdf_min; |
323 |
|
return(SDEnone); |
324 |
|
} |
325 |
|
|
584 |
|
input_orient = output_orient = 0; |
585 |
|
rbf_colorimetry = RBCunknown; |
586 |
|
grid_res = GRIDRES; |
587 |
+ |
memset(bsdf_hist, 0, sizeof(bsdf_hist)); |
588 |
|
bsdf_min = 0; |
589 |
|
bsdf_spec_val = 0; |
590 |
|
bsdf_spec_rad = 0; |
661 |
|
static int |
662 |
|
headline(char *s, void *p) |
663 |
|
{ |
664 |
< |
char fmt[64]; |
664 |
> |
char fmt[MAXFMTLEN]; |
665 |
|
int i; |
666 |
|
|
667 |
+ |
if (isheadid(s)) |
668 |
+ |
return(0); |
669 |
|
if (!strncmp(s, "NAME=", 5)) { |
670 |
|
strcpy(bsdf_name, s+5); |
671 |
|
bsdf_name[strlen(bsdf_name)-1] = '\0'; |
672 |
+ |
return(1); |
673 |
|
} |
674 |
|
if (!strncmp(s, "MANUFACT=", 9)) { |
675 |
|
strcpy(bsdf_manuf, s+9); |
676 |
|
bsdf_manuf[strlen(bsdf_manuf)-1] = '\0'; |
677 |
+ |
return(1); |
678 |
|
} |
679 |
|
if (!strncmp(s, "SYMMETRY=", 9)) { |
680 |
|
inp_coverage = atoi(s+9); |
681 |
|
single_plane_incident = !inp_coverage; |
682 |
< |
return(0); |
682 |
> |
return(1); |
683 |
|
} |
684 |
|
if (!strncmp(s, "IO_SIDES=", 9)) { |
685 |
|
sscanf(s+9, "%d %d", &input_orient, &output_orient); |
686 |
< |
return(0); |
686 |
> |
return(1); |
687 |
|
} |
688 |
|
if (!strncmp(s, "COLORIMETRY=", 12)) { |
689 |
|
fmt[0] = '\0'; |
694 |
|
if (i < 0) |
695 |
|
return(-1); |
696 |
|
rbf_colorimetry = i; |
697 |
< |
return(0); |
697 |
> |
return(1); |
698 |
|
} |
699 |
|
if (!strncmp(s, "GRIDRES=", 8)) { |
700 |
|
sscanf(s+8, "%d", &grid_res); |
701 |
< |
return(0); |
701 |
> |
return(1); |
702 |
|
} |
703 |
|
if (!strncmp(s, "BSDFMIN=", 8)) { |
704 |
|
sscanf(s+8, "%lf", &bsdf_min); |
705 |
< |
return(0); |
705 |
> |
return(1); |
706 |
|
} |
707 |
|
if (!strncmp(s, "BSDFSPEC=", 9)) { |
708 |
|
sscanf(s+9, "%lf %lf", &bsdf_spec_val, &bsdf_spec_rad); |
709 |
< |
return(0); |
709 |
> |
return(1); |
710 |
|
} |
711 |
< |
if (formatval(fmt, s) && strcmp(fmt, BSDFREP_FMT)) |
712 |
< |
return(-1); |
711 |
> |
if (formatval(fmt, s)) |
712 |
> |
return (strcmp(fmt, BSDFREP_FMT) ? -1 : 0); |
713 |
> |
if (sir_headshare != NULL) |
714 |
> |
return ((*sir_headshare)(s)); |
715 |
|
return(0); |
716 |
|
} |
717 |
|
|