From d6ca9cdf71f3c4f06797fb5459127cfe1cd55e9d Mon Sep 17 00:00:00 2001 From: jaseg Date: Mon, 23 Sep 2024 22:44:31 +0200 Subject: svg-flatten: Fix uniformity calculation Previously, the uniformity check miscalculated the worst-case absolute deviation --- svg-flatten/include/geom2d.hpp | 5 +- .../testdata/svg/xform_uniformity_threshold.svg | 292 +++++---------------- 2 files changed, 69 insertions(+), 228 deletions(-) (limited to 'svg-flatten') diff --git a/svg-flatten/include/geom2d.hpp b/svg-flatten/include/geom2d.hpp index 34455cd..28ce024 100644 --- a/svg-flatten/include/geom2d.hpp +++ b/svg-flatten/include/geom2d.hpp @@ -180,10 +180,11 @@ namespace gerbolyze { } double imbalance = f_max / f_min - 1.0; - //cerr << " * skew check: " << dbg_str(); + bool okay = imbalance < rel_tol && (f_max - f_min)*fabs(dist_doc) < abs_tol; + //cerr << " " << (okay ? "." : "#") << " skew check: " << dbg_str(); //cerr << " imbalance=" << imbalance << endl; //cerr << " rel=" << (imbalance < rel_tol) << " abs=" << (imbalance*fabs(dist_doc) < abs_tol) << endl; - return imbalance < rel_tol && imbalance*fabs(dist_doc) < abs_tol; + return okay; } double doc2phys_min(double dist_doc) { diff --git a/svg-flatten/testdata/svg/xform_uniformity_threshold.svg b/svg-flatten/testdata/svg/xform_uniformity_threshold.svg index d9a6c02..e8a1dc1 100644 --- a/svg-flatten/testdata/svg/xform_uniformity_threshold.svg +++ b/svg-flatten/testdata/svg/xform_uniformity_threshold.svg @@ -7,7 +7,7 @@ viewBox="0 0 80 160" version="1.1" id="svg5" - inkscape:version="1.2.2 (b0a8486541, 2022-12-01)" + inkscape:version="1.3.2 (091e20ef0f, 2023-11-25, custom)" sodipodi:docname="xform_uniformity_threshold.svg" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" @@ -24,11 +24,11 @@ inkscape:deskcolor="#d1d1d1" inkscape:document-units="mm" showgrid="false" - inkscape:zoom="8.6041055" - inkscape:cx="139.00341" - inkscape:cy="420.14827" - inkscape:window-width="1920" - inkscape:window-height="1011" + inkscape:zoom="3.0420107" + inkscape:cx="28.928235" + inkscape:cy="187.54043" + inkscape:window-width="3840" + inkscape:window-height="2091" inkscape:window-x="0" inkscape:window-y="0" inkscape:window-maximized="1" @@ -48,10 +48,11 @@ id="layer1"> + id="g4187" + style="opacity:1"> + transform="matrix(1,0,-0.01745506,1,0.23376669,15.875)" + style="opacity:1"> - - - - - - - - + transform="matrix(1,0,-0.03491012,1,0.46753338,31.750001)" + style="opacity:1"> + transform="matrix(1,0,-0.05236518,1,0.70130007,47.625002)" + style="opacity:1"> + transform="matrix(1,0,-0.06982024,1,0.93506676,63.500003)" + style="opacity:1"> + transform="matrix(1,0,-0.08748866,1,17.046691,0)" + style="opacity:1"> + transform="matrix(1,0,-0.10494372,1,17.280458,15.875)" + style="opacity:1"> - - - - - - - - + transform="matrix(1,0,-0.12239878,1,17.514225,31.750001)" + style="opacity:1"> + transform="matrix(1,0,-0.13985384,1,17.747991,47.625002)" + style="opacity:1"> + transform="matrix(1,0,-0.1573089,1,17.981758,63.500003)" + style="opacity:1"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - + transform="matrix(1,0,-0.17497732,1,34.093383,0)" + style="opacity:1"> + transform="matrix(1,0,-0.19243238,1,34.32715,15.875)" + style="opacity:1"> - - - - - - - - + transform="matrix(1,0,-0.20988744,1,34.560917,31.750001)" + style="opacity:1"> + transform="matrix(1,0,-0.2273425,1,34.794683,47.625002)" + style="opacity:1"> + transform="matrix(1,0,-0.24479756,1,35.02845,63.500003)" + style="opacity:1"> + transform="matrix(1,0,-0.26246598,1,51.140075,0)" + style="opacity:1"> + transform="matrix(1,0,-0.27992104,1,51.373842,15.875)" + style="opacity:1"> - - - - - - - - + transform="matrix(1,0,-0.2973761,1,51.607609,31.750001)" + style="opacity:1"> + transform="matrix(1,0,-0.31483116,1,51.841375,47.625002)" + style="opacity:1"> + transform="matrix(1,0,-0.33228622,1,52.075142,63.500003)" + style="opacity:1">