1
0
mirror of git://projects.qi-hardware.com/cae-tools.git synced 2024-12-22 23:43:00 +02:00

cameo/path.c: move assert(path_is_closed) into function and improve diagnostic

It's often hard to find an offending path. To help with this, we
now print the start and end coordinates.
This commit is contained in:
Werner Almesberger 2012-06-12 14:01:55 -03:00
parent e69fa24133
commit 382d14dcbb

View File

@ -106,6 +106,17 @@ static int path_is_closed(const struct path *path)
}
static void assert_path_is_closed(const struct path *path)
{
if (path_is_closed(path))
return;
fprintf(stderr, "path from (%g, %g, %g) to (%g, %g, %g) is open\n",
path->first->x, path->first->y, path->first->z,
path->last->x, path->last->y, path->last->z);
abort();
}
static void path_add_point(struct path *path, struct point *p)
{
if (path->last &&
@ -284,7 +295,8 @@ int path_tool_is_left(const struct path *path)
const struct point *prev, *p, *next;
double a = 0;
assert(path_is_closed(path));
assert_path_is_closed(path);
prev = path->first;
for (p = path->first->next; p; p = p->next) {
next = p->next ? p->next : path->first->next;
@ -335,7 +347,7 @@ struct path *path_offset(const struct path *path, int left, int notch)
struct point *n, *n2;
int dog;
assert(path_is_closed(path));
assert_path_is_closed(path);
if (path->first == path->last)
return circle(path->first->x, path->first->y, path->first->z,
path->r_tool, path->r_tool, 0.1, path->id);