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

cameo/area-poly2d.c (area): fail if any paths are open

This commit is contained in:
Werner Almesberger 2015-01-16 08:30:17 -03:00
parent 005dcc308c
commit 4d15951807

View File

@ -1,8 +1,8 @@
/* /*
* area-poly2d.c - Area fill (using libpoly2d) * area-poly2d.c - Area fill (using libpoly2d)
* *
* Written 2012 by Werner Almesberger * Written 2012, 2015 by Werner Almesberger
* Copyright 2012 Werner Almesberger * Copyright 2012, 2015 Werner Almesberger
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -10,6 +10,8 @@
* (at your option) any later version. * (at your option) any later version.
*/ */
#include <stdlib.h>
#include <stdio.h>
#include <math.h> #include <math.h>
#include "poly2d.h" #include "poly2d.h"
@ -47,7 +49,16 @@ struct path *area(const struct path *paths, double overlap)
double z = HUGE_VAL, best_z; double z = HUGE_VAL, best_z;
const struct path *path; const struct path *path;
struct path *res = NULL, **last = &res; struct path *res = NULL, **last = &res;
unsigned n = 0, bad = 0;
for (path = paths; path; path = path->next) {
bad += !path_is_closed(path);
n++;
}
if (bad) {
fprintf(stderr, "%u/%u open paths\n", bad, n);
exit(1);
}
while (1) { while (1) {
best_z = -HUGE_VAL; best_z = -HUGE_VAL;
for (path = paths; path; path = path->next) { for (path = paths; path; path = path->next) {