GRASS Programmer's Manual  6.4.1(2011)
fpreclass.c
Go to the documentation of this file.
00001 
00002 /**********************************************************************
00003  *
00004  *  G_fpreclass_init (r)
00005  *
00006  *       struct FPReclass *r;
00007  *
00008  *  initializes new reclassification structure. calls
00009  *  G_fpreclass_clear() before it returns.
00010  *  
00011  **********************************************************************
00012  *
00013  *  void
00014  *  G_fpreclass_reset (r)
00015  *  
00016  *       struct FPReclass *r;
00017  *
00018  *  resets the number of defined rules to 0 and free's space allocated
00019  *  for rules. calls G_fpreclass_clear ().
00020  *
00021  **********************************************************************
00022  *
00023  *  void
00024  *  G_fpreclass_clear (r)
00025  *  
00026  *       struct FPReclass *r;
00027  *
00028  *  resets the number of defined rules to 0. Resets default Min and Max
00029  *  to be unknown. (see G_fpreclass_set_domain (), G_fpreclass_set_range ()).
00030  *  deactivates default mapping.
00031  *
00032  **********************************************************************
00033  *
00034  *  void
00035  *  G_fpreclass_set_domain (r, dLow, dHigh)
00036  *
00037  *       struct FPReclass *r;
00038  *       DCELL dLow, dHigh;
00039  *
00040  *  defines the domain for the default mapping and 
00041  *  activates default mapping. (see G_fpreclass_perform_d ()).
00042  *  
00043  *  note: dHigh < dLow is valid.
00044  *
00045  **********************************************************************
00046  *
00047  *  void
00048  *  G_fpreclass_set_range (r, low, high)
00049  *
00050  *       struct FPReclass *r;
00051  *       DCELL low, high;
00052  *
00053  *  defines the range for the default mapping. does NOT
00054  *  activate default mapping. (see G_fpreclass_perform_d ()).
00055  *  
00056  **********************************************************************
00057  *
00058  *  int
00059  *  G_fpreclass_get_limits (r, dMin, dMax, rMin, rmax)
00060  *  
00061  *       const struct FPReclass *r;
00062  *       DCELL *dMin, *dMax;
00063  *       DCELL *rMin, *rmax;
00064  *
00065  *  returns the minimum and maximum values of all the rules defined.
00066  *  
00067  *  returns: -1 if after G_fpreclass_init (), or any call to 
00068  *                 G_fpreclass_clear () or G_fpreclass_reset () neither 
00069  *                 G_fpreclass_add_rule () nor G_fpreclass_set_domain () is
00070  *                 used. in this case the returned minimum and maximum 
00071  *                 range and domain values are undefined.
00072  *            0 if the default rule values are returned.domain values
00073  *                 are identical to those set with G_fpreclass_set_domain ().
00074  *                 range values are either reclassification internal default,
00075  *                 or the values set with G_fpreclass_set_range ().
00076  *            1 otherwise. in this case the values returned correspond
00077  *                 to the extreme values of the defined rules (they need 
00078  *                 not be identical to the values set with
00079  *                 G_fpreclass_set_domain ()).
00080  *
00081  **********************************************************************
00082  *  
00083  *  int
00084  *  G_fpreclass_nof_rules (r)
00085  *  
00086  *       const struct FPReclass *r;
00087  *  
00088  *  returns the number of reclassification rules defined. This number does
00089  *  not include the 2 infinite intervals.
00090  *  
00091  **********************************************************************
00092  *  
00093  *  void
00094  *  G_fpreclass_get_ith_rule (r, i, dLow, dHigh, rLow, rHigh)
00095  *  
00096  *       const struct FPReclass *r;
00097  *       int i;
00098  *       DCELL *dLow, *dHigh;
00099  *       DCELL *rLow, *rHigh;
00100  *  
00101  *  returns the i'th reclassification rule, for 
00102  *  0 <= i < G_fpreclass_nof_rules().
00103  *  a larger value for i means that the rule has been added later.
00104  *  
00105  **********************************************************************
00106  *   void
00107  *   G_fpreclass_set_neg_infinite_rule (r, dLeft, c)
00108  *
00109  *       struct FPReclass *r;
00110  *       DCELL dLeft;
00111  *       DCELL c;
00112  *
00113  *   defines a rule for values "dLeft" and smaller. values in this range
00114  *   are mapped to "c" if none of the "finite" reclassification rules applies.
00115  *
00116  * **********************************************************************
00117  *
00118  *  int
00119  *  G_fpreclass_get_neg_infinite_rule (r, dLeft, c)
00120  *
00121  *       const struct FPReclass *r;
00122  *       DCELL *dLeft;
00123  *       DCELL *c;
00124  *
00125  *  returns in "dLeft" and "c" the rule values for the negative infinite
00126  *  interval (see G_fpreclass_set_neg_infinite_rule ()).
00127  *
00128  *  returns: 0 if this rule is not defined
00129  *           1 otherwise.
00130  *
00131  **********************************************************************
00132  *   void
00133  *   G_fpreclass_set_pos_infinite_rule (r, dRight, c)
00134  *
00135  *       struct FPReclass *r;
00136  *       DCELL dRight;
00137  *       DCELL c;
00138  *
00139  *   defines a rule for values "dRight" and larger. values in this range
00140  *   are mapped to "c" if neither any of the "finite" reclassification
00141  *   rules nor the negative infinite rule applies.
00142  *
00143  * **********************************************************************
00144  *
00145  *  int
00146  *  G_fpreclass_get_pos_infinite_rule (r, dRight, c)
00147  *
00148  *       const struct FPReclass *r;
00149  *       DCELL *dRight;
00150  *       DCELL *c;
00151  *
00152  *  returns in "dRight" and "c" the rule values for the positive infinite
00153  *  interval (see G_fpreclass_set_pos_infinite_rule ()).
00154  *
00155  *  returns: 0 if this rule is not defined
00156  *           1 otherwise.
00157  *
00158  **********************************************************************
00159  *  
00160  *  void
00161  *  G_fpreclass_reverse_rule_order (r)
00162  *
00163  *        struct FPReclass *r;
00164  *
00165  *  reverses the order in which the reclassification rules are stored. (see
00166  *  also G_fpreclass_get_ith_rule () and G_fpreclass_perform_XY ()).
00167  *  
00168  **********************************************************************
00169  *  
00170  *  void
00171  *  G_fpreclass_add_rule (r, dLow, dHigh, rLow, rHigh)
00172  *  
00173  *       struct FPReclass *r;
00174  *       DCELL dLow, dHigh;
00175  *       DCELL rLow, rHigh;
00176  *  
00177  *  adds a new rule to the set of reclassification rules. if dLow > dHigh
00178  *  the rule will be stored with the low and high values interchanged.
00179  *  
00180  *  Note: currently no cleanup of rules is performed, i.e. redundant
00181  *        rules are not removed.
00182  *  
00183  **********************************************************************
00184  *  
00185  *  DCELL
00186  *  G_fpreclass_get_cell_value (r, cellValue)
00187  *  
00188  *       const struct FPReclass *r;
00189  *       DCELL *cellValue;
00190  *  
00191  *  returns the reclassified value corresponding to "cellValue".
00192  *
00193  *  if several reclassification rules apply for cellValue, the one which has 
00194  *  been inserted latest (i.e. the one of them which is returned by 
00195  *  G_fpreclass_get_ith_rule() for the largest i) is used. if no such rule
00196  *  applies the cellValue is first tested against the negative infinite
00197  *  rule, and finally against the positive infinite rule. if none of
00198  *  these rules apply, NO_DATA is returned. the actual value of NO_DATA 
00199  *  is found by calling G_set_d_null_value()
00200  *  
00201  *  if after G_fpreclass_init (), or any call to G_fpreclass_clear () or 
00202  *  G_fpreclass_reset () neither G_fpreclass_add_rule (),
00203  *  G_fpreclass_set_neg_infinite_rule (),  
00204  *  G_fpreclass_set_pos_infinite_rule (), *  nor  G_fpreclass_set_domain () 
00205  *  is used NO_DATA is returned independently of the cellValue.
00206  *
00207  *  if G_fpreclass_set_domain () is called but no explicit reclassification
00208  *  rule is set, the default mapping to the cell range set with 
00209  *  G_fpreclass_set_range () or, if the cell range is not set, 
00210  *  to the default CELL range [0,256 - 1] is applied.
00211  *  
00212  **********************************************************************
00213  *  
00214  *  void
00215  *  G_fpreclass_perform_XY (r, xcell, ycell, n)
00216  *  
00217  *       const struct FPReclass *r;
00218  *       XCELL *xcell;
00219  *       YCELL *ycell;
00220  *       int n;
00221  *  
00222  *  "X" and "Y" in the function name can be any of "d", "f", or "i". These
00223  *  correspond to "DCELL", "FCELL", and "CELL", respectively, and denote
00224  *  the type of the domain and range values.
00225  *  
00226  *  returns in "ycell" the reclassified YCELL values corresponding to the
00227  *  XCELL values stored in "xcell". the number of elements reclassified
00228  *  is n. reclassification is performed by repeated application of 
00229  *  G_fpreclass_get_cell_value ().
00230  *  
00231  **********************************************************************/
00232 
00233 /*--------------------------------------------------------------------------*/
00234 
00235 /*
00236    the reclassification table is stored as a linear array. rules are added 
00237    starting from index 0. redundant rules are not eliminated. rules are tested 
00238    from the highest index downto 0. there are two "infinite" rules. support is 
00239    provided to reverse the order of the rules.
00240  */
00241 
00242 /*--------------------------------------------------------------------------*/
00243 
00244 #include <grass/gis.h>
00245 
00246 /*--------------------------------------------------------------------------*/
00247 
00248 #undef MIN
00249 #undef MAX
00250 #define MIN(a,b) ((a) < (b) ? (a) : (b))
00251 #define MAX(a,b) ((a) > (b) ? (a) : (b))
00252 
00253 #define NO_DEFAULT_RULE (! r->defaultDRuleSet)
00254 #define NO_LEFT_INFINITE_RULE (! r->infiniteLeftSet)
00255 #define NO_RIGHT_INFINITE_RULE (! r->infiniteRightSet)
00256 #define NO_FINITE_RULE (r->nofRules <= 0)
00257 #define NO_EXPLICIT_RULE (NO_FINITE_RULE && \
00258                           NO_LEFT_INFINITE_RULE && NO_RIGHT_INFINITE_RULE)
00259 
00260 #define DEFAULT_MIN ((DCELL) 1)
00261 #define DEFAULT_MAX ((DCELL) 255)
00262 
00263 /*--------------------------------------------------------------------------*/
00264 
00265 void G_fpreclass_clear(struct FPReclass *r)
00266 {
00267     r->nofRules = 0;
00268     r->defaultDRuleSet = 0;
00269     r->defaultRRuleSet = 0;
00270     r->infiniteRightSet = r->infiniteLeftSet = 0;
00271 }
00272 
00273 /*--------------------------------------------------------------------------*/
00274 
00275 void G_fpreclass_reset(struct FPReclass *r)
00276 {
00277     G_fpreclass_clear(r);
00278 
00279     if (r->maxNofRules > 0)
00280         G_free(r->table);
00281 
00282     r->maxNofRules = 0;
00283 }
00284 
00285 /*--------------------------------------------------------------------------*/
00286 
00287 int G_fpreclass_init(struct FPReclass *r)
00288 {
00289     r->maxNofRules = 0;
00290     G_fpreclass_reset(r);
00291 
00292     return 1;
00293 }
00294 
00295 /*--------------------------------------------------------------------------*/
00296 
00297 void G_fpreclass_set_domain(struct FPReclass *r, DCELL dLow, DCELL dHigh)
00298 {
00299     r->defaultDMin = dLow;
00300     r->defaultDMax = dHigh;
00301     r->defaultDRuleSet = 1;
00302 }
00303 
00304 /*--------------------------------------------------------------------------*/
00305 
00306 void G_fpreclass_set_range(struct FPReclass *r, DCELL low, DCELL high)
00307 {
00308     r->defaultRMin = low;
00309     r->defaultRMax = high;
00310     r->defaultRRuleSet = 1;
00311 }
00312 
00313 /*--------------------------------------------------------------------------*/
00314 
00315 static void
00316 fpreclass_set_limits(struct FPReclass *r, DCELL dLow, DCELL dHigh, DCELL rLow,
00317                      DCELL rHigh)
00318 {
00319     r->dMin = dLow;
00320     r->dMax = dHigh;
00321     r->rMin = rLow;
00322     r->rMax = rHigh;
00323 }
00324 
00325 /*--------------------------------------------------------------------------*/
00326 
00327 static void
00328 fpreclass_update_limits(struct FPReclass *r, DCELL dLow, DCELL dHigh,
00329                         DCELL rLow, DCELL rHigh)
00330 {
00331     if (NO_EXPLICIT_RULE) {
00332         fpreclass_set_limits(r, dLow, dHigh, rLow, rHigh);
00333         return;
00334     }
00335 
00336     r->dMin = MIN(r->dMin, MIN(dLow, dHigh));
00337     r->dMax = MAX(r->dMax, MAX(dLow, dHigh));
00338     r->rMin = MIN(r->rMin, MIN(rLow, rHigh));
00339     r->rMax = MAX(r->rMax, MAX(rLow, rHigh));
00340 }
00341 
00342 /*--------------------------------------------------------------------------*/
00343 
00344 int
00345 G_fpreclass_get_limits(const struct FPReclass *r, DCELL * dMin, DCELL * dMax,
00346                        DCELL * rMin, DCELL * rMax)
00347 {
00348     if (NO_EXPLICIT_RULE) {
00349         if (NO_DEFAULT_RULE)
00350             return -1;
00351 
00352         *dMin = r->defaultDMin;
00353         *dMax = r->defaultDMax;
00354 
00355         if (r->defaultRRuleSet) {
00356             *rMin = r->defaultRMin;
00357             *rMax = r->defaultRMax;
00358         }
00359         else {
00360             *rMin = DEFAULT_MIN;
00361             *rMax = DEFAULT_MAX;
00362         }
00363 
00364         return 0;
00365     }
00366 
00367     *dMin = r->dMin;
00368     *dMax = r->dMax;
00369     *rMin = r->rMin;
00370     *rMax = r->rMax;
00371 
00372     return 1;
00373 }
00374 
00375 /*--------------------------------------------------------------------------*/
00376 
00377 int G_fpreclass_nof_rules(const struct FPReclass *r)
00378 {
00379     return r->nofRules;
00380 }
00381 
00382 /*--------------------------------------------------------------------------*/
00383 
00384 void
00385 G_fpreclass_get_ith_rule(const struct FPReclass *r, int i, DCELL * dLow,
00386                          DCELL * dHigh, DCELL * rLow, DCELL * rHigh)
00387 {
00388     *dLow = r->table[i].dLow;
00389     *dHigh = r->table[i].dHigh;
00390     *rLow = r->table[i].rLow;
00391     *rHigh = r->table[i].rHigh;
00392 }
00393 
00394 /*--------------------------------------------------------------------------*/
00395 
00396 static void fpreclass_table_increase(struct FPReclass *r)
00397 {
00398     if (r->nofRules < r->maxNofRules)
00399         return;
00400 
00401     if (r->maxNofRules == 0) {
00402         r->maxNofRules = 50;
00403         r->table = (struct FPReclass_table *)
00404             G_malloc(r->maxNofRules * sizeof(struct FPReclass_table));
00405     }
00406     else {
00407         r->maxNofRules += 50;
00408         r->table = (struct FPReclass_table *)
00409             G_realloc((char *)r->table,
00410                       r->maxNofRules * sizeof(struct FPReclass_table));
00411     }
00412 }
00413 
00414 /*--------------------------------------------------------------------------*/
00415 
00416 void
00417 G_fpreclass_set_neg_infinite_rule(struct FPReclass *r, DCELL dLeft, DCELL c)
00418 {
00419     r->infiniteDLeft = dLeft;
00420     r->infiniteRLeft = c;
00421     fpreclass_update_limits(r, dLeft, dLeft, c, c);
00422     r->infiniteLeftSet = 1;
00423 }
00424 
00425 /*--------------------------------------------------------------------------*/
00426 
00427 int
00428 G_fpreclass_get_neg_infinite_rule(const struct FPReclass *r, DCELL * dLeft,
00429                                   DCELL * c)
00430 {
00431     if (r->infiniteLeftSet == 0)
00432         return 0;
00433 
00434     *dLeft = r->infiniteDLeft;
00435     *c = r->infiniteRLeft;
00436 
00437     return 1;
00438 }
00439 
00440 /*--------------------------------------------------------------------------*/
00441 
00442 void
00443 G_fpreclass_set_pos_infinite_rule(struct FPReclass *r, DCELL dRight, DCELL c)
00444 {
00445     r->infiniteDRight = dRight;
00446     r->infiniteRRight = c;
00447     fpreclass_update_limits(r, dRight, dRight, c, c);
00448     r->infiniteRightSet = 1;
00449 }
00450 
00451 /*--------------------------------------------------------------------------*/
00452 
00453 int
00454 G_fpreclass_get_pos_infinite_rule(const struct FPReclass *r, DCELL * dRight,
00455                                   DCELL * c)
00456 {
00457     if (r->infiniteRightSet == 0)
00458         return 0;
00459 
00460     *dRight = r->infiniteDRight;
00461     *c = r->infiniteRRight;
00462 
00463     return 1;
00464 }
00465 
00466 /*--------------------------------------------------------------------------*/
00467 
00468 void
00469 G_fpreclass_add_rule(struct FPReclass *r, DCELL dLow, DCELL dHigh, DCELL rLow,
00470                      DCELL rHigh)
00471 {
00472     int i;
00473     struct FPReclass_table *p;
00474 
00475     fpreclass_table_increase(r);
00476 
00477     i = r->nofRules;
00478 
00479     p = &(r->table[i]);
00480     if (dHigh >= dLow) {
00481         p->dLow = dLow;
00482         p->dHigh = dHigh;
00483         p->rLow = rLow;
00484         p->rHigh = rHigh;
00485     }
00486     else {
00487         p->dLow = dHigh;
00488         p->dHigh = dLow;
00489         p->rLow = rHigh;
00490         p->rHigh = rLow;
00491     }
00492 
00493     fpreclass_update_limits(r, dLow, dHigh, rLow, rHigh);
00494 
00495     r->nofRules++;
00496 }
00497 
00498 /*--------------------------------------------------------------------------*/
00499 
00500 void G_fpreclass_reverse_rule_order(struct FPReclass *r)
00501 {
00502     struct FPReclass_table tmp;
00503     struct FPReclass_table *pLeft, *pRight;
00504 
00505     pLeft = r->table;
00506     pRight = &(r->table[r->nofRules - 1]);
00507 
00508     while (pLeft < pRight) {
00509         tmp.dLow = pLeft->dLow;
00510         tmp.dHigh = pLeft->dHigh;
00511         tmp.rLow = pLeft->rLow;
00512         tmp.rHigh = pLeft->rHigh;
00513 
00514         pLeft->dLow = pRight->dLow;
00515         pLeft->dHigh = pRight->dHigh;
00516         pLeft->rLow = pRight->rLow;
00517         pLeft->rHigh = pRight->rHigh;
00518 
00519         pRight->dLow = tmp.dLow;
00520         pRight->dHigh = tmp.dHigh;
00521         pRight->rLow = tmp.rLow;
00522         pRight->rHigh = tmp.rHigh;
00523 
00524         pLeft++;
00525         pRight--;
00526     }
00527 }
00528 
00529 /*--------------------------------------------------------------------------*/
00530 
00531 static DCELL
00532 fpreclass_interpolate(DCELL dLow, DCELL dHigh, DCELL rLow, DCELL rHigh,
00533                       DCELL dValue)
00534 {
00535     if (rLow == rHigh)
00536         return rLow;
00537     if (dLow == dHigh)
00538         return rLow;
00539 
00540     return ((dValue - dLow) / (dHigh - dLow) * (rHigh - rLow) + rLow);
00541 }
00542 
00543 /*--------------------------------------------------------------------------*/
00544 
00545 static DCELL
00546 fpreclass_get_default_cell_value(const struct FPReclass *r, DCELL cellVal)
00547 {
00548     DCELL tmp;
00549 
00550     G_set_d_null_value(&tmp, 1);
00551 
00552     if ((cellVal < MIN(r->defaultDMin, r->defaultDMax)) ||
00553         (cellVal > MAX(r->defaultDMin, r->defaultDMax)))
00554         return tmp;
00555 
00556     if (r->defaultRRuleSet)
00557         return fpreclass_interpolate(r->defaultDMin, r->defaultDMax,
00558                                      r->defaultRMin, r->defaultRMax, cellVal);
00559     else
00560         return fpreclass_interpolate(r->defaultDMin, r->defaultDMax,
00561                                      DEFAULT_MIN, DEFAULT_MAX, cellVal);
00562 }
00563 
00564 /*--------------------------------------------------------------------------*/
00565 
00566 DCELL G_fpreclass_get_cell_value(const struct FPReclass * r, DCELL cellVal)
00567 {
00568     DCELL tmp;
00569     const struct FPReclass_table *p;
00570 
00571     G_set_d_null_value(&tmp, 1);
00572     if (NO_EXPLICIT_RULE) {
00573 
00574         if (NO_DEFAULT_RULE)
00575             return tmp;
00576         return fpreclass_get_default_cell_value(r, cellVal);
00577     }
00578 
00579     if (!NO_FINITE_RULE)
00580         for (p = &(r->table[r->nofRules - 1]); p >= r->table; p--)
00581             if ((cellVal >= p->dLow) && (cellVal <= p->dHigh))
00582                 return fpreclass_interpolate(p->dLow, p->dHigh, p->rLow,
00583                                              p->rHigh, cellVal);
00584 
00585     if ((!NO_LEFT_INFINITE_RULE) && (cellVal <= r->infiniteDLeft))
00586         return r->infiniteRLeft;
00587 
00588     if ((NO_RIGHT_INFINITE_RULE) || (cellVal < r->infiniteDRight))
00589         return tmp;
00590 
00591     return r->infiniteRRight;
00592 }
00593 
00594 /*--------------------------------------------------------------------------*/
00595 
00596 void
00597 G_fpreclass_perform_di(const struct FPReclass *r, const DCELL * dcell,
00598                        CELL * cell, int n)
00599 {
00600     int i;
00601 
00602     for (i = 0; i < n; i++, dcell++)
00603         if (!G_is_d_null_value(dcell))
00604             *cell++ = G_fpreclass_get_cell_value(r, *dcell);
00605         else
00606             G_set_c_null_value(cell++, 1);
00607 }
00608 
00609 /*--------------------------------------------------------------------------*/
00610 
00611 void
00612 G_fpreclass_perform_df(const struct FPReclass *r, const DCELL * dcell,
00613                        FCELL * cell, int n)
00614 {
00615     int i;
00616 
00617     for (i = 0; i < n; i++, dcell++)
00618         if (!G_is_d_null_value(dcell))
00619             *cell++ = G_fpreclass_get_cell_value(r, *dcell);
00620         else
00621             G_set_f_null_value(cell++, 1);
00622 }
00623 
00624 /*--------------------------------------------------------------------------*/
00625 
00626 void
00627 G_fpreclass_perform_dd(const struct FPReclass *r, const DCELL * dcell,
00628                        DCELL * cell, int n)
00629 {
00630     int i;
00631 
00632     for (i = 0; i < n; i++, dcell++)
00633         if (!G_is_d_null_value(dcell))
00634             *cell++ = G_fpreclass_get_cell_value(r, *dcell);
00635         else
00636             G_set_d_null_value(cell++, 1);
00637 }
00638 
00639 /*--------------------------------------------------------------------------*/
00640 
00641 void
00642 G_fpreclass_perform_fi(const struct FPReclass *r, const FCELL * fcell,
00643                        CELL * cell, int n)
00644 {
00645     int i;
00646 
00647     for (i = 0; i < n; i++, fcell++)
00648         if (!G_is_f_null_value(fcell))
00649             *cell++ = G_fpreclass_get_cell_value(r, (DCELL) * fcell);
00650         else
00651             G_set_c_null_value(cell++, 1);
00652 }
00653 
00654 /*--------------------------------------------------------------------------*/
00655 
00656 void
00657 G_fpreclass_perform_ff(const struct FPReclass *r, const FCELL * fcell,
00658                        FCELL * cell, int n)
00659 {
00660     int i;
00661 
00662     for (i = 0; i < n; i++, fcell++)
00663         if (!G_is_f_null_value(fcell))
00664             *cell++ = G_fpreclass_get_cell_value(r, (DCELL) * fcell);
00665         else
00666             G_set_f_null_value(cell++, 1);
00667 }
00668 
00669 /*--------------------------------------------------------------------------*/
00670 
00671 void
00672 G_fpreclass_perform_fd(const struct FPReclass *r, const FCELL * fcell,
00673                        DCELL * cell, int n)
00674 {
00675     int i;
00676 
00677     for (i = 0; i < n; i++, fcell++)
00678         if (!G_is_f_null_value(fcell))
00679             *cell++ = G_fpreclass_get_cell_value(r, (DCELL) * fcell);
00680         else
00681             G_set_d_null_value(cell++, 1);
00682 }
00683 
00684 /*--------------------------------------------------------------------------*/
00685 
00686 void
00687 G_fpreclass_perform_ii(const struct FPReclass *r, const CELL * icell,
00688                        CELL * cell, int n)
00689 {
00690     int i;
00691 
00692     for (i = 0; i < n; i++, icell++)
00693         if (!G_is_c_null_value(icell))
00694             *cell++ = G_fpreclass_get_cell_value(r, (DCELL) * icell);
00695         else
00696             G_set_c_null_value(cell++, 1);
00697 }
00698 
00699 /*--------------------------------------------------------------------------*/
00700 
00701 void
00702 G_fpreclass_perform_if(const struct FPReclass *r, const CELL * icell,
00703                        FCELL * cell, int n)
00704 {
00705     int i;
00706 
00707     for (i = 0; i < n; i++, icell++)
00708         if (!G_is_c_null_value(icell))
00709             *cell++ = G_fpreclass_get_cell_value(r, (DCELL) * icell);
00710         else
00711             G_set_f_null_value(cell++, 1);
00712 }
00713 
00714 /*--------------------------------------------------------------------------*/
00715 
00716 void
00717 G_fpreclass_perform_id(const struct FPReclass *r, const CELL * icell,
00718                        DCELL * cell, int n)
00719 {
00720     int i;
00721 
00722     for (i = 0; i < n; i++, icell++)
00723         if (!G_is_c_null_value(icell))
00724             *cell++ = G_fpreclass_get_cell_value(r, (DCELL) * icell);
00725         else
00726             G_set_d_null_value(cell++, 1);
00727 }
00728 
00729 /*--------------------------------------------------------------------------*/
00730 
00731 /*--------------------------------------------------------------------------*/
00732 
00733 /*--------------------------------------------------------------------------*/
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines