Repository navigation
Add optional print correction for resin overcure - #6
Merged
Merged
Conversation
Exports every starter template and shipped project file as STL, OpenSCAD and schematic SVG, and compares SHA-256, size, triangle count, volume and bounds with a recorded baseline. Each chip is built twice to assert the exporter is deterministic, which is what makes comparing bytes sound. Re-record with UPDATE_GOLDEN=1 npm test -- goldenExport.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
A standalone, versioned JSON file describing how one printer and resin depart from the geometry they are asked to print: setup metadata, fitted compensation parameters, the coupon version and the raw coupon measurements, so a profile can be re-fitted later. Parsing validates every field with plain-language errors, refuses a newer schema version with a readable message, and hashes a canonical form so reformatting a file does not change its identity.
compensateDesign is one pure function from a nominal design and a profile to the design to print, plus a list of conflicts. Lateral bleed becomes wider dimension markers on a copy of the graph (and larger chambers and drainage vents); vertical cure-through becomes a ceiling raise that the pipeline applies to every roof, leaving floors where they were drawn. The lateral model superposes the exponential stray-dose tails of a channel's two walls, so narrow channels lose more and close at 2*delta + 2*lambda*ln 2. With lambda = 0 it is a constant offset. The ceiling raise is one optional parameter, default 0, through placeChannel, profilePoints, buildChip and exportScad. The default export baseline is unchanged. Conflicts are walls pushed under the printable minimum, channels that merge, features pushed into the edge spacing, and roofs left too thin or broken through, each with the features involved and the shortfall.
The coupon is an ordinary monolithic project: straight rectangular channels, one per width x height, each running through both side walls so it can be flushed and sighted through. Groups are labelled with tally dots, blind holes made from drainage vents, since there is no text primitive. A matching CSV measurement sheet is generated and reads back in.
Measured dimensions give a least-squares fit with a residual; the decay length is fitted only when three or more widths were measured and it cuts the error by more than a tenth. Open/partial/closed results give only the interval between the largest size that closed and the smallest that stayed open, which the fit reports alongside a point estimate and a note that the result is coarse.
Outlines and cross-sections of the nominal and the compensated design, built from the result of compensateDesign with the same loft, placement and profile functions the STL uses. The tests build the compensated chip through the export path and compare the mesh with what the preview draws, for rectangular, trapezoidal and round channels.
planExport returns the nominal design by identity when no profile is selected, with the file name and STL header the app has always written. With a profile it carries the compensated design, a -dfm-<profile> file suffix, and the profile name and hash for the STL header and the OpenSCAD source. The default-export baseline now runs through it. A project may record the profile it was last exported with as an optional dfmProfileRef (name and SHA-256). It is never defaulted, so existing files load and save unchanged, and no format version bump is needed. Loaded profiles live in a browser-level store; the selection is not persisted, so every session starts uncompensated.
A profile selector in the Export section, defaulting to None (uncompensated). With a profile selected: the offsets applied, a non-blocking list of conflicts, a Preview DFM toggle beside the STL button, and a read-only preview panel with a top view, a draggable slice line with cross-sections, a legend and a fullscreen view. A calibration dialog generates the coupon and its measurement sheet, takes open/partial/closed results and optional measured dimensions, shows the fit with what it rests on, and saves a .ocdfm profile.
Draw the open/partial/closed marks rather than relying on Unicode glyphs, keep the STL and Preview DFM buttons on one row in the sidebar, cap the preview zoom, and let a click place the slice line, which is usually off-screen once zoomed in. A roof that already broke through the top face as drawn is no longer reported as a conflict caused by the ceiling raise.
README: the feature in the list, a short usage section and a link to the guide. ARCHITECTURE: how the transform, the profile, the fit, the coupon and the preview fit together, and what the model assumes. The skill's schema reference gains the optional dfmProfileRef field.
Jujified
marked this pull request as ready for review
November 10, 2026 21:14
This branch was successfully deployed
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.
What this changes
Resin printers cure past the intended edge and through the layers above a channel, which narrows small channels and lowers their ceilings. This adds an optional correction for that at export time, driven by a calibration profile for one printer and resin, plus the tooling to make the profile and a preview of the corrected geometry.
It is off by default. With Print correction on
None (uncompensated), the app behaves and exports as it does today.Profile file (
.ocdfm) –src/lib/dfm/profile.tsA standalone, versioned JSON file: setup metadata, the fitted parameters, the coupon version and the raw coupon measurements, so a profile can be re-fitted later. Every field is validated with plain-language errors. A newer
schemaVersionis refused with a readable message rather than half-applied. Identity is a SHA-256 of a canonical form, so reformatting a file does not change it.Compensation –
src/lib/dfm/model.ts,compensate.tscompensateDesign(nominal, profile)is one pure function returning a second design and a conflict list. The STL export, the OpenSCAD export and the preview all call it.2Δ + 2λ·ln 2. Withλ = 0it is a constant offset.ceilingRaiseMm(default 0) throughplaceChannel,profilePoints,buildChipandexportScad. This is the only change to the existing pipeline.Coupon and fit –
coupon.ts,fit.tsThe coupon is an ordinary monolithic project built from nodes, segments and drainage vents, with channels run through both side walls so they are open at both ends. Groups are labelled with tally dots, since there is no text primitive. Open/partial/closed results give a bracket and the UI calls the fit coarse; measured dimensions give a least-squares fit with a residual.
UI –
src/components/dfm/,CadPanel.tsxA profile selector in the Export section. With a profile selected: the offsets applied, the conflict list, a Preview DFM toggle beside the STL button, and a read-only preview panel (top view, draggable slice line with cross-sections, legend, fullscreen). A calibration dialog covers coupon, results and saving the profile. No hint or prompt is shown to users who never open it.
Project file
One optional field,
dfmProfileRef(name and hash of the profile last exported with). It is never defaulted, so existing files load and save unchanged andformatVersionstays at 1. The selection itself is not persisted: every session starts uncompensated.Compensated exports get a
-dfm-<profile>file suffix and record the profile name and hash in the STL header and the OpenSCAD header comments. SVG, PNG and the presentation bundle are not corrected.No new dependencies.
How it was checked
npm run build && npm test && npm run lintpass (527 tests)Tests added:
goldenExport.test.ts: every template and shipped project file exported as STL, OpenSCAD and SVG through the no-profile path and compared byte-for-byte (SHA-256) with a baseline recorded before any feature code. Each chip is built twice to assert the exporter is deterministic.preview.test.ts: the preview's cross-sections equal a slice of the mesh built through the export path, for rectangular, trapezoidal and round channels.For reviewers
src/lib/wikiLinks.tsgains aprintCorrectionlink; the documentation page for it is prepared separately.