예제 #1
0
void
get_path_extents(PathIterator& path, const agg::trans_affine& trans,
                 double* x0, double* y0, double* x1, double* y1,
                 double* xm, double* ym)
{
    typedef agg::conv_transform<PathIterator> transformed_path_t;
    typedef PathNanRemover<transformed_path_t> nan_removed_t;
    typedef agg::conv_curve<nan_removed_t> curve_t;
    double x, y;
    unsigned code;

    transformed_path_t tpath(path, trans);
    nan_removed_t nan_removed(tpath, true, path.has_curves());
    curve_t curved_path(nan_removed);

    curved_path.rewind(0);

    while ((code = curved_path.vertex(&x, &y)) != agg::path_cmd_stop)
    {
        if ((code & agg::path_cmd_end_poly) == agg::path_cmd_end_poly)
        {
            continue;
        }
        if (x < *x0) *x0 = x;
        if (y < *y0) *y0 = y;
        if (x > *x1) *x1 = x;
        if (y > *y1) *y1 = y;
        /* xm and ym are the minimum positive values in the data, used
           by log scaling */
        if (x > 0.0 && x < *xm) *xm = x;
        if (y > 0.0 && y < *ym) *ym = y;
    }
}
예제 #2
0
void get_path_extents(PathIterator& path, const agg::trans_affine& trans,
                      double* x0, double* y0, double* x1, double* y1,
                      double* xm, double* ym)
{
    typedef agg::conv_transform<PathIterator> transformed_path_t;
    typedef agg::conv_curve<transformed_path_t> curve_t;
    double x, y;
    unsigned code;

    transformed_path_t tpath(path, trans);
    curve_t curved_path(tpath);

    curved_path.rewind(0);

    while ((code = curved_path.vertex(&x, &y)) != agg::path_cmd_stop)
    {
        if ((code & agg::path_cmd_end_poly) == agg::path_cmd_end_poly)
            continue;
        /* if (MPL_notisfinite64(x) || MPL_notisfinite64(y))
            continue;
           We should not need the above, because the path iterator
           should already be filtering out invalid values.
        */
        if (x < *x0) *x0 = x;
        if (y < *y0) *y0 = y;
        if (x > *x1) *x1 = x;
        if (y > *y1) *y1 = y;
        /* xm and ym are the minimum positive values in the data, used
           by log scaling */
        if (x > 0.0 && x < *xm) *xm = x;
        if (y > 0.0 && y < *ym) *ym = y;
    }
}
예제 #3
0
inline bool point_on_path(double x, double y, double r, PathIterator& path, const agg::trans_affine& trans)
{
    typedef agg::conv_transform<PathIterator> transformed_path_t;
    typedef agg::conv_curve<transformed_path_t> curve_t;
    typedef agg::conv_stroke<curve_t> stroke_t;

    transformed_path_t trans_path(path, trans);
    curve_t curved_path(trans_path);
    stroke_t stroked_path(curved_path);
    stroked_path.width(r * 2.0);
    return point_in_path_impl(x, y, stroked_path);
}
예제 #4
0
inline bool point_in_path(double x, double y, PathIterator& path, const agg::trans_affine& trans)
{
    typedef agg::conv_transform<PathIterator> transformed_path_t;
    typedef agg::conv_curve<transformed_path_t> curve_t;

    if (path.total_vertices() < 3)
        return false;

    transformed_path_t trans_path(path, trans);
    curve_t curved_path(trans_path);
    return point_in_path_impl(x, y, curved_path);
}
예제 #5
0
inline bool
point_in_path(double x, double y, PathIterator& path,
              const agg::trans_affine& trans)
{
    typedef agg::conv_transform<PathIterator> transformed_path_t;
    typedef PathNanRemover<transformed_path_t> no_nans_t;
    typedef agg::conv_curve<no_nans_t> curve_t;

    if (path.total_vertices() < 3)
    {
        return false;
    }

    transformed_path_t trans_path(path, trans);
    no_nans_t no_nans_path(trans_path, true, path.has_curves());
    curve_t curved_path(no_nans_path);
    return point_in_path_impl(x, y, curved_path);
}