Logo Search packages:      
Sourcecode: inkscape version File versions

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

Perform consistency check of bpath array.

Returns:
Address of NR_END node or NULL.

Todo:
effic: consider checking for END/MOVE/MOVETO inside switch block

Definition at line 995 of file curve.cpp.

References NArtBpath::code, NR_CURVETO, NR_END, NR_LINETO, NR_MOVETO, NR_MOVETO_OPEN, NArtBpath::x3, and NArtBpath::y3.

Referenced by sp_bpath_clean(), and sp_bpath_good().

{
    g_return_val_if_fail(bpath != NULL, NULL);

    bool closed;
    if (bpath->code == NR_MOVETO) {
        closed = true;
    } else if (bpath->code == NR_MOVETO_OPEN) {
        closed = false;
    } else {
        return NULL;
    }

    gint len = 0;
    gint i;
    /** \todo
     * effic: consider checking for END/MOVE/MOVETO inside switch block
     */
    for (i = 1; (bpath[i].code != NR_END) && (bpath[i].code != NR_MOVETO) && (bpath[i].code != NR_MOVETO_OPEN); i++) {
        switch (bpath[i].code) {
            case NR_LINETO:
            case NR_CURVETO:
                len++;
                break;
            default:
                return NULL;
        }
    }

    if (closed) {
        if (len < 1)
            return NULL;

        if ((bpath->x3 != bpath[i-1].x3) || (bpath->y3 != bpath[i-1].y3))
            return NULL;
    } else {
        if (len < 1)
            return NULL;
    }

    return bpath + i;
}


Generated by  Doxygen 1.6.0   Back to index