Repository navigation
Multi-head 2/7: window analysis core - #97
Conversation
React-free primitives for multi-head printing: expand auto-paint zones into printer layers, Beer-Lambert color stack, LUT/window scoring and window selection. Not used by the app yet. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
|
Unit test results for this branch ( |
vycdev
left a comment
There was a problem hiding this comment.
Automated code review
Verdict: Needs changes · Findings: 3 (3 inline)
Scope: this PR's changes against develop; the earlier PRs in this stack are reviewed in their own threads.
The new module is isolated and React-free, but three verified discrepancies make its analysis diverge from the existing printable stack. All 24 added tests, focused ESLint, and TypeScript checks passed. The full suite finished with 883 passing tests and one failure in the unchanged Windows file-association installer test.
Reviewed by GPT 6.1 Sol
| let currentZ = 0; | ||
| let layerIndex = 0; | ||
|
|
||
| while (currentZ < totalHeight) { |
There was a problem hiding this comment.
[medium] Keep layer expansion on the existing printable grid
Unrounded currentZ accumulation affects both loop termination and zone selection. With the tests' black/white fixture and 0.12/0.20 mm settings, the canonical stack has 84 layers ending at 10.16 mm, but this function produces 85 ending at 10.28 mm. At 0.10 mm, accumulated Z also falls just below the 6.6 mm filament boundary, delaying the change by one layer. Use result.finalStack.layers, or match the existing printable-stack rounding and epsilon comparisons, so windows describe the actual model.
Reviewed by GPT 6.1 Sol
| return imageSwatches.map((s) => { | ||
| const rgb = hexToRgb(s.hex); | ||
| const lum = getLuminance(rgb) / 255; | ||
| const h = luminanceToHeight(lum, transitionZones, totalHeight, firstLayerHeight); |
There was a problem hiding this comment.
[medium] Use the existing swatch-to-height mappings
Linear luminance interpolation does not reproduce auto-paint's color-based height mapping. In the existing black/white test fixture, #808080 maps to 7.04 mm in result.finalStack.targetMappings, while this code assigns it to a layer ending at 8.48 mm. Consequently, affected swatches, baseline errors, and optimal LUT entries are calculated for different physical stacks than preview/export uses. Pass through the final-stack mappings, or reuse the shared palette mapper, and resolve their surface heights to the correct layer indices.
Reviewed by GPT 6.1 Sol
| layers.push({ | ||
| filamentIdx: Math.max(0, filamentIdx), | ||
| filamentRgb: hexToRgb(zone.filamentColor), | ||
| td: channelHds(filament ?? FALLBACK_FILAMENT), |
There was a problem hiding this comment.
[medium] Preserve fitted optics in baseline and candidate simulations
This conversion drops the zones' effective colors, effective HDs, and transition optics, replacing them with raw profile properties. Valid Stack Matrix results therefore use a different optical model here: a 0.125 mm white layer over black with effective HDs [1, 1.1, 1.2] and effective color [235, 240, 245] produces approximately [177, 177, 177] here versus [126, 124, 122] in the existing stack prediction—about 20 ΔE apart. Carry the result's fitted optical model through both baseline and LUT simulations, resolving transitions when assignments change substrates.
Reviewed by GPT 6.1 Sol
- Reuse final printable layers and swatch surface mappings - Preserve fitted optics and resolve substrates for candidate runs - Add seven regression tests and update the unreleased changelog
Fixes for the automated reviewPushed Findings
Verification: All 31 multi-head analysis tests pass. Fixed by GPT 6.1 Sol |
vycdev
left a comment
There was a problem hiding this comment.
Automated code review: second pass
Verdict: Needs changes · New or remaining findings: 2 (2 inline)
Reviewed head 942bd1e, which includes the fixes for the first review. Scope: this PR's changes against develop; the other PRs in this stack are reviewed in their own threads.
The three first-pass defects are resolved. All 91 focused tests pass, as do TypeScript and ESLint checks. Two additional correctness issues remain: scoring discards appearance corrections, and selected assignments can shorten the required opaque foundation.
First-pass findings
- ✅ Resolved: Keep layer expansion on the existing printable grid. Expansion now copies finalStack.layers directly and rejects mismatched slice settings. Regression tests verify boundaries, thicknesses, and filament assignments on both reported grids.
- ✅ Resolved: Use the existing swatch-to-height mappings. Existing swatches reuse final-stack target mappings; additional swatches use the shared palette mapper. Surface heights resolve to layer indices with an epsilon comparison.
- ✅ Resolved: Preserve fitted optics in baseline and candidate simulations. Zone optics are retained, consecutive runs accumulate thickness, and candidate transitions resolve changed substrates. Tests compare these predictions against the shared fitted-optics predictor, including suffixes and continuation beyond support.
Reviewed by GPT 6.1 Sol
| const pixels = buildPixelData( | ||
| imageSwatches, layers, colorAtLayer, result.finalStack | ||
| ); | ||
| const effectiveOptics = result.finalStack.appearanceModel.effectiveOptics; |
There was a problem hiding this comment.
[medium] Apply the full appearance model when scoring assignments
This path retains only effectiveOptics, discarding the appearance corrections used to produce the final-stack mappings and preview colors. With black/gray/white HDs of 0.05/0.5/0.5 mm, 0.08/0.16 mm layer settings, a valid deltaL: 6 appearance model, and swatches #808080/#e0e0e0, window [5,6] chooses white/white and worsens the latter swatch from approximately 1.06 to 4.92 ΔE under the actual appearance model. Use snapshot predictions for baseline errors and run candidate prefixes through the shared full appearance resolver before scoring.
Reviewed by GPT 6.1 Sol
|
|
||
| const windows: WindowResult[] = []; | ||
|
|
||
| for (let wStart = 1; wStart + N <= layers.length; wStart++) { |
There was a problem hiding this comment.
[medium] Preserve the minimum opaque foundation in LUT candidates
Starting at layer 1 protects only the first physical layer, allowing candidates to replace later layers of the reserved foundation. With ordinary black/white filaments (td: 0.5 each), 0.08/0.16 mm layer settings, and swatches #808080/#e0e0e0, the selected window [7,8] uses white/black, moving the first transition to 0.64 mm despite the foundation's 0.72 mm minimum. The simulator still treats that shortened run as opaque. Lock the required foundation layers or reject assignments that violate its minimum thickness.
Reviewed by GPT 6.1 Sol
- Use snapshot baselines and resolve full candidate appearance corrections - Preserve required foundation layers without changing LUT indices - Add four regression tests and update the existing Added changelog entry
# Conflicts: # CHANGELOG.md
Fixes for the second automated reviewPushed Findings
Verification: Full unit suite 895/895, Fixed by GPT 6.1 Sol |
Second of seven stacked PRs splitting up #38 (Multi Print Head Capability). Independent of part 1; targets
developdirectly.What
React-free primitives in
src/lib/multiHeadAnalysis.ts:channelHds()model, so hiding distance is not scaled a second time)Nothing in the app calls it yet; the run-based engine that builds on it is part 3.
Tests
tests/multiHeadAnalysis.test.ts(24 tests).tscis clean and the full unit suite passes (884 tests, 0 failures, 1 skipped).Stack
mph-split-3-color-runs)mph-split-4-schedule-plan)mph-split-5-ui-wiring)mph-split-6-docs)mph-split-7-color-grouping)No changelog entry: this is internal groundwork with no user-visible change.
🤖 Generated with Claude Code