1
0
mirror of git://projects.qi-hardware.com/cae-tools.git synced 2025-04-21 12:27:27 +03:00

cameo/: move conversion between poly2d and "struct path" from area-poly2d.c to poly2d.c

Untested.
This commit is contained in:
Werner Almesberger
2012-06-12 14:58:46 -03:00
parent f48754e067
commit 7b54293bff
4 changed files with 130 additions and 35 deletions

View File

@@ -12,7 +12,7 @@
#include <math.h>
#include <poly2d.h>
#include "poly2d.h"
#include "path.h"
#include "area.h"
@@ -22,46 +22,22 @@ static void fill_path(const struct path *paths, double z, double overlap,
struct path ***res)
{
const struct path *path;
const struct point *p;
double r_tool;
struct p2d *polys = NULL, *poly, *last = NULL;
double r_tool = 0;
struct p2d *polys;
struct p2d *fill;
const struct v2d *v;
for (path = paths; path; path = path->next) {
if (path->first->z != z)
continue;
if (!path->first || !path->first->next)
continue;
r_tool = path->r_tool;
for (path = paths; path; path = path->next)
if (path->first && path->first->z == z)
r_tool = path->r_tool;
poly = p2d_new();
if (last)
last->next = poly;
else
polys = poly;
last = poly;
for (p = path->first; p && p->next; p = p->next)
p2d_append(poly, v2d_new(p->x, p->y));
p2d_close(poly);
}
polys = paths_to_polys_z(paths, z, z);
fill = p2d_area(polys, r_tool, 2*r_tool-overlap);
p2d_free_all(polys);
for (poly = fill; poly; poly = poly->next) {
**res = path_new(r_tool, "");
v = poly->v;
while (v) {
path_add(**res, v->x, v->y, z);
v = v->next;
if (v == poly->v)
break;
}
if (v)
path_add(**res, v->x, v->y, z);
**res = polys_to_paths(fill, r_tool, z);
while (**res)
*res = &(**res)->next;
}
p2d_free_all(fill);
}