Logo Search packages:      
Sourcecode: inkscape version File versions

static double sp_curve_distance_including_space ( SPCurve const *const   curve,
double  seg2len[] 
) [static]

Returns total length of curve, excluding length of closepath segments.

Definition at line 1118 of file curve.cpp.

References SPCurve::_bpath, bezier_len(), NArtBpath::c(), NArtBpath::code, SPCurve::end, Geom::L2(), NR_CURVETO, NR_END, NR_LINETO, NR_MOVETO, and NR_MOVETO_OPEN.

Referenced by sp_curve_nonzero_distance_including_space().

{
    g_return_val_if_fail(curve != NULL, 0.);

    double ret = 0.0;

    if ( curve->_bpath->code == NR_END ) {
        return ret;
    }

    NR::Point prev(curve->_bpath->c(3));
    for (gint i = 1; i < curve->end; ++i) {
        NArtBpath &p = curve->_bpath[i];
        double seg_len = 0;
        switch (p.code) {
            case NR_MOVETO_OPEN:
            case NR_MOVETO:
            case NR_LINETO:
                seg_len = L2(p.c(3) - prev);
                break;

            case NR_CURVETO:
                seg_len = bezier_len(prev, p.c(1), p.c(2), p.c(3), 1.);
                break;

            case NR_END:
                return ret;
        }
        seg2len[i - 1] = seg_len;
        ret += seg_len;
        prev = p.c(3);
    }
    g_assert(!(ret < 0));
    return ret;
}


Generated by  Doxygen 1.6.0   Back to index