mirror of
git://projects.qi-hardware.com/cae-tools.git
synced 2025-04-21 12:27:27 +03:00
cameo/: new commands "remove" and "keep" for path filtering (untested)
This commit is contained in:
38
cameo/ops.c
38
cameo/ops.c
@@ -153,3 +153,41 @@ struct path *reverse_paths(const struct path *paths)
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
static int select_path(const struct path *path, double xa, double ya,
|
||||
double xb, double yb, int inside)
|
||||
{
|
||||
const struct point *p;
|
||||
|
||||
for (p = path->first; p; p = p->next) {
|
||||
if (p->x >= xa && p->x <= xb && p->y >= ya && p->y <= yb) {
|
||||
if (!inside)
|
||||
return 0;
|
||||
} else {
|
||||
if (inside)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
struct path *select_paths(const struct path *paths, double xa, double ya,
|
||||
double xb, double yb, int inside)
|
||||
{
|
||||
struct path *res = NULL, **last = &res;
|
||||
|
||||
if (xa > xb)
|
||||
return select_paths(paths, xb, ya, xa, yb, inside);
|
||||
if (ya > yb)
|
||||
return select_paths(paths, xa, yb, xb, ya, inside);
|
||||
while (paths) {
|
||||
if (select_path(paths, xa, ya, xb, yb, inside)) {
|
||||
*last = path_clone(paths);
|
||||
last = &(*last)->next;
|
||||
}
|
||||
paths = paths->next;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user