Repository navigation
Conversation
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.
vibe coded with chatgpt astra xhigh
DEMO: https://github.com/aewallin/opencamlib/actions/runs/39053516922/artifacts/12108573749
This follows PR #184, using
cc0a45das the baseline. It addresses native-object lifetime and repeated-run issues across the bindings, adds optional WebAssembly threading and adaptive-waterline batching, and provides a browser demo with reproducible builds and opt-in GitHub Pages deployment.Core correctness and ownership
WebAssembly threading and wrapper simplification
Add an optional pthread backend for independent point, fiber, and span work. Thread counts are bounded by the available worker pool; worker failures are propagated after started workers have been joined. Adaptive waterline batches midpoint fibers across both sampling directions, then restores their ordering before contour assembly. The serial path retains its recursive traversal. Parallel refinement retains intermediate fibers and therefore uses more temporary memory.
The JavaScript API keeps automatic startup handling: callers can construct an operation and call its methods before the WASM runtime is ready. Each operation waits on one initialization promise. Native calls are synchronous, so promise callback ordering preserves invocation order without maintaining a separate chain after every call.
Input replacement shares one cleanup path for surfaces, cutters, and paths.
dispose()is idempotent, waits for previously requested calls, and rejects subsequent use. WASM objects require explicit disposal; native Node wrappers also support cleanup through GC. Runtime initialization failures propagate consistently to every call. Invalid parameter calls reject without preventing later valid calls.The promise API does not itself move computation off the calling thread. The demo runs the engine in a Web Worker so the viewer remains responsive in both serial and threaded modes.
Browser demo
Sampling presets control sampling density, not a guaranteed machining tolerance. Accuracy also depends on the STL, cutter geometry, pass spacing, step down, and machining setup.
Build, CI, and publishing
Compile the core once per configuration and share it between bindings and tests. Add debug, release, OpenMP, sanitizer, and serial/threaded demo presets. Demo builds enable Release optimization, interprocedural optimization, and native WASM exceptions; threading and native exceptions remain opt-in for general library builds.
CI builds and tests the demo, uploads its generated HTML and screenshots, compares ordered toolpaths across backends, and exercises both WASM exception modes. Browser tests generate their STL fixtures and do not depend on private files. Generated HTML, binaries, caches, logs, and screenshots stay out of source control.
An opt-in Pages job publishes the tested HTML artifact after the core and binding/browser checks pass on the default branch. Enable GitHub Actions as the Pages source and set the repository variable
OCL_PUBLISH_DEMO=true. Pull requests, tags, and other branches do not deploy. The artifact contains only the generatedindex.html.The demo selects its threaded runtime when COOP/COEP isolation headers are available. GitHub Pages uses the serial fallback because it does not supply those headers; the included local server enables threading. Both modes keep calculations in a background worker.
Compatibility
C++ consumers must rebuild because operation ownership, spatial-index storage, and class layouts change. Operations are noncopyable.
Pathsupports deep copying and owns spans added throughappend; directly inserted span pointers remain caller-owned. Invalid inputs now raise exceptions. Native ASCII STL parsing preserves double precision instead of rounding through float32.The wrapper simplification preserves the existing public promise-based operation API. Native WASM exceptions used by the demo require a supporting browser/runtime.
Validation
Completed locally on macOS arm64:
file://loading; uploads; presets; cancellation; exports; Z controls; full cutter geometry; and desktop/mobile layouts. A Pages-style/opencamlib/URL without isolation headers loads successfully and produces the same ordered coordinates as the threaded build./usr/local/include; the consumer usesCMAKE_NO_SYSTEM_FROM_IMPORTED=ONto prioritize the selected installation.The updated CI workflow and Pages deployment have not yet run remotely.