249 #define NO_DEFAULT_RULE (! r->defaultDRuleSet)
250 #define NO_LEFT_INFINITE_RULE (! r->infiniteLeftSet)
251 #define NO_RIGHT_INFINITE_RULE (! r->infiniteRightSet)
252 #define NO_FINITE_RULE (r->nofRules <= 0)
253 #define NO_EXPLICIT_RULE (NO_FINITE_RULE && \
254 NO_LEFT_INFINITE_RULE && NO_RIGHT_INFINITE_RULE)
256 #define DEFAULT_MIN ((DCELL) 1)
257 #define DEFAULT_MAX ((DCELL) 255)
264 r->defaultDRuleSet = 0;
265 r->defaultRRuleSet = 0;
266 r->infiniteRightSet =
r->infiniteLeftSet = 0;
275 if (
r->maxNofRules > 0)
293 r->defaultDMin = dLow;
294 r->defaultDMax = dHigh;
295 r->defaultDRuleSet = 1;
302 r->defaultRMin = low;
303 r->defaultRMax = high;
304 r->defaultRRuleSet = 1;
309 static void fpreclass_set_limits(
struct FPReclass *
r,
321 static void fpreclass_update_limits(
struct FPReclass *
r,
326 fpreclass_set_limits(
r, dLow, dHigh, rLow, rHigh);
330 r->dMin =
MIN(
r->dMin,
MIN(dLow, dHigh));
331 r->dMax =
MAX(
r->dMax,
MAX(dLow, dHigh));
332 r->rMin =
MIN(
r->rMin,
MIN(rLow, rHigh));
333 r->rMax =
MAX(
r->rMax,
MAX(rLow, rHigh));
346 *dMin =
r->defaultDMin;
347 *dMax =
r->defaultDMax;
349 if (
r->defaultRRuleSet) {
350 *rMin =
r->defaultRMin;
351 *rMax =
r->defaultRMax;
382 *dLow =
r->table[i].dLow;
383 *dHigh =
r->table[i].dHigh;
384 *rLow =
r->table[i].rLow;
385 *rHigh =
r->table[i].rHigh;
390 static void fpreclass_table_increase(
struct FPReclass *
r)
392 if (
r->nofRules <
r->maxNofRules)
395 if (
r->maxNofRules == 0) {
401 r->maxNofRules += 50;
414 r->infiniteDLeft = dLeft;
415 r->infiniteRLeft = c;
416 fpreclass_update_limits(
r, dLeft, dLeft, c, c);
417 r->infiniteLeftSet = 1;
425 if (
r->infiniteLeftSet == 0)
428 *dLeft =
r->infiniteDLeft;
429 *c =
r->infiniteRLeft;
439 r->infiniteDRight = dRight;
440 r->infiniteRRight = c;
441 fpreclass_update_limits(
r, dRight, dRight, c, c);
442 r->infiniteRightSet = 1;
450 if (
r->infiniteRightSet == 0)
453 *dRight =
r->infiniteDRight;
454 *c =
r->infiniteRRight;
467 fpreclass_table_increase(
r);
498 pRight = &(
r->table[
r->nofRules - 1]);
500 while (pLeft < pRight) {
536 static DCELL fpreclass_get_default_cell_value(
const struct FPReclass *
r,
543 if ((cellVal <
MIN(
r->defaultDMin,
r->defaultDMax)) ||
544 (cellVal >
MAX(
r->defaultDMin,
r->defaultDMax)))
547 if (
r->defaultRRuleSet)
548 return fpreclass_interpolate(
r->defaultDMin,
r->defaultDMax,
549 r->defaultRMin,
r->defaultRMax, cellVal);
551 return fpreclass_interpolate(
r->defaultDMin,
r->defaultDMax,
567 return fpreclass_get_default_cell_value(
r, cellVal);
571 for (p = &(
r->table[
r->nofRules - 1]); p >=
r->table; p--)
572 if ((cellVal >= p->
dLow) && (cellVal <= p->
dHigh))
577 return r->infiniteRLeft;
582 return r->infiniteRRight;
592 for (i = 0; i < n; i++, dcell++)
606 for (i = 0; i < n; i++, dcell++)
620 for (i = 0; i < n; i++, dcell++)
634 for (i = 0; i < n; i++, fcell++)
648 for (i = 0; i < n; i++, fcell++)
662 for (i = 0; i < n; i++, fcell++)
672 const CELL * icell,
CELL * cell,
int n)
676 for (i = 0; i < n; i++, icell++)
690 for (i = 0; i < n; i++, icell++)
704 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)