Date:2012-03-18 21:57:04 (12 years 10 days ago)
Author:Werner Almesberger
Commit:5a599e14f6e5ef17ab80ed09148fbb949ecf5bf6
Message:cameo: don't duplicate paths already cleared by the outline

Also pass information on whether we're about to enter or leave a
polygon.
Files: cameo/area.c (4 diffs)

Change Details

cameo/area.c
182182
183183
184184static int hit_path(double fx, double fy, double tx, double ty,
185    const struct path *path, int inside, double r, double *x)
185    const struct path *path, int inside, int enter, double r, double *x)
186186{
187187    const struct point *p;
188188    int left;
...... 
234234
235235
236236static void do_line(const struct path *path, const struct path **sub,
237    double xa, double xb, double y, double r_tool, struct path **res)
237    double xa, double xb, double y, double r_tool, double overlap,
238    struct path **res)
238239{
239240    const struct path *last = path;
240241    const struct path **s;
...... 
242243    double x, next;
243244
244245printf(" y=%g\n", y);
245    if (!hit_path(xa-3*r_tool, y, xb, y, last, 1, r_tool, &x))
246    if (!hit_path(xa-3*r_tool, y, xb, y, last, 1, 0, r_tool, &x))
246247        return;
247248    while (1) {
248249printf(" x=%g\n", x);
249250        next = xb;
250251        last = NULL;
251        if (hit_path(x, y, xb, y, path, 1, r_tool, &next))
252        if (hit_path(x, y, xb, y, path, 1, 1, r_tool, &next))
252253            last = path;
253254        for (s = sub; *s; s++)
254            if (hit_path(x, y, next, y, *s, 0, r_tool, &next))
255            if (hit_path(x, y, next, y, *s, 0, 1, r_tool, &next))
255256                last = *s;
256        new = path_new(r_tool, "");
257        path_add(new, x, y, path->first->z);
258        path_add(new, next, y, path->first->z);
259        new->next = *res;
260        *res = new;
257        if (next-x > 2*r_tool-2*overlap) {
258            new = path_new(r_tool, "");
259            path_add(new, x, y, path->first->z);
260            path_add(new, next, y, path->first->z);
261            new->next = *res;
262            *res = new;
263        }
261264        if (!last)
262265            return;
263        if (!hit_path(next+EPSILON, y, xb, y, last, last == path,
266        if (!hit_path(next+EPSILON, y, xb, y, last, last == path, 0,
264267            r_tool, &x))
265268            return;
266269    }
...... 
291294        return;
292295    sub = subordinates(paths, path);
293296    xa += r_tool;
294    ya += r_tool;
297    ya += 3*r_tool-overlap;
295298    xb -= r_tool;
296    yb -= r_tool;
299    yb -= 3*r_tool-overlap;
297300    n = ceil((yb-ya)/(2*r_tool-overlap));
298301printf("x[%g:%g] y[%g:%g] n=%d\n", xa, xb, ya, yb, n);
299302    for (i = 0; i <= n; i++)
300        do_line(path, sub, xa, xb, ya+(yb-ya)*((double) i/n), r_tool,
301            res);
303        do_line(path, sub, xa, xb, ya+(yb-ya)*((double) i/n),
304            r_tool, overlap, res);
302305    for (s = sub; *s; s++) {
303306        sub2 = subordinates(paths, *s);
304307        for (s2 = sub2; *s2; s2++)

Archive Download the corresponding diff file

Branches:
master



interactive