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

« back to all changes in this revision

Viewing changes to vector/v.voronoi/sw_main.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:
30
30
 
31
31
    if (siteidx < nsites) {
32
32
        s = &sites[siteidx];
33
 
        siteidx += 1;
 
33
        siteidx++;
34
34
        return (s);
35
35
    }
36
36
    else
72
72
 
73
73
    if (j != nsites) {
74
74
        nsites = j;
75
 
        sites = (struct Site *)G_realloc(sites, nsites * sizeof(*sites));
 
75
        sites = (struct Site *)G_realloc(sites, nsites * sizeof(struct Site));
76
76
    }
77
77
 
78
78
}
80
80
/* read all sites, sort, and compute xmin, xmax, ymin, ymax */
81
81
int readsites(void)
82
82
{
83
 
    int i, nlines, line;
 
83
    int nlines, line;
84
84
    struct line_pnts *Points;
85
85
 
86
86
    Points = Vect_new_line_struct();
88
88
    nlines = Vect_get_num_lines(&In);
89
89
 
90
90
    nsites = 0;
91
 
    sites = (struct Site *)myalloc(nlines * sizeof(*sites));
 
91
    sites = (struct Site *)G_malloc(nlines * sizeof(struct Site));
92
92
 
93
93
    for (line = 1; line <= nlines; line++) {
94
94
        int type;
108
108
            G_debug(3, "Points->z[0]: %f", Points->z[0]);
109
109
            sites[nsites].coord.z = Points->z[0];
110
110
        }
 
111
        else
 
112
            sites[nsites].coord.z = 0.0;
111
113
 
112
114
        sites[nsites].sitenbr = nsites;
113
115
        sites[nsites].refcnt = 0;
114
 
        nsites += 1;
115
 
        if (nsites % 4000 == 0)
116
 
            sites =
117
 
                (struct Site *)G_realloc(sites,
118
 
                                         (nsites + 4000) * sizeof(*sites));
 
116
 
 
117
        if (nsites > 1) {
 
118
            if (xmin > sites[nsites].coord.x)
 
119
                xmin = sites[nsites].coord.x;
 
120
            if (xmax < sites[nsites].coord.x)
 
121
                xmax = sites[nsites].coord.x;
 
122
            if (ymin > sites[nsites].coord.y)
 
123
                ymin = sites[nsites].coord.y;
 
124
            if (ymax < sites[nsites].coord.y)
 
125
                ymax = sites[nsites].coord.y;
 
126
        }
 
127
        else {
 
128
            xmin = xmax = sites[nsites].coord.x;
 
129
            ymin = ymax = sites[nsites].coord.y;
 
130
        }
 
131
        nsites++;
119
132
    }
120
133
 
121
 
    qsort(sites, nsites, sizeof(*sites), scomp);
 
134
    if (nsites < nlines - 1)
 
135
        sites =
 
136
            (struct Site *)G_realloc(sites,
 
137
                                     (nsites) * sizeof(struct Site));
 
138
 
 
139
    qsort(sites, nsites, sizeof(struct Site), scomp);
122
140
    removeDuplicates();
123
 
    xmin = sites[0].coord.x;
124
 
    xmax = sites[0].coord.x;
125
 
    for (i = 1; i < nsites; i += 1) {
126
 
        if (sites[i].coord.x < xmin)
127
 
            xmin = sites[i].coord.x;
128
 
        if (sites[i].coord.x > xmax)
129
 
            xmax = sites[i].coord.x;
130
 
    }
131
 
    ymin = sites[0].coord.y;
132
 
    ymax = sites[nsites - 1].coord.y;
 
141
 
133
142
    return 0;
134
143
}
135
144
 
141
150
    s = (struct Site *)getfree(&sfl);
142
151
    s->refcnt = 0;
143
152
    s->sitenbr = siteidx;
144
 
    siteidx += 1;
 
153
    siteidx++;
145
154
 
146
155
    if (scanf("%lf %lf", &(s->coord.x), &(s->coord.y)) == EOF)
147
156
        return ((struct Site *)NULL);