~ubuntu-branches/ubuntu/precise/graphviz/precise-security

« back to all changes in this revision

Viewing changes to lib/neatogen/poly.c

  • Committer: Bazaar Package Importer
  • Author(s): David Claughton
  • Date: 2010-03-24 22:45:18 UTC
  • mfrom: (1.2.7 upstream) (6.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20100324224518-do441tthbqjaqjzd
Tags: 2.26.3-4
Add patch to fix segfault in circo. Backported from upstream snapshot
release.  Thanks to Francis Russell for his work on this.
(Closes: #575255)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: poly.c,v 1.8 2008/06/18 19:28:39 erg Exp $ $Revision: 1.8 $ */
 
1
/* $Id: poly.c,v 1.20 2009/06/03 01:10:54 ellson Exp $ $Revision: 1.20 $ */
2
2
/* vim:set shiftwidth=4 ts=8: */
3
3
 
4
4
/**********************************************************
151
151
    return rv;
152
152
}
153
153
 
154
 
static Point makeScaledPoint(int x, int y)
 
154
static Point makeScaledPoint(double x, double y)
155
155
{
156
156
    Point rv;
157
157
    rv.x = PS2INCH(x);
182
182
}
183
183
 
184
184
#define PUTPT(P,X,Y) ((P).x=(X),(P).y=(Y))
185
 
#define LEN(x,y) sqrt((x)*(x)+(y)*(y))
186
185
 
187
186
void makeAddPoly(Poly * pp, Agnode_t * n, float xmargin, float ymargin)
188
187
{
190
189
    int sides;
191
190
    Point *verts;
192
191
    polygon_t *poly;
193
 
    box b;
 
192
    boxf b;
194
193
 
195
194
    if (ND_clust(n)) {
196
195
        Point b;
197
196
        sides = 4;
198
 
        b.x = ND_width(n) / 2.0 + (xmargin);
199
 
        b.y = ND_height(n) / 2.0 + (ymargin);
 
197
        b.x = ND_width(n) / 2.0 + xmargin;
 
198
        b.y = ND_height(n) / 2.0 + ymargin;
200
199
        pp->kind = BOX;
201
200
        verts = N_GNEW(sides, Point);
202
201
        PUTPT(verts[0], b.x, b.y);
212
211
            if (streq(ND_shape(n)->name, "box"))
213
212
                pp->kind = BOX;
214
213
            else if (streq(ND_shape(n)->name, "polygon")
215
 
                     && isBox(verts, sides))
 
214
                     && isBox(poly->vertices, sides))
216
215
                pp->kind = BOX;
217
216
            else if ((poly->sides < 3) && poly->regular)
218
217
                pp->kind = CIRCLE;
233
232
                    verts[2].y = PS2INCH(poly->vertices[2].y) - ymargin;
234
233
                    verts[3].x = PS2INCH(poly->vertices[3].x) + xmargin;
235
234
                    verts[3].y = PS2INCH(poly->vertices[3].y) - ymargin;
 
235
 
236
236
                }
237
 
                else for (i = 0; i < sides; i++) {
238
 
                    double h = LEN(poly->vertices[i].x,poly->vertices[i].y);
239
 
                    verts[i].x = poly->vertices[i].x * (1.0 + xmargin/h);
240
 
                    verts[i].y = poly->vertices[i].y * (1.0 + ymargin/h);
241
 
                    verts[i].x = PS2INCH(verts[i].x);
242
 
                    verts[i].y = PS2INCH(verts[i].y);
 
237
                else {
 
238
                    for (i = 0; i < sides; i++) {
 
239
                        double h = LEN(poly->vertices[i].x,poly->vertices[i].y);
 
240
                        verts[i].x = poly->vertices[i].x * (1.0 + xmargin/h);
 
241
                        verts[i].y = poly->vertices[i].y * (1.0 + ymargin/h);
 
242
                        verts[i].x = PS2INCH(verts[i].x);
 
243
                        verts[i].y = PS2INCH(verts[i].y);
 
244
                    }
243
245
                }
244
246
            } else
245
247
                verts = genRound(n, &sides, xmargin, ymargin);
278
280
    int sides;
279
281
    Point *verts;
280
282
    polygon_t *poly;
281
 
    box b;
 
283
    boxf b;
282
284
 
283
285
    if (ND_clust(n)) {
284
286
        Point b;
420
422
 
421
423
}
422
424
 
 
425
/* inPoly:
 
426
 * Return 1 if q is inside polygon vertex[]
 
427
 * Assume points are in CCW order
 
428
 */
423
429
static int inPoly(Point vertex[], int n, Point q)
424
430
{
425
431
    int i, i1;                  /* point index; i1 = i-1 mod n */