7 |
|
* G. Ward |
8 |
|
*/ |
9 |
|
|
10 |
< |
#ifndef _WIN32 |
10 |
> |
#if !defined(_WIN32) && !defined(_WIN64) |
11 |
|
#include <unistd.h> |
12 |
|
#include <sys/wait.h> |
13 |
|
#include <sys/mman.h> |
63 |
|
static double |
64 |
|
est_DSFrad(const RBFNODE *rbf, const FVECT outvec) |
65 |
|
{ |
66 |
< |
const double rad_epsilon = 0.03; |
66 |
> |
const double rad_epsilon = 0.01; |
67 |
|
const double DSFtarget = 0.60653066 * eval_rbfrep(rbf,outvec) * |
68 |
|
COSF(outvec[2]); |
69 |
|
double inside_rad = rad_epsilon; |
76 |
|
do { |
77 |
|
double test_rad = interp_rad; |
78 |
|
double DSFtest; |
79 |
< |
if (test_rad >= outside_rad) |
80 |
< |
return(test_rad); |
81 |
< |
if (test_rad <= inside_rad) |
82 |
< |
return(test_rad*(test_rad>0)); |
79 |
> |
if ((test_rad >= outside_rad) | (test_rad <= inside_rad)) |
80 |
> |
test_rad = .5*(inside_rad + outside_rad); |
81 |
|
DSFtest = eval_DSFsurround(rbf, outvec, test_rad); |
82 |
|
if (DSFtest > DSFtarget) { |
83 |
|
inside_rad = test_rad; |
86 |
|
outside_rad = test_rad; |
87 |
|
DSFoutside = DSFtest; |
88 |
|
} |
91 |
– |
if (DSFoutside >= DSFinside) |
92 |
– |
return(test_rad); |
89 |
|
} while (outside_rad-inside_rad > rad_epsilon); |
90 |
< |
return(interp_rad); |
90 |
> |
|
91 |
> |
return(.5*(inside_rad + outside_rad)); |
92 |
|
#undef interp_rad |
93 |
|
} |
94 |
|
|
103 |
|
return(0); |
104 |
|
} |
105 |
|
|
106 |
< |
/* Compute average BSDF peak from current DSF's */ |
106 |
> |
/* Conservative estimate of average BSDF value from current DSF's */ |
107 |
|
static void |
108 |
|
comp_bsdf_spec(void) |
109 |
|
{ |
114 |
|
double max_cost = 1.; |
115 |
|
RBFNODE *rbf; |
116 |
|
FVECT sdv; |
117 |
< |
/* grazing 25th percentile */ |
117 |
> |
/* sort by incident altitude */ |
118 |
|
for (rbf = dsf_list; rbf != NULL; rbf = rbf->next) |
119 |
|
n++; |
120 |
|
if (n >= 10) |
128 |
|
for (rbf = dsf_list; rbf != NULL; rbf = rbf->next) |
129 |
|
cost_list[n++] = rbf->invec[2]*input_orient; |
130 |
|
qsort(cost_list, n, sizeof(double), dbl_cmp); |
131 |
< |
max_cost = cost_list[(n+3)/4]; |
131 |
> |
max_cost = cost_list[(n+3)/4]; /* accept 25% nearest grazing */ |
132 |
|
free(cost_list); |
133 |
|
n = 0; |
134 |
|
for (rbf = dsf_list; rbf != NULL; rbf = rbf->next) { |
138 |
|
sdv[0] = -rbf->invec[0]; |
139 |
|
sdv[1] = -rbf->invec[1]; |
140 |
|
sdv[2] = rbf->invec[2]*(2*(input_orient==output_orient) - 1); |
144 |
– |
this_rad = est_DSFrad(rbf, sdv); |
141 |
|
cosfact = COSF(sdv[2]); |
142 |
+ |
this_rad = est_DSFrad(rbf, sdv); |
143 |
|
vest = eval_rbfrep(rbf, sdv) * cosfact * |
144 |
< |
(2*M_PI) * this_rad*this_rad; |
145 |
< |
if (vest > rbf->vtotal) |
144 |
> |
(2.*M_PI) * this_rad*this_rad; |
145 |
> |
if (vest > rbf->vtotal) /* don't over-estimate energy */ |
146 |
|
vest = rbf->vtotal; |
147 |
< |
vmod_sum += vest / cosfact; |
147 |
> |
vmod_sum += vest / cosfact; /* remove cosine factor */ |
148 |
|
rad_sum += this_rad; |
149 |
|
++n; |
150 |
|
} |
159 |
|
size_t memlen = sizeof(MIGRATION) + |
160 |
|
sizeof(float)*(from_rbf->nrbf*to_rbf->nrbf - 1); |
161 |
|
MIGRATION *newmig; |
162 |
< |
#ifdef _WIN32 |
162 |
> |
#if defined(_WIN32) || defined(_WIN64) |
163 |
|
if (nprocs > 1) |
164 |
|
fprintf(stderr, "%s: warning - multiprocessing not supported\n", |
165 |
|
progname); |
190 |
|
return(mig_list = newmig); |
191 |
|
} |
192 |
|
|
193 |
< |
#ifdef _WIN32 |
193 |
> |
#if defined(_WIN32) || defined(_WIN64) |
194 |
|
#define await_children(n) (void)(n) |
195 |
|
#define run_subprocess() 0 |
196 |
|
#define end_subprocess() (void)0 |
488 |
|
default: |
489 |
|
return; /* else we can interpolate */ |
490 |
|
} |
491 |
< |
for (rbf = near_rbf->next; rbf != NULL; rbf = rbf->next) { |
491 |
> |
for (rbf = dsf_list; rbf != NULL; rbf = rbf->next) { |
492 |
|
const double d = input_orient*rbf->invec[2]; |
493 |
|
if (d >= 1.-2.*FTINY) |
494 |
|
return; /* seems we have normal */ |