From 0d4172901bb0f9a37c46cd46da786cf92155774c Mon Sep 17 00:00:00 2001 From: jaseg Date: Thu, 30 Mar 2023 15:05:09 +0200 Subject: Fix scale of drill mapping test --- gerbolyze/tests/resources/layers.svg | 738 +++++++++++++++++++++-------------- gerbolyze/tests/test_integration.py | 4 +- svg-flatten/src/svg_doc.cpp | 8 +- 3 files changed, 445 insertions(+), 305 deletions(-) diff --git a/gerbolyze/tests/resources/layers.svg b/gerbolyze/tests/resources/layers.svg index 1879033..33ff4ab 100644 --- a/gerbolyze/tests/resources/layers.svg +++ b/gerbolyze/tests/resources/layers.svg @@ -82,7 +82,7 @@ id="rect1146-5" /> + inkscape:window-maximized="1" + showguides="false" /> + transform="matrix(1.0463418,0,0,1.0463418,-43.953115,62.062388)" + style="stroke-width:0.955711"> + transform="translate(59.673046,11.13409)" + style="stroke-width:0.955711"> + transform="translate(-70.372474)" + style="stroke-width:0.955711"> + transform="translate(71.659431)" + style="stroke-width:0.955711" /> + id="use1685" + style="stroke-width:0.955711" /> + id="use1687" + style="stroke-width:0.955711" /> + id="use1689" + style="stroke-width:0.955711" /> + id="use1691" + style="stroke-width:0.955711" /> + id="use1693" + style="stroke-width:0.955711" /> + id="use1695" + style="stroke-width:0.955711" /> + id="use1697" + style="stroke-width:0.955711" /> + id="use1699" + style="stroke-width:0.955711" /> + id="use1701" + style="stroke-width:0.955711" /> + id="use1703" + style="stroke-width:0.955711" /> + id="use1705" + style="stroke-width:0.955711" /> + id="use1707" + style="stroke-width:0.955711" /> + id="use1709" + style="stroke-width:0.955711" /> + id="use1711" + style="stroke-width:0.955711" /> + id="use1713" + style="stroke-width:0.955711" /> + id="use1715" + style="stroke-width:0.955711" /> + id="use1717" + style="stroke-width:0.955711" /> + id="use1719" + style="stroke-width:0.955711" /> + id="use1721" + style="stroke-width:0.955711" /> + id="use1723" + style="stroke-width:0.955711" /> + id="use1725" + style="stroke-width:0.955711" /> + id="use1727" + style="stroke-width:0.955711" /> + id="use1729" + style="stroke-width:0.955711" /> + id="use1731" + style="stroke-width:0.955711" /> + id="use1733" + style="stroke-width:0.955711" /> + id="use1735" + style="stroke-width:0.955711" /> + id="use1737" + style="stroke-width:0.955711" /> + id="use1739" + style="stroke-width:0.955711" /> + id="use1741" + style="stroke-width:0.955711" /> + id="use1743" + style="stroke-width:0.955711" /> + id="use1745" + style="stroke-width:0.955711" /> + id="use1747" + style="stroke-width:0.955711" /> + id="use1749" + style="stroke-width:0.955711" /> + id="use1751" + style="stroke-width:0.955711" /> + id="g3579" + style="stroke-width:0.955711"> + transform="translate(-4.0047091,11.13409)" + style="stroke-width:0.955711"> + transform="translate(71.659431)" + style="stroke-width:0.955711" /> + id="use1792" + style="stroke-width:0.955711" /> + id="use1794" + style="stroke-width:0.955711" /> + id="use1796" + style="stroke-width:0.955711" /> + id="use1798" + style="stroke-width:0.955711" /> + id="use1800" + style="stroke-width:0.955711" /> + id="use1802" + style="stroke-width:0.955711" /> + id="use1804" + style="stroke-width:0.955711" /> + id="use1810" + style="stroke-width:0.955711" /> + id="use1818" + style="stroke-width:0.955711" /> + id="use1824" + style="stroke-width:0.955711" /> + id="use1832" + style="stroke-width:0.955711" /> + id="use1838" + style="stroke-width:0.955711" /> + id="use1848" + style="stroke-width:0.955711" /> + id="use1850" + style="stroke-width:0.955711" /> + transform="translate(3.0096666,11.13409)" + style="stroke-width:0.955711"> + transform="translate(71.659431)" + style="stroke-width:0.955711" /> + id="use1864" + style="stroke-width:0.955711" /> + id="use1866" + style="stroke-width:0.955711" /> + id="use1868" + style="stroke-width:0.955711" /> + id="use1870" + style="stroke-width:0.955711" /> + id="use1872" + style="stroke-width:0.955711" /> + id="use1874" + style="stroke-width:0.955711" /> + id="use1888" + style="stroke-width:0.955711" /> + id="use1902" + style="stroke-width:0.955711" /> + id="use1916" + style="stroke-width:0.955711" /> + id="use1930" + style="stroke-width:0.955711" /> + transform="translate(10.024042,11.13409)" + style="stroke-width:0.955711"> + id="use1936" + style="stroke-width:0.955711" /> + id="use1938" + style="stroke-width:0.955711" /> + id="use1940" + style="stroke-width:0.955711" /> + id="use1942" + style="stroke-width:0.955711" /> + id="use1944" + style="stroke-width:0.955711" /> + id="use1946" + style="stroke-width:0.955711" /> + id="use1948" + style="stroke-width:0.955711" /> + id="use1956" + style="stroke-width:0.955711" /> + id="use1962" + style="stroke-width:0.955711" /> + id="use1970" + style="stroke-width:0.955711" /> + id="use1976" + style="stroke-width:0.955711" /> + id="use1984" + style="stroke-width:0.955711" /> + id="use1992" + style="stroke-width:0.955711" /> + id="use1994" + style="stroke-width:0.955711" /> + id="use1996" + style="stroke-width:0.955711" /> + id="use1998" + style="stroke-width:0.955711" /> + id="use2000" + style="stroke-width:0.955711" /> + id="use2002" + style="stroke-width:0.955711" /> + transform="translate(17.038418,11.13409)" + style="stroke-width:0.955711"> + transform="translate(71.659431)" + style="stroke-width:0.955711" /> + id="use2020" + style="stroke-width:0.955711" /> + id="use2034" + style="stroke-width:0.955711" /> + id="use2036" + style="stroke-width:0.955711" /> + id="use2038" + style="stroke-width:0.955711" /> + id="use2040" + style="stroke-width:0.955711" /> + id="use2042" + style="stroke-width:0.955711" /> + id="use2044" + style="stroke-width:0.955711" /> + id="use2046" + style="stroke-width:0.955711" /> + id="use2048" + style="stroke-width:0.955711" /> + id="use2062" + style="stroke-width:0.955711" /> + transform="translate(24.052794,11.13409)" + style="stroke-width:0.955711"> + transform="translate(71.659431)" + style="stroke-width:0.955711" /> + id="use2080" + style="stroke-width:0.955711" /> + id="use2082" + style="stroke-width:0.955711" /> + id="use2084" + style="stroke-width:0.955711" /> + id="use2086" + style="stroke-width:0.955711" /> + id="use2088" + style="stroke-width:0.955711" /> + id="use2090" + style="stroke-width:0.955711" /> + id="use2092" + style="stroke-width:0.955711" /> + id="use2098" + style="stroke-width:0.955711" /> + id="use2104" + style="stroke-width:0.955711" /> + id="use2106" + style="stroke-width:0.955711" /> + id="use2112" + style="stroke-width:0.955711" /> + id="use2118" + style="stroke-width:0.955711" /> + id="use2120" + style="stroke-width:0.955711" /> + id="use2126" + style="stroke-width:0.955711" /> + id="use2132" + style="stroke-width:0.955711" /> + id="use2134" + style="stroke-width:0.955711" /> + id="use2140" + style="stroke-width:0.955711" /> + id="use2146" + style="stroke-width:0.955711" /> + transform="translate(31.06717,11.13409)" + style="stroke-width:0.955711"> + transform="translate(71.659431)" + style="stroke-width:0.955711" /> + id="use2440" + style="stroke-width:0.955711" /> + id="use2442" + style="stroke-width:0.955711" /> + id="use2444" + style="stroke-width:0.955711" /> + id="use2446" + style="stroke-width:0.955711" /> + id="use2448" + style="stroke-width:0.955711" /> + id="use2450" + style="stroke-width:0.955711" /> + id="use2452" + style="stroke-width:0.955711" /> + id="use2464" + style="stroke-width:0.955711" /> + id="use2466" + style="stroke-width:0.955711" /> + id="use2478" + style="stroke-width:0.955711" /> + id="use2480" + style="stroke-width:0.955711" /> + id="use2492" + style="stroke-width:0.955711" /> + id="use2496" + style="stroke-width:0.955711" /> + id="use2498" + style="stroke-width:0.955711" /> + id="use2500" + style="stroke-width:0.955711" /> + id="use2502" + style="stroke-width:0.955711" /> + id="use2504" + style="stroke-width:0.955711" /> @@ -1504,12 +1642,12 @@ inkscape:groupmode="layer"> + transform="matrix(0.74819266,0,0,0.74819266,-35.646202,78.405074)" + style="stroke-width:1.33656"> + style="stroke-width:1.33656"> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656"> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656"> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656"> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656"> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656"> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656"> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656"> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656"> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> + style="stroke-width:1.33656" /> diff --git a/gerbolyze/tests/test_integration.py b/gerbolyze/tests/test_integration.py index 7456e85..5232cb1 100644 --- a/gerbolyze/tests/test_integration.py +++ b/gerbolyze/tests/test_integration.py @@ -82,6 +82,6 @@ def test_convert_layers(): assert set(round(ap.diameter, 4) for ap in stack[layer].apertures) == {dia, 0.05} # Note: svg-flatten rounds these diameters to the geometric tolerance given on the command line (0.01mm by - # default). Thus, these values are different from the more precise values in the SVG. - assert set(stack.drill_layers[0].drill_sizes()) == {0.67, 0.51} + # default). + assert set(stack.drill_layers[0].drill_sizes()) == {0.7, 0.5} diff --git a/svg-flatten/src/svg_doc.cpp b/svg-flatten/src/svg_doc.cpp index 77b561e..afb3a68 100644 --- a/svg-flatten/src/svg_doc.cpp +++ b/svg-flatten/src/svg_doc.cpp @@ -298,10 +298,12 @@ void gerbolyze::SVGDocument::export_svg_path(RenderContext &ctx, const pugi::xml d2p centroid = nopencv::polygon_centroid(geom_poly); centroid[0] /= clipper_scale; centroid[1] /= clipper_scale; + /* area of n-gon with circumradius 1 relative to circle with radius 1 */ - double ngon_area_relative = p.size()/(2*std::numbers::pi) * sin(2*std::numbers::pi / p.size()); - double diameter = sqrt(4*fabs(area)/std::numbers::pi) / clipper_scale / ngon_area_relative; - double tolerance = ctx.settings().geometric_tolerance_mm / 2; + //double ngon_area_relative = p.size()/(2*std::numbers::pi) * sin(2*std::numbers::pi / p.size()); + // ^- correction not necessary, we already do a very good job. + double diameter = sqrt(4*fabs(area)/std::numbers::pi) / clipper_scale; + double tolerance = ctx.settings().geometric_tolerance_mm; diameter = round(diameter/tolerance) * tolerance; ctx.sink() << ApertureToken(diameter) << FlashToken(centroid); } -- cgit