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

poly2d/p2d_hsort.c (p2d_hier_free): make freeing of polygons optional

This commit is contained in:
Werner Almesberger 2013-10-13 21:29:48 -03:00
parent 3d8a8d04aa
commit d758359791
4 changed files with 15 additions and 12 deletions

View File

@ -37,6 +37,6 @@ struct f2d *f2d_tri(const struct p2d *p)
t = p2d_hsort(p);
recurse_area(t, &last);
p2d_hier_free(t);
p2d_hier_free(t, 0);
return res;
}

View File

@ -1,8 +1,8 @@
/*
* p2d_area.c - Fill a set of nested polygons
*
* Written 2012 by Werner Almesberger
* Copyright 2012 Werner Almesberger
* Written 2012, 2013 by Werner Almesberger
* Copyright 2012, 2013 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
@ -39,6 +39,6 @@ struct p2d *p2d_area(const struct p2d *p, double first, double next)
t = p2d_hsort(p);
recurse_area(t, first, next, &last);
p2d_hier_free(t);
p2d_hier_free(t, 1);
return res;
}

View File

@ -1,8 +1,8 @@
/*
* p2d_hsort.c - Hierarchical polygon sort
*
* Written 2012 by Werner Almesberger
* Copyright 2012 Werner Almesberger
* Written 2012, 2013 by Werner Almesberger
* Copyright 2012, 2013 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
@ -92,16 +92,17 @@ struct p2d_hier *p2d_hsort(const struct p2d *p)
}
void p2d_hier_free(struct p2d_hier *t)
void p2d_hier_free(struct p2d_hier *t, bool free_poly)
{
struct p2d_hier *next;
struct p2d *p;
while (t) {
p2d_hier_free(t->holes);
p2d_hier_free(t->holes, free_poly);
p = &t->p;
next = p2d_to_hier(p->next);
p2d_free(p);
if (free_poly)
p2d_free(p);
t = next;
}
}

View File

@ -1,8 +1,8 @@
/*
* p2d_hsort.h - Hierarchical polygon sort
*
* Written 2012 by Werner Almesberger
* Copyright 2012 Werner Almesberger
* Written 2012, 2013 by Werner Almesberger
* Copyright 2012, 2013 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
@ -14,6 +14,8 @@
#ifndef P2D_HSORT_H
#define P2D_HSORT_H
#include <stdbool.h>
#include "poly2d.h"
@ -27,6 +29,6 @@ struct p2d_hier {
struct p2d_hier *p2d_hsort(const struct p2d *p);
void p2d_hier_free(struct p2d_hier *t);
void p2d_hier_free(struct p2d_hier *t, bool free_poly);
#endif /* !P2D_HSORT_H */