diff options
author | jaseg <git@jaseg.de> | 2022-06-19 13:42:58 +0200 |
---|---|---|
committer | jaseg <git@jaseg.de> | 2022-06-19 13:42:58 +0200 |
commit | 676eff0a30866fd00558d71232b0c101b97b4073 (patch) | |
tree | 747c4120687b4fab636de958da410d70fe9f8df8 /svg-flatten | |
parent | 31b5a77c8a574ad1eee7fe9ead0a1a8cd14989f6 (diff) | |
download | gerbolyze-676eff0a30866fd00558d71232b0c101b97b4073.tar.gz gerbolyze-676eff0a30866fd00558d71232b0c101b97b4073.tar.bz2 gerbolyze-676eff0a30866fd00558d71232b0c101b97b4073.zip |
svg-flatten: Fix drills in patterns
Diffstat (limited to 'svg-flatten')
-rw-r--r-- | svg-flatten/src/svg_doc.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/svg-flatten/src/svg_doc.cpp b/svg-flatten/src/svg_doc.cpp index 42338e8..b1c253a 100644 --- a/svg-flatten/src/svg_doc.cpp +++ b/svg-flatten/src/svg_doc.cpp @@ -270,13 +270,23 @@ void gerbolyze::SVGDocument::export_svg_path(RenderContext &ctx, const pugi::xml double polsby_popper = 4*M_PI * area / pow(nopencv::polygon_perimeter(geom_poly), 2); polsby_popper = fabs(fabs(polsby_popper) - 1.0); if (polsby_popper < ctx.settings().drill_test_polsby_popper_tolerance) { + if (!ctx.clip().empty()) { + Clipper c; + c.AddPath(p, ptSubject, /* closed */ true); + c.AddPaths(ctx.clip(), ptClip, /* closed */ true); + c.StrictlySimple(true); + c.Execute(ctDifference, ptree_fill, pftNonZero, pftNonZero); + if (ptree_fill.Total() > 0) + continue; + } + d2p centroid = nopencv::polygon_centroid(geom_poly); centroid[0] /= clipper_scale; centroid[1] /= clipper_scale; double diameter = sqrt(4*fabs(area)/M_PI) / clipper_scale; diameter = ctx.mat().doc2phys_dist(diameter); /* FIXME is this correct w.r.t. PolygonScaler? */ diameter = round(diameter * 1000.0) / 1000.0; /* Round to micrometer precsion; FIXME: make configurable */ - ctx.sink() << ApertureToken(diameter) << DrillToken(ctx.mat().doc2phys(centroid)); + ctx.sink() << ApertureToken(diameter) << DrillToken(centroid); } } return; |