mirror of
git://projects.qi-hardware.com/cae-tools.git
synced 2024-12-23 04:13:20 +02:00
cameo: don't duplicate paths already cleared by the outline
Also pass information on whether we're about to enter or leave a polygon.
This commit is contained in:
parent
35c0624dc5
commit
5a599e14f6
33
cameo/area.c
33
cameo/area.c
@ -182,7 +182,7 @@ printf("\tna %g (%g) nb %g (%g)\n", na, fx+tx*na, nb, fx+tx*nb);
|
||||
|
||||
|
||||
static int hit_path(double fx, double fy, double tx, double ty,
|
||||
const struct path *path, int inside, double r, double *x)
|
||||
const struct path *path, int inside, int enter, double r, double *x)
|
||||
{
|
||||
const struct point *p;
|
||||
int left;
|
||||
@ -234,7 +234,8 @@ static const struct path **subordinates(const struct path *paths,
|
||||
|
||||
|
||||
static void do_line(const struct path *path, const struct path **sub,
|
||||
double xa, double xb, double y, double r_tool, struct path **res)
|
||||
double xa, double xb, double y, double r_tool, double overlap,
|
||||
struct path **res)
|
||||
{
|
||||
const struct path *last = path;
|
||||
const struct path **s;
|
||||
@ -242,25 +243,27 @@ static void do_line(const struct path *path, const struct path **sub,
|
||||
double x, next;
|
||||
|
||||
printf(" y=%g\n", y);
|
||||
if (!hit_path(xa-3*r_tool, y, xb, y, last, 1, r_tool, &x))
|
||||
if (!hit_path(xa-3*r_tool, y, xb, y, last, 1, 0, r_tool, &x))
|
||||
return;
|
||||
while (1) {
|
||||
printf(" x=%g\n", x);
|
||||
next = xb;
|
||||
last = NULL;
|
||||
if (hit_path(x, y, xb, y, path, 1, r_tool, &next))
|
||||
if (hit_path(x, y, xb, y, path, 1, 1, r_tool, &next))
|
||||
last = path;
|
||||
for (s = sub; *s; s++)
|
||||
if (hit_path(x, y, next, y, *s, 0, r_tool, &next))
|
||||
if (hit_path(x, y, next, y, *s, 0, 1, r_tool, &next))
|
||||
last = *s;
|
||||
new = path_new(r_tool, "");
|
||||
path_add(new, x, y, path->first->z);
|
||||
path_add(new, next, y, path->first->z);
|
||||
new->next = *res;
|
||||
*res = new;
|
||||
if (next-x > 2*r_tool-2*overlap) {
|
||||
new = path_new(r_tool, "");
|
||||
path_add(new, x, y, path->first->z);
|
||||
path_add(new, next, y, path->first->z);
|
||||
new->next = *res;
|
||||
*res = new;
|
||||
}
|
||||
if (!last)
|
||||
return;
|
||||
if (!hit_path(next+EPSILON, y, xb, y, last, last == path,
|
||||
if (!hit_path(next+EPSILON, y, xb, y, last, last == path, 0,
|
||||
r_tool, &x))
|
||||
return;
|
||||
}
|
||||
@ -291,14 +294,14 @@ static void fill_path(const struct path *paths, const struct path *path,
|
||||
return;
|
||||
sub = subordinates(paths, path);
|
||||
xa += r_tool;
|
||||
ya += r_tool;
|
||||
ya += 3*r_tool-overlap;
|
||||
xb -= r_tool;
|
||||
yb -= r_tool;
|
||||
yb -= 3*r_tool-overlap;
|
||||
n = ceil((yb-ya)/(2*r_tool-overlap));
|
||||
printf("x[%g:%g] y[%g:%g] n=%d\n", xa, xb, ya, yb, n);
|
||||
for (i = 0; i <= n; i++)
|
||||
do_line(path, sub, xa, xb, ya+(yb-ya)*((double) i/n), r_tool,
|
||||
res);
|
||||
do_line(path, sub, xa, xb, ya+(yb-ya)*((double) i/n),
|
||||
r_tool, overlap, res);
|
||||
for (s = sub; *s; s++) {
|
||||
sub2 = subordinates(paths, *s);
|
||||
for (s2 = sub2; *s2; s2++)
|
||||
|
Loading…
Reference in New Issue
Block a user