mirror of
git://projects.qi-hardware.com/cae-tools.git
synced 2024-12-23 08:59:53 +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,
|
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;
|
const struct point *p;
|
||||||
int left;
|
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,
|
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 *last = path;
|
||||||
const struct path **s;
|
const struct path **s;
|
||||||
@ -242,25 +243,27 @@ static void do_line(const struct path *path, const struct path **sub,
|
|||||||
double x, next;
|
double x, next;
|
||||||
|
|
||||||
printf(" y=%g\n", y);
|
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;
|
return;
|
||||||
while (1) {
|
while (1) {
|
||||||
printf(" x=%g\n", x);
|
printf(" x=%g\n", x);
|
||||||
next = xb;
|
next = xb;
|
||||||
last = NULL;
|
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;
|
last = path;
|
||||||
for (s = sub; *s; s++)
|
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;
|
last = *s;
|
||||||
new = path_new(r_tool, "");
|
if (next-x > 2*r_tool-2*overlap) {
|
||||||
path_add(new, x, y, path->first->z);
|
new = path_new(r_tool, "");
|
||||||
path_add(new, next, y, path->first->z);
|
path_add(new, x, y, path->first->z);
|
||||||
new->next = *res;
|
path_add(new, next, y, path->first->z);
|
||||||
*res = new;
|
new->next = *res;
|
||||||
|
*res = new;
|
||||||
|
}
|
||||||
if (!last)
|
if (!last)
|
||||||
return;
|
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))
|
r_tool, &x))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -291,14 +294,14 @@ static void fill_path(const struct path *paths, const struct path *path,
|
|||||||
return;
|
return;
|
||||||
sub = subordinates(paths, path);
|
sub = subordinates(paths, path);
|
||||||
xa += r_tool;
|
xa += r_tool;
|
||||||
ya += r_tool;
|
ya += 3*r_tool-overlap;
|
||||||
xb -= r_tool;
|
xb -= r_tool;
|
||||||
yb -= r_tool;
|
yb -= 3*r_tool-overlap;
|
||||||
n = ceil((yb-ya)/(2*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);
|
printf("x[%g:%g] y[%g:%g] n=%d\n", xa, xb, ya, yb, n);
|
||||||
for (i = 0; i <= n; i++)
|
for (i = 0; i <= n; i++)
|
||||||
do_line(path, sub, xa, xb, ya+(yb-ya)*((double) i/n), r_tool,
|
do_line(path, sub, xa, xb, ya+(yb-ya)*((double) i/n),
|
||||||
res);
|
r_tool, overlap, res);
|
||||||
for (s = sub; *s; s++) {
|
for (s = sub; *s; s++) {
|
||||||
sub2 = subordinates(paths, *s);
|
sub2 = subordinates(paths, *s);
|
||||||
for (s2 = sub2; *s2; s2++)
|
for (s2 = sub2; *s2; s2++)
|
||||||
|
Loading…
Reference in New Issue
Block a user