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
1 changed files with 13 additions and 2 deletions

View File

@ -1,8 +1,8 @@
/*
* area-poly2d.c - Area fill (using libpoly2d)
*
* Written 2012 by Werner Almesberger
* Copyright 2012 Werner Almesberger
* Written 2012, 2015 by Werner Almesberger
* Copyright 2012, 2015 Werner Almesberger
*
* 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
@ -10,6 +10,8 @@
* (at your option) any later version.
*/
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include "poly2d.h"
@ -47,7 +49,16 @@ struct path *area(const struct path *paths, double overlap)
double z = HUGE_VAL, best_z;
const struct path *path;
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) {
best_z = -HUGE_VAL;
for (path = paths; path; path = path->next) {