~ubuntu-branches/ubuntu/vivid/grass/vivid-proposed

« back to all changes in this revision

Viewing changes to lib/vector/Vlib/dgraph.c

  • Committer: Package Import Robot
  • Author(s): Bas Couwenberg
  • Date: 2015-02-20 23:12:08 UTC
  • mfrom: (8.2.6 experimental)
  • Revision ID: package-import@ubuntu.com-20150220231208-1u6qvqm84v430b10
Tags: 7.0.0-1~exp1
* New upstream release.
* Update python-ctypes-ternary.patch to use if/else instead of and/or.
* Drop check4dev patch, rely on upstream check.
* Add build dependency on libpq-dev to grass-dev for libpq-fe.h.
* Drop patches applied upstream, refresh remaining patches.
* Update symlinks for images switched from jpg to png.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*!
 
2
   \file lib/vector/Vlib/dgraph.c
 
3
 
 
4
   \brief Vector library - intersection (lower level functions)
 
5
 
 
6
   Higher level functions for reading/writing/manipulating vectors.
 
7
 
 
8
   (C) 2008-2009 by the GRASS Development Team
 
9
 
 
10
   This program is free software under the GNU General Public License
 
11
   (>=v2). Read the file COPYING that comes with GRASS for details.
 
12
 
 
13
   \author Rewritten by Rosen Matev (Google Summer of Code 2008)
 
14
*/
 
15
 
1
16
#include <stdlib.h>
2
17
#include <string.h>
3
18
#include <math.h>
4
 
#include <grass/Vect.h>
5
 
#include <grass/gis.h>
 
19
#include <grass/vector.h>
 
20
#include <grass/glocale.h>
6
21
#include "dgraph.h"
7
22
#include "e_intersect.h"
8
23
 
82
97
 
83
98
/* internal use */
84
99
void add_ipoint1(struct seg_intersection_list *il, int with, double dist,
85
 
                 int ip)
 
100
                        int ip)
86
101
{
87
102
    struct seg_intersection *s;
88
103
 
102
117
}
103
118
 
104
119
/* adds intersection point to the structure */
105
 
void add_ipoint(struct line_pnts *Points, int first_seg, int second_seg,
106
 
                double x, double y, struct seg_intersections *si)
 
120
void add_ipoint(const struct line_pnts *Points, int first_seg, int second_seg,
 
121
                       double x, double y, struct seg_intersections *si)
107
122
{
108
123
    struct intersection_point *t;
109
124
 
136
151
void sort_intersection_list(struct seg_intersection_list *il)
137
152
{
138
153
    int n, i, j, min;
139
 
 
140
154
    struct seg_intersection t;
141
155
 
142
156
    G_debug(4, "sort_intersection_list()");
160
174
    return;
161
175
}
162
176
 
163
 
static int compare(const void *a, const void *b)
 
177
int compare(const void *a, const void *b)
164
178
{
165
179
    struct intersection_point *aa, *bb;
166
180
 
201
215
}
202
216
 
203
217
/* currently O(n*n); future implementation O(nlogn) */
204
 
struct seg_intersections *find_all_intersections(struct line_pnts *Points)
 
218
struct seg_intersections *find_all_intersections(const struct line_pnts *Points)
205
219
{
206
220
    int i, j, np;
207
 
 
208
221
    int group, t;
209
 
 
210
222
    int looped;
211
 
 
212
 
    double EPSILON = 0.00000001;
213
 
 
 
223
    /* double EPSILON = 0.00000001; */
 
224
    double EPSILON = GRASS_EPSILON;
214
225
    double *x, *y;
215
 
 
216
226
    double x1, y1, x2, y2;
217
 
 
218
227
    int res;
219
228
 
220
229
    /*int res2
221
230
       double x1_, y1_, x2_, y2_, z1_, z2_; */
222
231
    struct seg_intersections *si;
223
 
 
224
232
    struct seg_intersection_list *il;
225
 
 
226
233
    struct intersection_point **sorted;
227
234
 
228
235
    G_debug(3, "find_all_intersections()");
245
252
                segment_intersection_2d(x[i], y[i], x[i + 1], y[i + 1], x[j],
246
253
                                        y[j], x[j + 1], y[j + 1], &x1, &y1,
247
254
                                        &x2, &y2);
 
255
 
248
256
            /*            res2 = segment_intersection_2d_e(x[i], y[i], x[i+1], y[i+1], x[j], y[j], x[j+1], y[j+1], &x1_, &y1_, &x2_, &y2_);
249
257
               if ((res != res2) || ((res != 0) && (x1!=x1_ || y1!=y1_)) ) {
250
 
               G_debug(0, "exact=%d orig=%d", res, res2);
 
258
               G_debug(1, "exact=%d orig=%d", res, res2);
251
259
               segment_intersection_2d_test(x[i], y[i], x[i+1], y[i+1], x[j], y[j], x[j+1], y[j+1], &x1, &y1, &x2, &y2);
252
260
               }
253
261
             */
334
342
                    si->ip[si->il[i].a[j].ip].x, si->ip[si->il[i].a[j].ip].y);
335
343
        }
336
344
    }
 
345
    G_free(sorted);
337
346
 
338
347
    return si;
339
348
}
373
382
int pg_existsedge(struct planar_graph *pg, int v1, int v2)
374
383
{
375
384
    struct pg_vertex *v;
376
 
 
377
385
    struct pg_edge *e;
378
 
 
379
386
    int i, ecount;
380
387
 
381
388
    if (pg->v[v1].ecount <= pg->v[v2].ecount)
422
429
        return;
423
430
 
424
431
    if (pg->ecount == pg->eallocated) {
425
 
        G_fatal_error
426
 
            ("Trying to add more edges to the planar_graph than the initial allocation size allows");
 
432
        G_fatal_error(_("Trying to add more edges to the planar_graph "
 
433
                        "than the initial allocation size allows"));
427
434
    }
428
435
    e = &(pg->e[pg->ecount]);
429
436
    e->v1 = v1;
439
446
    return;
440
447
}
441
448
 
442
 
struct planar_graph *pg_create(struct line_pnts *Points)
 
449
struct planar_graph *pg_create(const struct line_pnts *Points)
443
450
{
444
451
    struct seg_intersections *si;
445
 
 
446
452
    struct planar_graph *pg;
447
 
 
448
453
    struct intersection_point *ip;
449
 
 
450
454
    struct pg_vertex *vert;
451
 
 
452
455
    struct pg_edge *edge;
453
456
 
454
457
    int i, j, t, v;