245 #define NO_DEFAULT_RULE (!r->defaultDRuleSet)
246 #define NO_LEFT_INFINITE_RULE (!r->infiniteLeftSet)
247 #define NO_RIGHT_INFINITE_RULE (!r->infiniteRightSet)
248 #define NO_FINITE_RULE (r->nofRules <= 0)
249 #define NO_EXPLICIT_RULE \
250 (NO_FINITE_RULE && NO_LEFT_INFINITE_RULE && NO_RIGHT_INFINITE_RULE)
252 #define DEFAULT_MIN ((DCELL)1)
253 #define DEFAULT_MAX ((DCELL)255)
260 r->defaultDRuleSet = 0;
261 r->defaultRRuleSet = 0;
262 r->infiniteRightSet =
r->infiniteLeftSet = 0;
271 if (
r->maxNofRules > 0)
289 r->defaultDMin = dLow;
290 r->defaultDMax = dHigh;
291 r->defaultDRuleSet = 1;
298 r->defaultRMin = low;
299 r->defaultRMax = high;
300 r->defaultRRuleSet = 1;
320 fpreclass_set_limits(
r, dLow, dHigh, rLow, rHigh);
324 r->dMin =
MIN(
r->dMin,
MIN(dLow, dHigh));
325 r->dMax =
MAX(
r->dMax,
MAX(dLow, dHigh));
326 r->rMin =
MIN(
r->rMin,
MIN(rLow, rHigh));
327 r->rMax =
MAX(
r->rMax,
MAX(rLow, rHigh));
339 *dMin =
r->defaultDMin;
340 *dMax =
r->defaultDMax;
342 if (
r->defaultRRuleSet) {
343 *rMin =
r->defaultRMin;
344 *rMax =
r->defaultRMax;
374 *dLow =
r->table[i].dLow;
375 *dHigh =
r->table[i].dHigh;
376 *rLow =
r->table[i].rLow;
377 *rHigh =
r->table[i].rHigh;
382 static void fpreclass_table_increase(
struct FPReclass *
r)
384 if (
r->nofRules <
r->maxNofRules)
387 if (
r->maxNofRules == 0) {
393 r->maxNofRules += 50;
404 r->infiniteDLeft = dLeft;
405 r->infiniteRLeft = c;
406 fpreclass_update_limits(
r, dLeft, dLeft, c, c);
407 r->infiniteLeftSet = 1;
415 if (
r->infiniteLeftSet == 0)
418 *dLeft =
r->infiniteDLeft;
419 *c =
r->infiniteRLeft;
429 r->infiniteDRight = dRight;
430 r->infiniteRRight = c;
431 fpreclass_update_limits(
r, dRight, dRight, c, c);
432 r->infiniteRightSet = 1;
440 if (
r->infiniteRightSet == 0)
443 *dRight =
r->infiniteDRight;
444 *c =
r->infiniteRRight;
457 fpreclass_table_increase(
r);
488 pRight = &(
r->table[
r->nofRules - 1]);
490 while (pLeft < pRight) {
526 static DCELL fpreclass_get_default_cell_value(
const struct FPReclass *
r,
533 if ((cellVal <
MIN(
r->defaultDMin,
r->defaultDMax)) ||
534 (cellVal >
MAX(
r->defaultDMin,
r->defaultDMax)))
537 if (
r->defaultRRuleSet)
538 return fpreclass_interpolate(
r->defaultDMin,
r->defaultDMax,
539 r->defaultRMin,
r->defaultRMax, cellVal);
541 return fpreclass_interpolate(
r->defaultDMin,
r->defaultDMax,
557 return fpreclass_get_default_cell_value(
r, cellVal);
561 for (p = &(
r->table[
r->nofRules - 1]); p >=
r->table; p--)
562 if ((cellVal >= p->
dLow) && (cellVal <= p->
dHigh))
567 return r->infiniteRLeft;
572 return r->infiniteRRight;
582 for (i = 0; i < n; i++, dcell++)
596 for (i = 0; i < n; i++, dcell++)
610 for (i = 0; i < n; i++, dcell++)
624 for (i = 0; i < n; i++, fcell++)
638 for (i = 0; i < n; i++, fcell++)
652 for (i = 0; i < n; i++, fcell++)
666 for (i = 0; i < n; i++, icell++)
680 for (i = 0; i < n; i++, icell++)
694 for (i = 0; i < n; i++, icell++)
void G_free(void *)
Free allocated memory.
#define Rast_is_f_null_value(fcellVal)
void Rast_set_d_null_value(DCELL *, int)
To set a number of DCELL raster values to NULL.
void Rast_set_f_null_value(FCELL *, int)
To set a number of FCELL raster values to NULL.
void Rast_set_c_null_value(CELL *, int)
To set a number of CELL raster values to NULL.
#define Rast_is_d_null_value(dcellVal)
#define Rast_is_c_null_value(cellVal)
#define NO_LEFT_INFINITE_RULE
void Rast_fpreclass_perform_fi(const struct FPReclass *r, const FCELL *fcell, CELL *cell, int n)
#define NO_RIGHT_INFINITE_RULE
void Rast_fpreclass_perform_df(const struct FPReclass *r, const DCELL *dcell, FCELL *cell, int n)
void Rast_fpreclass_set_pos_infinite_rule(struct FPReclass *r, DCELL dRight, DCELL c)
void Rast_fpreclass_init(struct FPReclass *r)
void Rast_fpreclass_perform_ff(const struct FPReclass *r, const FCELL *fcell, FCELL *cell, int n)
void Rast_fpreclass_perform_fd(const struct FPReclass *r, const FCELL *fcell, DCELL *cell, int n)
void Rast_fpreclass_perform_dd(const struct FPReclass *r, const DCELL *dcell, DCELL *cell, int n)
void Rast_fpreclass_reverse_rule_order(struct FPReclass *r)
void Rast_fpreclass_get_ith_rule(const struct FPReclass *r, int i, DCELL *dLow, DCELL *dHigh, DCELL *rLow, DCELL *rHigh)
int Rast_fpreclass_get_pos_infinite_rule(const struct FPReclass *r, DCELL *dRight, DCELL *c)
void Rast_fpreclass_reset(struct FPReclass *r)
int Rast_fpreclass_get_limits(const struct FPReclass *r, DCELL *dMin, DCELL *dMax, DCELL *rMin, DCELL *rMax)
void Rast_fpreclass_perform_if(const struct FPReclass *r, const CELL *icell, FCELL *cell, int n)
void Rast_fpreclass_perform_ii(const struct FPReclass *r, const CELL *icell, CELL *cell, int n)
void Rast_fpreclass_perform_di(const struct FPReclass *r, const DCELL *dcell, CELL *cell, int n)
void Rast_fpreclass_perform_id(const struct FPReclass *r, const CELL *icell, DCELL *cell, int n)
void Rast_fpreclass_set_range(struct FPReclass *r, DCELL low, DCELL high)
int Rast_fpreclass_get_neg_infinite_rule(const struct FPReclass *r, DCELL *dLeft, DCELL *c)
void Rast_fpreclass_set_domain(struct FPReclass *r, DCELL dLow, DCELL dHigh)
int Rast_fpreclass_nof_rules(const struct FPReclass *r)
void Rast_fpreclass_set_neg_infinite_rule(struct FPReclass *r, DCELL dLeft, DCELL c)
DCELL Rast_fpreclass_get_cell_value(const struct FPReclass *r, DCELL cellVal)
void Rast_fpreclass_add_rule(struct FPReclass *r, DCELL dLow, DCELL dHigh, DCELL rLow, DCELL rHigh)
void Rast_fpreclass_clear(struct FPReclass *r)