Logo Search packages:      
Sourcecode: inkscape version File versions

SPCurve* sp_curve_append_continuous ( SPCurve c0,
SPCurve const *  c1,
gdouble  tolerance 
)

Append c1 to c0 with possible fusing of close endpoints.

Todo:
fixme: Strictly we mess in case of multisegment mixed open/close curves

Definition at line 854 of file curve.cpp.

References SPCurve::closed, NArtBpath::code, SPCurve::end, NR_CURVETO, NR_END, NR_LINETO, NR_MOVETO, NR_MOVETO_OPEN, sp_curve_append(), sp_curve_closepath(), sp_curve_curveto(), sp_curve_first_bpath(), sp_curve_last_bpath(), sp_curve_lineto(), sp_curve_moveto(), NArtBpath::x1, NArtBpath::x2, NArtBpath::x3, NArtBpath::y1, NArtBpath::y2, and NArtBpath::y3.

Referenced by fit_and_split(), and spdc_pen_finish_segment().

{
    g_return_val_if_fail(c0 != NULL, NULL);
    g_return_val_if_fail(c1 != NULL, NULL);
    g_return_val_if_fail(!c0->closed, NULL);
    g_return_val_if_fail(!c1->closed, NULL);

    if (c1->end < 1) {
        return c0;
    }

    NArtBpath *be = sp_curve_last_bpath(c0);
    if (be) {
        NArtBpath const *bs = sp_curve_first_bpath(c1);
        if ( bs
             && ( fabs( bs->x3 - be->x3 ) <= tolerance )
             && ( fabs( bs->y3 - be->y3 ) <= tolerance ) )
        {
            /** \todo
             * fixme: Strictly we mess in case of multisegment mixed
             * open/close curves
             */
            bool closed = false;
            for (bs = bs + 1; bs->code != NR_END; bs++) {
                switch (bs->code) {
                    case NR_MOVETO_OPEN:
                        if (closed) sp_curve_closepath(c0);
                        sp_curve_moveto(c0, bs->x3, bs->y3);
                        closed = false;
                        break;
                    case NR_MOVETO:
                        if (closed) sp_curve_closepath(c0);
                        sp_curve_moveto(c0, bs->x3, bs->y3);
                        closed = true;
                        break;
                    case NR_LINETO:
                        sp_curve_lineto(c0, bs->x3, bs->y3);
                        break;
                    case NR_CURVETO:
                        sp_curve_curveto(c0, bs->x1, bs->y1, bs->x2, bs->y2, bs->x3, bs->y3);
                        break;
                    case NR_END:
                        g_assert_not_reached();
                }
            }
        } else {
            sp_curve_append(c0, c1, TRUE);
        }
    } else {
        sp_curve_append(c0, c1, TRUE);
    }

    return c0;
}


Generated by  Doxygen 1.6.0   Back to index