Repository navigation
import(): weld an AMF object's vertices by exact position - #270
Merged
Merged
Conversation
OpenSCAD (checked against 2026.02.01) treats an AMF object's vertices at
exactly the same position as one vertex, so a closed object written as a
triangle soup -- or with its vertex list duplicated, or a solid with a
through-hole whose triangles never share indices -- imports as a closed
solid. We took the indices as written, so every such file came in as an
open surface ("N boundary edges, M unwelded vertices") that could not
take part in CSG.
Each object is now welded with STL's existing exact-match weldVertices
(moved out of mesh_import.cpp's anonymous namespace). The weld is per
object, never across objects, and never merges near-coincident vertices,
matching OpenSCAD's import; its CSG-time repair of near-coincident
vertices is a generic polyhedron/PolySet behaviour, not AMF's.
Genuinely open meshes stay open, as in OpenSCAD. A corpus of 148
STL/OFF/OBJ/3MF/AMF files imports byte-identically before and after; of
30 hand-written and generated AMF cases only the 6 with duplicated
positions changed, each to OpenSCAD's closed result.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 8, 2026
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.
An AMF object whose triangles don't share vertex indices -- a triangle soup, or a duplicated vertex list -- imported as an open surface ("N boundary edges, M unwelded vertices") that could not take part in CSG. OpenSCAD 2026.02.01 merges an object's vertices at exactly the same position, so the same file imports closed there, including a solid with a through-hole (genus 1).
Fix
loadAmfnow reads each object into its ownLoadedMesh, runs the STL importer's existingweldVerticeson it, then appends it with the index offset: exact-only and per object, as OpenSCAD does (objects are never welded to each other).weldVerticesmoves out ofmesh_import.cpp's anonymous namespace intomesh_import.hpp. CLAUDE.md's AMF note is corrected (unitis ignored, as in OpenSCAD) and describes the weld.What OpenSCAD does (from running the binary only)
polyhedron()-- a separate item).Verification
tests/test_import_export.cpp(2 fail on the old code; the third pins the per-object boundary). Full suite: 1471 passed.🤖 Generated with Claude Code