Logo Search packages:      
Sourcecode: inkscape version File versions

static NArtBpath * sp_bpath_clean ( NArtBpath const   bpath[]  )  [static]

Return copy of a bpath array, discarding any inconsistencies.

Definition at line 938 of file curve.cpp.

References NArtBpath::code, NR_CURVETO, NR_END, NR_LINETO, sp_bpath_check_subpath(), and sp_bpath_length().

Referenced by sp_curve_new_from_foreign_bpath().

{
    NArtBpath *new_bpath = g_new(NArtBpath, sp_bpath_length(bpath));

    NArtBpath const *bp = bpath;
    NArtBpath *np = new_bpath;

    while (bp->code != NR_END) {
        if (sp_bpath_check_subpath(bp)) {
            *np++ = *bp++;
            while ((bp->code == NR_LINETO) ||
                   (bp->code == NR_CURVETO))
                *np++ = *bp++;
        } else {
            bp++;
            while ((bp->code == NR_LINETO) ||
                   (bp->code == NR_CURVETO))
                bp++;
        }
    }

    if (np == new_bpath) {
        g_free(new_bpath);
        return NULL;
    }

    np->code = NR_END;
    np += 1;

    new_bpath = g_renew(NArtBpath, new_bpath, np - new_bpath);

    return new_bpath;
}


Generated by  Doxygen 1.6.0   Back to index