~ubuntu-branches/ubuntu/precise/grass/precise

« back to all changes in this revision

Viewing changes to raster/r.surf.contour/find_con.c

  • Committer: Bazaar Package Importer
  • Author(s): Francesco Paolo Lovergine
  • Date: 2011-04-13 17:08:41 UTC
  • mfrom: (8.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20110413170841-ss1t9bic0d0uq0gz
Tags: 6.4.1-1
* New upstream version.
* Now build-dep on libjpeg-dev and current libreadline6-dev.
* Removed patch swig: obsolete.
* Policy bumped to 3.9.2, without changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#include <math.h>
2
2
#include "contour.h"
3
3
 
4
 
int find_con_slow(int r, int c, double *d1, double *d2, CELL * con1,
5
 
                  CELL * con2)
 
4
int find_con_slow(int r, int c, double *d1, double *d2, DCELL * con1,
 
5
                  DCELL * con2)
6
6
{
7
7
    int ct, low_ct, node_ct;
8
8
    int rr, cc, dor, doc;
9
9
    double dd, shortest;
10
 
    CELL value;
 
10
    DCELL value;
 
11
    char mask_value;
11
12
 
12
 
    *con1 = 0;
13
 
    *con2 = 0;
 
13
    G_set_d_null_value(con1, 1);
 
14
    G_set_d_null_value(con2, 1);
14
15
    *d1 = *d2 = 1.0;
15
16
    shortest = nrows * ncols;
16
17
    for (rr = minr; rr <= maxr; rr++) {
43
44
        cc = zero[ct].c;
44
45
        dor = ABS(rr - r);
45
46
        doc = ABS(cc - c);
46
 
        bseg_get(&bmask, &value, rr, cc);
47
 
        if (!value && rr >= 0 && cc >= 0 && rr < nrows && cc < ncols
 
47
        bseg_get(&bmask, &mask_value, rr, cc);
 
48
        if (!mask_value && rr >= 0 && cc >= 0 && rr < nrows && cc < ncols
48
49
            && zero[ct].d < shortest) {
49
 
            cseg_get(&con, rr, cc, &value);
50
 
            if (value == 0)
 
50
            dseg_get(&con, rr, cc, &value);
 
51
            if (G_is_d_null_value(&value))
51
52
                zero = addpts_slow(zero, r, c, rr, cc, &node_ct);
52
 
            else if (*con1 == 0) {
 
53
            else if (G_is_d_null_value(con1)) {
53
54
                *con1 = value;
54
55
                *d1 = MIN(dor, doc) * 1.414 + ABS(dor - doc);
55
56
                shortest = *d1 * 2.0 * i_val_l_f;
61
62
                    shortest = dd * 2.0 * i_val_l_f;
62
63
                }
63
64
            }
64
 
            else if (*con2 == 0) {
 
65
            else if (G_is_d_null_value(con2)) {
65
66
                *con2 = value;
66
67
                *d2 = MIN(dor, doc) * 1.414 + ABS(dor - doc);
67
68
                shortest = *d2;
74
75
    }
75
76
}
76
77
 
77
 
int find_con(int r, int c, double *d1, double *d2, CELL * con1, CELL * con2)
 
78
int find_con(int r, int c, double *d1, double *d2, DCELL * con1, DCELL * con2)
78
79
{
79
80
    int ct, low_ct, node_ct;
80
81
    int rr, cc, dor, doc;
81
82
    double dd, shortest;
82
 
    CELL value;
 
83
    DCELL value;
83
84
 
84
 
    *con1 = 0;
85
 
    *con2 = 0;
 
85
    G_set_d_null_value(con1, 1);
 
86
    G_set_d_null_value(con2, 1);
86
87
    *d1 = *d2 = 1.0;
87
88
    shortest = nrows * ncols;
88
89
    for (rr = minr; rr <= maxr; rr++) {
114
115
        doc = ABS(cc - c);
115
116
        if (rr >= 0 && cc >= 0 && rr < nrows && cc < ncols
116
117
            && zero[ct].d < shortest && !flag_get(mask, rr, cc)) {
117
 
            cseg_get(&con, rr, cc, &value);
118
 
            if (value == 0)
 
118
            dseg_get(&con, rr, cc, &value);
 
119
            if (G_is_d_null_value(&value))
119
120
                zero = addpts(zero, r, c, rr, cc, &node_ct);
120
 
            else if (*con1 == 0) {
 
121
            else if (G_is_d_null_value(con1)) {
121
122
                *con1 = value;
122
123
                *d1 = MIN(dor, doc) * 1.414 + ABS(dor - doc);
123
124
                shortest = *d1 * 2.0 * i_val_l_f;
129
130
                    shortest = dd * 2.0 * i_val_l_f;
130
131
                }
131
132
            }
132
 
            else if (*con2 == 0) {
 
133
            else if (G_is_d_null_value(con2)) {
133
134
                *con2 = value;
134
135
                *d2 = MIN(dor, doc) * 1.414 + ABS(dor - doc);
135
136
                shortest = *d2;