Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SVG rendering incorrect for a path with multiple simple subpaths. #3809

Closed
DavidPhillipOster opened this issue Jun 10, 2021 · 2 comments
Closed

Comments

@DavidPhillipOster
Copy link

DavidPhillipOster commented Jun 10, 2021

The python qrcode package pyqrcode generates SVG using a series of short horizontal and vertical line segments.

Example of creating the .svg attached.

import pyqrcode
from pyqrcode import QRCode
getqrcode = pyqrcode.create("A")
getqrcode.svg("qrA.svg", scale=1)

OpenSCAD version 2021.01, given the following .scad file:

import("qrA.svg");

does not parse this correctly compared to Inkscape and Google Chrome. qrA.svg could be worked up into a unit test.

Originally posted by @DavidPhillipOster in #1740 (comment)

but reduced to a smaller file, with expected and actual results.

the SVG file

qrA.svg renamed so I can attach it here: qrA_svg.txt

Expected results

qrA.svg as rendered by Chrome A-Chrome and Inkscape A-Inkscape

Actual results

as rendered by OpenSCAD version 2021.01
A-OpenSCAD

The problem is most visible in the corners - what should be a square surrounded by a larger square is merged into a single shape.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@MichaelAtOz
Copy link
Member

Note that QR codes seem to frequently contain points which become non-manifold.
e.g. http://forum.openscad.org/Preview-OK-Render-gets-only-half-tp33306p33315.html
That won't be the cause of the above issue, but could be your next problem.
As shown, offset() is a work-around.

@DavidPhillipOster
Copy link
Author

DavidPhillipOster commented Jun 11, 2021

Thank you. Yes:

linear_extrude(1)offset(0.001)import("qrA.svg");

reports as valid. Without the offset() I get:

ERROR: The given mesh is not closed! Unable to convert to CGAL_Nef_Polyhedron. 

But the rendering is still badly wrong: the donut shapes look nothing like they are supposed to.

To anyone in the future reading this: Python's pyqrcode can generate .png files just a well as .svg and I'd expect that OpenSCAD would have no trouble with a .png barcode.

jumostedu added a commit to jumostedu/openscad that referenced this issue Mar 9, 2024
jumostedu added a commit to jumostedu/openscad that referenced this issue Mar 9, 2024
With fix for openscad#3809 this test failed. New expected png now matches how
other applications (firefox, gwenview, ...) render the input svg.
@t-paul t-paul closed this as completed in 099d200 Mar 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants