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

« back to all changes in this revision

Viewing changes to lib/vector/Vlib/snap.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:
118
118
    for (line_idx = 0; line_idx < List_lines->n_values; line_idx++) {
119
119
        int v;
120
120
 
 
121
        G_percent(line_idx, List_lines->n_values, 2);
 
122
 
121
123
        line = List_lines->value[line_idx];
122
124
 
123
125
        G_debug(3, "line =  %d", line);
159
161
            }
160
162
        }
161
163
    }
 
164
    G_percent(line_idx, List_lines->n_values, 2); /* finish it */
 
165
 
162
166
    npoints = point - 1;
163
167
 
164
168
    /* Go through all registered points and if not yet marked mark it as anchor and assign this anchor
167
171
    for (point = 1; point <= npoints; point++) {
168
172
        int i;
169
173
 
 
174
        G_percent(point, npoints, 2);
 
175
 
170
176
        G_debug(3, "  point = %d", point);
171
177
 
172
178
        if (XPnts[point].anchor >= 0)
199
205
            dy = XPnts[pointb].y - XPnts[point].y;
200
206
            dist2 = dx * dx + dy * dy;
201
207
 
202
 
            if (dist2 <= thresh2) {
 
208
            if (dist2 > thresh2) /* outside threshold */
 
209
                continue;
 
210
                
 
211
            /* doesn't have an anchor yet */
 
212
            if (XPnts[pointb].anchor == -1) {
203
213
                XPnts[pointb].anchor = point;
204
214
                ntosnap++;
205
215
            }
 
216
            else if (XPnts[pointb].anchor > 0) {   /* check distance to previously assigned anchor */
 
217
                double dist2_a;
 
218
 
 
219
                dx = XPnts[XPnts[pointb].anchor].x - XPnts[pointb].x;
 
220
                dy = XPnts[XPnts[pointb].anchor].y - XPnts[pointb].y;
 
221
                dist2_a = dx * dx + dy * dy;
 
222
 
 
223
                /* replace old anchor */
 
224
                if (dist2 < dist2_a) {
 
225
                    XPnts[pointb].anchor = point;
 
226
                }
 
227
            }
206
228
        }
207
229
    }
208
230
 
216
238
        int v, spoint, anchor;
217
239
        int changed = 0;
218
240
 
 
241
        G_percent(line_idx, List_lines->n_values, 2);
 
242
 
219
243
        line = List_lines->value[line_idx];
220
244
 
221
245
        G_debug(3, "line =  %d", line);
378
402
            }
379
403
        }
380
404
    }                           /* for each line */
 
405
    G_percent(line_idx, List_lines->n_values, 2); /* finish it */
381
406
 
382
407
    Vect_destroy_line_struct(Points);
383
408
    Vect_destroy_line_struct(NPoints);
436
461
        if (!(ltype & type))
437
462
            continue;
438
463
 
439
 
        Vect_list_append(List, line);
 
464
        /* Vect_list_append(List, line); */
 
465
        dig_list_add(List, line);
440
466
    }
441
467
 
442
468
    Vect_snap_lines_list(Map, List, thresh, Err);