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

poly2d/: simplify semantics of first/next offset in area fill

This commit is contained in:
Werner Almesberger 2012-05-07 22:45:39 -03:00
parent 46c8f8653c
commit a950c5b13c
5 changed files with 16 additions and 17 deletions

View File

@ -43,7 +43,6 @@ Not yet specified:
Other: Other:
- change the license from GPL to LGPL - change the license from GPL to LGPL
- transform CGAL's idea of outer polygons into something we can use - transform CGAL's idea of outer polygons into something we can use
- use more meaningful offset/overlap model for area fill
- check for memory leaks - check for memory leaks
- try to generate dependencies also for *.cpp - try to generate dependencies also for *.cpp

View File

@ -32,13 +32,13 @@ static void recurse_area(struct p2d_hier *t, double offset, double overlap,
} }
struct p2d *p2d_area(const struct p2d *p, double offset, double overlap) struct p2d *p2d_area(const struct p2d *p, double first, double next)
{ {
struct p2d_hier *t; struct p2d_hier *t;
struct p2d *res = NULL, **last = &res; struct p2d *res = NULL, **last = &res;
t = p2d_hsort(p); t = p2d_hsort(p);
recurse_area(t, offset, overlap, &last); recurse_area(t, first, next, &last);
p2d_hier_free(t); p2d_hier_free(t);
return res; return res;
} }

View File

@ -52,17 +52,17 @@ static void append_poly(Polygon_2 poly, struct p2d ***last)
} }
static void recurse_area(Polygon_with_holes poly, double curr_off, static void recurse_area(Polygon_with_holes poly, double current,
double next_off, struct p2d ***last) double next, struct p2d ***last)
{ {
PolygonPtrVector tmp = PolygonPtrVector tmp =
CGAL::create_interior_skeleton_and_offset_polygons_with_holes_2( CGAL::create_interior_skeleton_and_offset_polygons_with_holes_2(
curr_off, poly); current, poly);
for (PolygonPtrVector::const_iterator pit = tmp.begin(); for (PolygonPtrVector::const_iterator pit = tmp.begin();
pit != tmp.end(); ++pit) { pit != tmp.end(); ++pit) {
append_poly((*pit)->outer_boundary(), last); append_poly((*pit)->outer_boundary(), last);
recurse_area(**pit, next_off, next_off, last); recurse_area(**pit, next, next, last);
for (Polygon_with_holes::Hole_const_iterator for (Polygon_with_holes::Hole_const_iterator
hit = (*pit)->holes_begin(); hit = (*pit)->holes_begin();
@ -74,7 +74,7 @@ static void recurse_area(Polygon_with_holes poly, double curr_off,
extern "C" void p2d_area_holes_append(const struct p2d *p, extern "C" void p2d_area_holes_append(const struct p2d *p,
const struct p2d *holes, double offset, double overlap, const struct p2d *holes, double first, double next,
struct p2d ***last) struct p2d ***last)
{ {
const struct p2d *h; const struct p2d *h;
@ -87,15 +87,15 @@ extern "C" void p2d_area_holes_append(const struct p2d *p,
poly.add_hole(p2d_to_P2(h, 0)); poly.add_hole(p2d_to_P2(h, 0));
} }
recurse_area(poly, offset, offset-overlap, last); recurse_area(poly, first, next, last);
} }
extern "C" struct p2d *p2d_area_holes(const struct p2d *p, extern "C" struct p2d *p2d_area_holes(const struct p2d *p,
const struct p2d *holes, double offset, double overlap) const struct p2d *holes, double first, double next)
{ {
struct p2d *res = NULL, **last = &res; struct p2d *res = NULL, **last = &res;
p2d_area_holes_append(p, holes, offset, overlap, &last); p2d_area_holes_append(p, holes, first, next, &last);
return res; return res;
} }

View File

@ -127,11 +127,11 @@ struct p2d *p2d_offset_holes(const struct p2d *p, const struct p2d *holes,
struct p2d *p2d_offset(const struct p2d *p, double off); struct p2d *p2d_offset(const struct p2d *p, double off);
void p2d_area_holes_append(const struct p2d *p, void p2d_area_holes_append(const struct p2d *p,
const struct p2d *holes, double offset, double overlap, const struct p2d *holes, double first, double next,
struct p2d ***last); struct p2d ***last);
struct p2d *p2d_area_holes(const struct p2d *p, const struct p2d *holes, struct p2d *p2d_area_holes(const struct p2d *p, const struct p2d *holes,
double offset, double overlap); double first, double next);
struct p2d *p2d_area(const struct p2d *p, double offset, double overlap); struct p2d *p2d_area(const struct p2d *p, double first, double next);
struct p2d *p2d_read_gnuplot(FILE *file); struct p2d *p2d_read_gnuplot(FILE *file);
int p2d_write_gnuplot(FILE *file, const struct p2d *p); int p2d_write_gnuplot(FILE *file, const struct p2d *p);

View File

@ -12,7 +12,7 @@ p2d_append(p, v2d_new(5.5, 0));
p2d_append(p, v2d_new(5.5, 4.5)); p2d_append(p, v2d_new(5.5, 4.5));
p2d_append(p, v2d_new(0, 4.5)); p2d_append(p, v2d_new(0, 4.5));
p2d_close(p); p2d_close(p);
q = p2d_area(p, 1, 0); q = p2d_area(p, 1, 1);
p2d_write_gnuplot_all(stdout, q); p2d_write_gnuplot_all(stdout, q);
EOF EOF
@ -42,7 +42,7 @@ p2d_append(p, v2d_new(5.5, 0));
p2d_append(p, v2d_new(5.5, 4.5)); p2d_append(p, v2d_new(5.5, 4.5));
p2d_append(p, v2d_new(0, 4.5)); p2d_append(p, v2d_new(0, 4.5));
p2d_close(p); p2d_close(p);
q = p2d_area(p, 1, 0.3); q = p2d_area(p, 1, 0.7);
p2d_write_gnuplot_all(stdout, q); p2d_write_gnuplot_all(stdout, q);
EOF EOF
@ -81,7 +81,7 @@ p2d_append(p, v2d_new(18, 8));
p2d_append(p, v2d_new(18, 2)); p2d_append(p, v2d_new(18, 2));
p2d_close(p); p2d_close(p);
q = p2d_area(pl, 0.7, 0); q = p2d_area(pl, 0.7, 0.7);
p2d_write_gnuplot_all(stdout, q); p2d_write_gnuplot_all(stdout, q);
EOF EOF