Inspiration

Every garment factory and sheet-metal shop has a scrap bin next to the cutting table. It fills up with the fabric and aluminium left between the parts: the curves around a sleeve, the corners around a bracket. That material was bought, shipped and dyed or rolled, and it is thrown away before a single product exists. Unlike most waste, it can't be woven or rolled back into stock.

A lot of it comes from how layouts are made. Simple nesting tools and manual layouts treat every curved part as its bounding rectangle and pack the rectangles. We wanted to see how much of that bin disappears if a computer packs the real shapes instead, fast enough to use at the cutting table and verifiable enough to trust.

What it does

CutZero is a nesting engine and browser studio for irregular 2D parts on a roll or sheet. Try it live in your browser: no install needed.

  • Two rolls, drawn to scale. The top roll is the industry-style baseline (first-fit bounding boxes, waste shaded red). Press Run and the bottom roll animates live as the C++ engine streams better layouts, until it locks in with a green cut-line and a hatched saved material zone.
  • Measured results (200 iterations, 2 mm kerf, 100-lay batch):
Workload Utilization Roll saved / 100 lays Scrap prevented
Men's dress shirt, 28 pieces 60.6% → 76.8% 70.2 m 19.0 kg
Shell jacket, 36 pieces 67.6% → 79.1% 40.4 m 12.5 kg
Sheet-metal enclosure, 24 parts 44.1% → 61.4% 64.8 m 209.9 kg
  • Fabric flaws. Click the roll to mark holes or stains. The engine nests around them: the shirt with three flaws goes from 50.5% to 71.0%, with every part a full kerf clear of every flaw.
  • Ready to cut. Export a true-scale SVG, an AutoCAD R12 DXF for cutting-room CAM, or G-code with holes cut before outlines, plus an animated toolpath preview and a one-page printable impact report.
  • Your own parts. Import SVG or DXF, including the BLOCK/INSERT-style DXF that pattern CAD exports.
  • FFT radar, interlock highlights, live telemetry, a convergence chart, and a scale to your factory panel that projects yearly material, scrap, CO2e and cost from your own assumptions.

How we built it

Engine: C++20, no dependencies. Each candidate placement must answer "where does this part fit?" for every position on the roll. We rasterise the roll \(S\) and each rotated part \(P\), and a hand-written Radix-2 2D real FFT computes the cross-correlation

$$C = \mathcal{F}^{-1}\left(\mathcal{F}(S)\cdot\overline{\mathcal{F}(P)}\right)$$

Every cell where \(C = 0\) is a collision-free offset, so one inverse FFT tests all positions at once. Placing a part doesn't need a new forward FFT. For a part placed at offset \((u, v)\) on an \(M \times N\) grid, its spectrum is shifted by a phase factor and added to the roll's spectrum:

$$\hat{S}(k,l) \leftarrow \hat{S}(k,l) + \hat{P}(k,l)\, e^{-2\pi i \left( \frac{k u}{M} + \frac{l v}{N} \right)}$$

That update is \(O(MN)\), with no new FFT. A full correlation takes about 0.2 ms.

The raster only nominates pockets. Each one is re-checked on exact 64-bit vector geometry (winding-number containment, segment-distance clearance, holes), and the part slides along \(-x\) and \(\pm y\) until it touches its neighbours at exactly the kerf. On top of that, simulated annealing runs four parallel chains over placement order and rotation, with swap, rotation-flip, block-shift, 2-opt, critical-piece and jostle moves, and accepts a worse layout with probability \(e^{-\Delta E/T}\). It finishes with exact compaction and a pass that re-seats the parts that set the roll length.

Fabric flaws are obstacles inside the engine: their rasters are on the FFT sheet before any part is placed, and the vector checks, compaction and the baseline all treat them as fixed neighbours.

Measuring the impact. Every run is scored against the baseline on the same parts, roll, kerf and rotation rules: $$\eta = \frac{A}{W \cdot L}, \qquad \Delta M = \frac{\Delta A \cdot \text{GSM}}{1000}$$

where \(A\) is the total true area of the parts, \(W\) the roll width, \(L\) the roll length used, and \(\Delta M\) the scrap mass prevented in kg, with its embodied carbon in kg CO2e.

Verification. A separate checker that shares no code with the engine (pure Python on the server, TypeScript in the browser) rebuilds every part from the raw outlines and measures every close pair and every flaw. A saving only counts if the layout can actually be cut.

Stack. pybind11 bridges the engine to FastAPI, releasing the GIL so WebSocket frames keep streaming during a solve. Run history is stored in PostgreSQL through SQLAlchemy, with SQLite as a fallback. The studio is React + TypeScript + Vite + Tailwind with a hand-written Canvas renderer that tweens every part between frames. The same C++ source also compiles to a 175 KB WebAssembly module in a Web Worker, which powers the live demo with no server at all. One Docker image builds the engine, gates on its test bench, builds the studio and serves it all. GitHub Actions builds that image on every push, drives it end to end, and publishes the live demo.

Challenges we ran into

  • The raster is never quite right. Grid cells blur edges, and FFT correlation is circular, so shapes wrap around. We let the FFT propose and exact geometry decide, and added 2 microns of slack so layouts stay valid after coordinates are rounded for export.
  • Streaming without freezing. A long C++ solve inside a Python web server blocks everything. Releasing the GIL and handing frames back through a thread-safe queue fixed it.
  • No C++20 compiler on the dev machine. We built through the ziglang toolchain installed by pip, which also gave us the WebAssembly build from the same source.
  • Keeping the baseline honest. It would be easy to beat a weak baseline. Ours is the best of nine first-fit-decreasing variants under the same rules, and we say plainly that commercial marker software will do better than it.
  • Flaws as first-class obstacles. The placer caches the roll's spectrum after each placement to make annealing fast. Flaws had to live underneath those checkpoints rather than be checked afterwards.
  • A feature we cut. We built multi-size markers (several graded sizes in one lay) and measured them. Utilization stayed at about 76.7% while solve time grew from 1.5 s to 29 s, so we removed the feature instead of shipping it.

Accomplishments that we're proud of

  • +16 to +17 points of utilization on garment and metal workloads in under two seconds, with zero overlaps confirmed by an independent checker.
  • One C++ codebase that runs natively behind an API and as WebAssembly in a browser tab.
  • Outputs a factory can actually use: DXF, G-code, SVG and a printable report, not just a picture.

What we learned

  • The FFT is the right tool for where could it go? and exact geometry is the right tool for is it really clear?. Using both beat either alone.
  • Measuring before shipping saves you from your own good ideas (see multi-size markers).
  • For a sustainability claim to be believable, the baseline, the formulas and the verification have to be visible, not just the headline number.

What's next

  • Test on production markers from a partner cutting room, against the tool they use today.
  • A windowed FFT that only scans the active end of the roll, so large multi-size markers stay fast.
  • No-fit-polygon refinement and common-line cutting for the final layout.
  • Flaw maps read from roll-inspection cameras, and remnant reuse, so one job's offcuts become the next job's stock.
  • Post-processors for specific cutters and laser controllers.

Built With

Share this project:

Updates

Submission history