Logo Search packages:      
Sourcecode: inkscape version File versions

gint sp_bezier_fit_cubic_r ( NR::Point  bezier[],
NR::Point const   data[],
gint const   len,
gdouble const   error,
unsigned const   max_beziers 
)

Fit a multi-segment Bezier curve to a set of digitized points.

Maximum number of generated segments is max_beziers. bezier must be large enough for n. segments * 4 elements.

return value: number of segments generated, or -1 on error.

Definition at line 118 of file bezier-utils.cpp.

{
    g_return_val_if_fail(bezier != NULL, -1);
    g_return_val_if_fail(data != NULL, -1);
    g_return_val_if_fail(len > 0, -1);
    g_return_val_if_fail(max_beziers < (1ul << (31 - 2 - 1 - 3)), -1);

    NR::Point *uniqued_data = g_new(NR::Point, len);
    unsigned uniqued_len = copy_without_nans_or_adjacent_duplicates(data, len, uniqued_data);

    if ( uniqued_len < 2 ) {
        g_free(uniqued_data);
        return 0;
    }

    /* Call fit-cubic function with recursion. */
    gint const ret = sp_bezier_fit_cubic_full(bezier, NULL, uniqued_data, uniqued_len,
                                              unconstrained_tangent, unconstrained_tangent,
                                              error, max_beziers);
    g_free(uniqued_data);
    return ret;
}


Generated by  Doxygen 1.6.0   Back to index