import(): AMF, X3D and VRML97; a .pdf or malformed SVG no longer hangs - #219
Merged
Merged
Conversation
The three multi-object formats export writes that nothing could read back. Geometry only, like the other mesh loaders, but each format's scene structure is honoured: - X3D and VRML: Transforms nest and apply in full (translation, rotation, scale, center, scaleOrientation), DEF/USE resolves, ccw FALSE flips winding, IndexedFaceSet polygons fan-triangulate; X3D also reads IndexedTriangleSet and TriangleSet. X3D goes through a small XML parser, VRML through a tokenizer and generic node parser that steps over PROTO, EXTERNPROTO and ROUTE. VRML 1.0 is refused by name. - AMF: plain or zipped, unit scaled to millimetres. What is not a mesh -- X3D/VRML primitives, Inline, AMF constellations -- is reported through LoadedMesh::warnings, which both faces of import() emit. Current upstream OpenSCAD removed its AMF importer, so all three go beyond it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The SVG parser's attribute loop stopped on a character no attribute can
start with -- a '/' not followed by '>', a stray '=' -- without consuming
it, and came straight back to it forever. A PDF is full of "/Name", so
import("x.pdf"), which routed .pdf to the SVG parser, hung for good; so
did a malformed SVG such as `<a / b>`. The loop now steps past such a
character, and .pdf is no longer routed to the SVG parser at all: nothing
reads PDF (OpenSCAD does not either), so it takes the ordinary
"unsupported file type '.pdf'" error.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Sep 30, 2026
Merged
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
import()now reads AMF, X3D and VRML97, the three multi-object formats export writes that nothing could read back. Current upstream OpenSCAD removed its AMF importer (bf7a0970b), so all three go beyond it.Geometry only, like the STL/OBJ/OFF/3MF loaders, but each format's scene structure is honoured:
Transforms nest and apply in full: translation, rotation, scale, center and scaleOrientation (T·C·R·SR·S·SR⁻¹·C⁻¹).DEF/USEresolves, andccw FALSEflips winding.IndexedFaceSetpolygons are fan-triangulated; a last polygon without-1still counts.IndexedTriangleSetandTriangleSet.PROTO,EXTERNPROTOandROUTE; VRML 1.0 is refused by name.unit(inch, feet, metre, micron) scaled to mm.Inline, AMF constellations) is skipped with a warning,import: '<file>': skipped what is not a mesh: 1 Box, from both the geometry and expression forms ofimport().Tested (8 new tests):
USEunder a rotation, a tetrahedron withccw="false"and aBox. Expected and got a volume of 13.5, the right bounding box, and the Box warning.PROTO/ROUTE/comments. Expected and got volume 9, and a maximum x of 30, which proves the rotation applied.Suites: all 1346 C++ tests pass, all 61 binding tests pass, and BelfrySCAD's full suite (2187) passes against this build.
Also fixes an
import()hang. The SVG parser's attribute loop stopped on a character no attribute can start with (a/not followed by>, a stray=) without consuming it, then came back to it forever. A PDF is full of/Name, soimport("x.pdf")(routed to the SVG parser) hung for good, and so did a malformed SVG like<a / b>. The loop now steps past such a character, and.pdfis no longer routed to the SVG parser: nothing reads PDF (OpenSCAD doesn't either), so it gets the ordinary "unsupported file type" error. Both files that hung now fail in under half a second, and 3 new tests cover them.🤖 Generated with Claude Code