From 4d159518071045b960f186c8dea1ce5c6f3cc5e1 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Fri, 16 Jan 2015 08:30:17 -0300 Subject: [PATCH] cameo/area-poly2d.c (area): fail if any paths are open --- cameo/area-poly2d.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/cameo/area-poly2d.c b/cameo/area-poly2d.c index 7d506b5..643f6de 100644 --- a/cameo/area-poly2d.c +++ b/cameo/area-poly2d.c @@ -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 +#include #include #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) {