holder: switch to OpenSCAD Manifold backend (10-50x faster renders)

OpenSCAD 2021.01 (Debian 13 default) is single-threaded CGAL. The Manifold
backend, available in OpenSCAD 2024+, parallelises CSG operations and
gives massive speedups on multi-cell holders.

Bench on this LXC (6 cores), realistic params:
  6x12  (72 cells):  CGAL  3.14s -> Manifold 0.08s   (37x)
  10x20 (200 cells): -                       1.41s
  15x25 (375 cells): -                       1.97s

Installation steps performed on the server (manual, not in this repo):
  wget https://files.openscad.org/snapshots/OpenSCAD-2026.04.26-x86_64.AppImage
  ./AppImage --appimage-extract  (no FUSE required)
  ln -s squashfs-root/AppRun /usr/local/bin/openscad-nightly

Code changes:
- holder.py: new OPENSCAD_BACKEND env var (default "Manifold");
  appends "--backend Manifold" to the openscad call when set.
- deploy/busbar-designer.service: points OPENSCAD_BIN at the
  extracted nightly and sets OPENSCAD_BACKEND=Manifold.

Real-time progress percentage was investigated but not implemented:
OpenSCAD has no headless --progress flag, so live % from the CLI is
not feasible. With Manifold making renders sub-second to a few seconds,
the existing indeterminate progress bar + elapsed timer is sufficient.
This commit is contained in:
wenil
2026-05-25 11:35:20 +03:00
parent af3ed092dc
commit 0aa38809b4
2 changed files with 8 additions and 0 deletions
+4
View File
@@ -28,6 +28,8 @@ from typing import Any
APP_DIR = Path(__file__).resolve().parent
SCAD_FILE = APP_DIR / "scad" / "hex_cell.scad"
OPENSCAD_BIN = os.environ.get("OPENSCAD_BIN", "openscad")
# Empty string disables; default Manifold gives ~10-50x speedup on OpenSCAD 2024+
OPENSCAD_BACKEND = os.environ.get("OPENSCAD_BACKEND", "Manifold")
RENDER_TIMEOUT = int(os.environ.get("OPENSCAD_TIMEOUT", "300"))
@@ -210,6 +212,8 @@ def render_stl(params: dict) -> bytes:
with tempfile.TemporaryDirectory() as tmp:
out = Path(tmp) / "out.stl"
cmd = [OPENSCAD_BIN, "-o", str(out)]
if OPENSCAD_BACKEND:
cmd += ["--backend", OPENSCAD_BACKEND]
for k, v in clean.items():
cmd += ["-D", f"{k}={_to_scad_literal(v)}"]
cmd.append(str(SCAD_FILE))