mirror of
git://projects.qi-hardware.com/cae-tools.git
synced 2024-12-23 04:23:55 +02:00
cameo: "area" now works on Z layers individually (untested)
This commit is contained in:
parent
5ecce7de9e
commit
18c9477137
@ -170,6 +170,9 @@ what "offset" does.
|
|||||||
The overlap is the distance by which the areas cleared by parallel paths
|
The overlap is the distance by which the areas cleared by parallel paths
|
||||||
should overlap.
|
should overlap.
|
||||||
|
|
||||||
|
If the current paths have different Z coordinates, each level is
|
||||||
|
processed separately.
|
||||||
|
|
||||||
|
|
||||||
Drill/mill conversion:
|
Drill/mill conversion:
|
||||||
|
|
||||||
|
45
cameo/area.c
45
cameo/area.c
@ -16,7 +16,6 @@
|
|||||||
* outlines without cutting into anything it's not supposed to.
|
* outlines without cutting into anything it's not supposed to.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@ -209,18 +208,20 @@ static int hit_path(double fx, double fy, double tx, double ty,
|
|||||||
|
|
||||||
|
|
||||||
static const struct path **subordinates(const struct path *paths,
|
static const struct path **subordinates(const struct path *paths,
|
||||||
const struct path *path)
|
const struct path *path, double z)
|
||||||
{
|
{
|
||||||
const struct path **sub, **w, **a, **b;;
|
const struct path **sub, **w, **a, **b;;
|
||||||
const struct path *p;
|
const struct path *p;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
|
|
||||||
for (p = paths; p; p = p->next)
|
for (p = paths; p; p = p->next)
|
||||||
|
if (p->first && p->first->z == z)
|
||||||
n++;
|
n++;
|
||||||
sub = alloc_size(sizeof(struct path *)*n);
|
sub = alloc_size(sizeof(struct path *)*n);
|
||||||
w = sub;
|
w = sub;
|
||||||
for (p = paths; p; p = p->next)
|
for (p = paths; p; p = p->next)
|
||||||
if (p != path && is_inside(p, path) && !is_inside(path, p))
|
if (p != path && p->first && p->first->z == z &&
|
||||||
|
is_inside(p, path) && !is_inside(path, p))
|
||||||
*w++ = p;
|
*w++ = p;
|
||||||
*w = NULL;
|
*w = NULL;
|
||||||
for (a = sub; a != w; a++)
|
for (a = sub; a != w; a++)
|
||||||
@ -283,7 +284,7 @@ static void add_outline(const struct path *path, int inside, struct path **res)
|
|||||||
|
|
||||||
|
|
||||||
static void fill_path(const struct path *paths, const struct path *path,
|
static void fill_path(const struct path *paths, const struct path *path,
|
||||||
double r_tool, double overlap, struct path **res)
|
double z, double r_tool, double overlap, struct path **res)
|
||||||
{
|
{
|
||||||
const struct path **sub, **s;
|
const struct path **sub, **s;
|
||||||
const struct path **sub2, **s2;
|
const struct path **sub2, **s2;
|
||||||
@ -292,7 +293,7 @@ static void fill_path(const struct path *paths, const struct path *path,
|
|||||||
|
|
||||||
if (!bbox(path, &xa, &ya, &xb, &yb))
|
if (!bbox(path, &xa, &ya, &xb, &yb))
|
||||||
return;
|
return;
|
||||||
sub = subordinates(paths, path);
|
sub = subordinates(paths, path, z);
|
||||||
xa += r_tool;
|
xa += r_tool;
|
||||||
ya += 3*r_tool-overlap;
|
ya += 3*r_tool-overlap;
|
||||||
xb -= r_tool;
|
xb -= r_tool;
|
||||||
@ -302,9 +303,9 @@ static void fill_path(const struct path *paths, const struct path *path,
|
|||||||
do_line(path, sub, xa, xb, ya+(yb-ya)*((double) i/n),
|
do_line(path, sub, xa, xb, ya+(yb-ya)*((double) i/n),
|
||||||
r_tool, overlap, res);
|
r_tool, overlap, res);
|
||||||
for (s = sub; *s; s++) {
|
for (s = sub; *s; s++) {
|
||||||
sub2 = subordinates(paths, *s);
|
sub2 = subordinates(paths, *s, z);
|
||||||
for (s2 = sub2; *s2; s2++)
|
for (s2 = sub2; *s2; s2++)
|
||||||
fill_path(paths, *s2, r_tool, overlap, res);
|
fill_path(paths, *s2, z, r_tool, overlap, res);
|
||||||
free(sub2);
|
free(sub2);
|
||||||
add_outline(*s, 0, res);
|
add_outline(*s, 0, res);
|
||||||
}
|
}
|
||||||
@ -313,12 +314,36 @@ static void fill_path(const struct path *paths, const struct path *path,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct path *area(const struct path *path, double overlap)
|
struct path *area(const struct path *paths, double overlap)
|
||||||
{
|
{
|
||||||
struct path *res = NULL;
|
struct path *res = NULL;
|
||||||
|
double z = HUGE_VAL, best_x, x;
|
||||||
|
const struct path *path, *best;
|
||||||
|
const struct point *p;
|
||||||
|
|
||||||
if (!path)
|
if (!paths)
|
||||||
return NULL;
|
return NULL;
|
||||||
fill_path(path, path_find_leftmost(path), path->r_tool, overlap, &res);
|
while (1) {
|
||||||
|
best = NULL;
|
||||||
|
best_x = HUGE_VAL;
|
||||||
|
for (path = paths; path; path = path->next) {
|
||||||
|
if (!path->first)
|
||||||
|
continue;
|
||||||
|
if (path->first->z >= z)
|
||||||
|
continue;
|
||||||
|
x = HUGE_VAL;
|
||||||
|
for (p = path->first; p; p = p->next)
|
||||||
|
if (p->x < x)
|
||||||
|
x = p->x;
|
||||||
|
if (best && best->first->z >= path->first->z &&
|
||||||
|
x >= best_x)
|
||||||
|
continue;
|
||||||
|
best = path;
|
||||||
|
best_x = x;
|
||||||
|
}
|
||||||
|
if (!best)
|
||||||
return res;
|
return res;
|
||||||
|
z = best->first->z;
|
||||||
|
fill_path(paths, best, z, best->r_tool, overlap, &res);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,6 @@
|
|||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
|
||||||
|
|
||||||
struct path *area(const struct path *path, double overlap);
|
struct path *area(const struct path *paths, double overlap);
|
||||||
|
|
||||||
#endif /* !AREA_H */
|
#endif /* !AREA_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user