Everyone who prints has G-code whose model is gone. A sliced file still knows the shape of every layer: the outer
wall is the surface, moved in by half a line width. So you can rebuild the part. The catch is the bit between
layers: stack the layers and every slope comes back as a staircase.
The trick in this write-up: a printed layer isn't a brick, it's a sample of the designed surface, taken at the
middle of the layer. Follow each corner of the outline up through the layers, fit a smooth curve through the samples,
and the stairs go. Whatever the print lacks more than 0.3 mm below that smooth surface is real (engraving, text), and
it gets cut back in. On my test print (a curved arm with numbers engraved up it) the depths fell into two clean groups
with nothing between 0.2 and 0.4 mm.
The full paper, with the mistakes, the numbers and a defensive disclosure (so nobody can patent this and charge
hobbyists for it): https://github.com/The-Dorkknight/reading-between-the-layers
The software is Unslice, a plug-in for my Twoo STEP CAD Toolbox: https://github.com/The-Dorkknight/unslice
Only one real print has been through the new method so far, so test files and bug reports are very welcome.
The paper
title: "Reading Between the Layers"
subtitle: "Getting a smooth, editable CAD solid back out of 3D-printer G-code: which steps the printer made, which ones the designer meant, and how to put the engraving back. A hobbyist's field guide and a defensive publication."
author: "Matthew Armstrong (The-Dorkknight)"
date: "Version 1.0, 1 December 2026"
The short version
- The problem: you have the G-code (or a sliced
.gcode.3mf,.ufpor.bgcode) but not the model. Maybe the STL lived on a laptop that died, maybe a friend only sent the print file. You want a STEP: a CAD solid you can open in FreeCAD or Fusion and change, not a pile of triangles. - What a sliced file still knows: more than you'd think. Every layer's outer wall is the part's surface, moved in by half a line width. Holes, line widths, which moves are support and which are part: it's all there, labelled.
- What it has lost: everything between two layers. The printer only knows the shape at one height per layer, so a sloped face comes back as a staircase unless you are careful.
- The trick this paper describes: treat each printed layer as a sample of the designed surface (the slicer cut it through the middle of the layer), not as a brick. Follow each corner of the outline up through the layers, fit a smooth curve through the samples, and the stairs disappear. Anything the print lacks more than 0.3 mm below that smooth surface is a real feature (engraving, text), and it gets cut back in.
- How well it works: on one real print (the arm above), the result is one valid solid with smooth faces and all 16 engraved numerals back, within 0.54 mm of every printed layer, in about 2 minutes. On made-up test parts the simpler routes land within 0.01 % of the true volume. Only one real file has been through the new method. Section 8 is a test plan.
- Why a paper: it's a defensive publication. Section 9 writes the methods down, with variations, and dedicates them to the public, so that they are prior art and nobody can easily patent them and charge hobbyists for them later.
1. Why this exists
Ask around any 3D printing group and you'll find the same folder on everyone's computer: G-code files whose models
are gone. The STL was on the old laptop, or on a USB stick, or came from a site that's since vanished. The print file
survived because it was on the printer's SD card.
A G-code file isn't useless. It's a complete description of the part, just written for a printer instead of a person:
"go here, squeeze this much plastic, go there". Turning it back into a mesh (an STL) has been done before, several
times (section 3). Turning it back into something a CAD program can edit is harder, because CAD wants faces:
"this is a flat side, this is a cylinder, this is a smooth curve", not "here are 90,000 triangles".
Unslice is a plug-in for my Twoo STEP CAD Toolbox (a free STL-to-STEP converter) that does that job. It started as
"how hard can it be?" on 29 November 2026. It turned out to be harder than that on exactly one kind of part: a
smooth slope with writing on it. Which is, of course, the test file I printed.
2. What a sliced file still knows (and what it doesn't)
A slicer cuts the model into horizontal layers and, for each layer, plans walls, infill and the rest. Unslice reads
that plan back.
| What | Where it is in the file | Used for |
|---|---|---|
| Cross-sections | every layer | the shape |
| The surface | the outer wall loops: the model's edge moved in by half a line width | the exact outline |
| Holes | an outer-wall loop inside another one (the even-odd rule) | holes |
| Line width | ;WIDTH: comments, or worked out from the plastic pushed (below) | growing the walls back out |
| What each move is | ;TYPE: (Cura, Prusa, Orca), ; FEATURE: (Bambu) | leaving out support, skirt, brim, purge towers |
| Objects | ;MESH:, ; printing object, Klipper's EXCLUDE_OBJECT lines | one body per object |
| Layer height | the layer-change comments, or the Z moves | slab heights |
| Size tweaks | the settings block the slicer writes at the end | undoing them (section 4.3) |
Line width from the plastic used. Cura doesn't write widths. But a line's cross-section is the filament pushed
divided by its length, and a flattened bead is close to a rectangle with round ends, so the width is
w = A/h + h(1 − π/4) (the bead model PrusaSlicer documents). On the test parts it gives 0.420 mm for 0.42 mm lines.
What is lost:
- Everything between two layers. Each layer is the model cut at one height. CuraEngine cuts it "through the middle of each layer's span, by default" [1]. A 0.2 mm layer from Z 15.0 to 15.2 tells you exactly what the model looked like at Z 15.1, and nothing about Z 15.05.
- What the slicer changed on purpose: elephant-foot compensation, hole and contour compensation, fuzzy skin.
- Anything finer than a line width across, which the slicer couldn't print anyway.
3. What already exists
This is a hobbyist's search, not a professional one, and not legal advice. G-code to model has been studied
from three directions: security ("could someone steal a design from the print file?"), simulation ("what does the
printed part really look like, beads and all?") and plain recovery.
| What | What it does | How Unslice differs |
|---|---|---|
| Tsoutsos, Gamil, Maniatakos (NYU) [2] | A compiler that reverse-engineers G-code toolpaths into a close approximation of the original 3D object, for checking outsourced prints | Mesh output for validation; Unslice aims at an editable CAD solid |
| Tel Aviv University CGL student project [3] | Samples a point cloud along the toolpath and rebuilds the model with alpha shapes | Mesh; no surfaces, no features |
| Kiński, Technical Sciences (UWM) [4] | Converts G-code for visualisation; tries Poisson surface reconstruction to get the geometry back | Mesh |
| "From GCode to STL", extrusion simulation as a web service [5] | Simulates extrusion to a point cloud, then an STL; no holes or cavities | Mesh; Unslice keeps holes |
| Bacciaglia et al., Materials Today: Proceedings 2022 [6] | Sweeps a nozzle-shaped profile along every extrusion path in FreeCAD, producing a STEP of the printed geometry (beads, infill, skin) for stress analysis | Rebuilds the beads, not the designed shape; slow (a 100-line dog-bone took about 62,000 s) |
| Giardini, Quarto, Pellegrini, 2025 [7] | Reconstructs the sliced geometry from G-code into a fine STL, for quality control and comparison | Mesh |
| Staircase-aware smoothing (Mönch, Adler, Preim, 2010) [8] | Finds the staircase artefacts in a mesh built from medical image slices and smooths only those, keeping real features | The closest idea. It works on a finished mesh. Unslice works on the slices themselves and knows which height each one was taken at |
| Reconstruction from planar cross-sections (decades of medical imaging; e.g. OReX, 2023) [9] | Builds a surface between contours on parallel slices | Usually meshes; recent methods use neural networks (far too heavy for an old laptop) |
| Slicer previews and G-code viewers | Draw the toolpath | A picture, not a model |
The gap Unslice fills is not a new algorithm. It's a chain of plain, checkable steps that turns layer outlines
into a CAD solid with real faces, and tells the difference between a step the printer made and a step the
designer drew. Section 9 writes those steps down as prior art.
A word on whose files these are. Unslice is for your own prints, or prints whose designer lets you modify them.
Recovering a model from a print file doesn't change its licence.
4. The method, in enough detail to rebuild it
4.1 Reading the file
- Containers: a Bambu/Orca
.gcode.3mfis a zip withMetadata/plate_N.gcodeinside; a Cura.ufpis a zip with/3D/model.gcode; a Prusa.bgcodeis a block format (file headerGCDE, blocks that may be deflate or heatshrink compressed and MeatPack encoded), decoded in plain Python from the published specification. - Heights from the slicer's own layer-change comments, not by grouping moves by Z. Scarf seams (OrcaSlicer, PrusaSlicer) ramp the start of each outer wall up from the layer below; grouping by Z chained every layer into one and a 10 mm block came back 0.2 mm tall.
- A purge line is not the first layer. A purge line printed at Z 0.3 before a first layer at Z 0.2 made the next layer look 0.1 mm tall, so its worked-out line width doubled. Start code and support-only layers are dropped before heights are worked out, and any layer whose lines come out over 1.35 times the print's usual width is scaled back.
4.2 One layer's outline
- With labels: take the outer-wall loops, join them end to end where the slicer split them (PrusaSlicer splits at overhangs, every slicer stops a loop just short of its start), fill them by the even-odd rule (a loop inside a loop is a hole), and grow every wall by half its width with mitred corners, the way the slicer shrank it.
- Without labels: draw every extrusion as a line as wide as it was printed, on a fine grid (4 x 4 sub-pixels per cell, so each cell knows how much of it is covered), and fill small enclosed gaps as infill. Skirts and purge lines are found as islands that no layer within two above or below touches: a real part always rests on, or carries, its neighbours.
4.3 Undoing the slicer's size tweaks
Slicers write their settings into the file. Unslice reads the ones that change the size (xy_hole_compensation,
xy_contour_compensation in Orca and Bambu Studio, xy_size_compensation and elefant_foot_compensation in
PrusaSlicer, xy_offset, xy_offset_layer_0 and hole_xy_offset in Cura) and grows or shrinks the outlines back,
holes and outsides separately, the first layer on its own. The part comes back at the size it was designed, not
the size it was printed for.
4.4 The layers route: slabs and lofts
The obvious way to make a solid from layers, a prism per layer fused into a stack, works, and it's what "keep" does.
It gives a staircase with thousands of faces. Most layers don't need it:
- Runs of layers with the same outline (average edge movement under 0.05 mm) become one extruded slab. A 30 x 20 x 10 mm block with a hole is two slabs: 7 faces, the hole a true cylinder.
- Runs whose outline changes smoothly (a cone, a chamfer, a dome) become a loft: a skin stretched through a few sampled layers. Which layers: the fewest such that every other layer's size and centre is within tolerance of the straight line between its neighbours (Douglas-Peucker, run in height). A straight cone needs two.
- Outlines are fitted with lines and arcs by the toolbox's own sketch fitter, so a round hole is a cylinder. If a fitted outline's area misses the traced area by more than 0.3 %, it's redone with straight segments, because arcs round off the sharp corners of embossed text.
Then the hard-won rules, every one of which was found by something going wrong (section 6):
- A loft must be checked where it was not built. A loft through 24 sampled layers fits those 24 by construction. The engraving lives in the layers in between. So every loft is cut at the middle of every printed layer it spans and compared with that layer's outline.
- Check every join by volume, both ways. OpenCASCADE will happily report a fused solid as "valid" after it has swallowed most of the stack. After each join, the new volume must be the old volume plus the piece, within 2 %. Too much is as bad as too little: a skin that crosses itself measures wrong and wrecks the next join.
- Undo, don't give up. If a later join fails, the most recent loft is the likeliest culprit: it's undone, rebuilt the other way (smooth, then ruled), and if that fails too, its layers are stacked as printed.
- Ruled before smooth for awkward outlines. A ruled skin (straight lines between sections) with its sections matched up joined about 14 times faster than a smooth one, and can't overshoot between sections.
4.5 Engraving: keep it, or fill it
Text cut into a sloped face changes the outline of every layer it crosses, so a run of layers that should be one
smooth loft looks like a run of different outlines. Two simple answers came first:
- keep: every layer as printed. Exact, crisp numbers, 5,721 faces, a 21.5 MB STEP, about 70 s on the arm.
- fill: like the toolbox's "Texture = peaks" fills the valleys of a grip pattern. Each layer is replaced by its carrier: the smallest rectangle around it when the outline fills more than 97 % of it, otherwise its convex hull with short chamfers extended back to sharp corners. Notches up to 1.2 mm deep are filled, measured from the notch's own opening (measured to the nearest edge, a 3 mm slot near a corner looked shallow). Deeper notches are cut back out of the carrier: they're part of the shape. Smooth and lighter (1,002 faces, 13.1 MB, about 40 s), but the engraving is gone, and where a loft still failed its check, those layers stayed stepped.
4.6 Step recognition
This is the part the title is about.
The idea in one sentence: a printed outline is a sample of the designed surface, taken at the middle of the
layer, and the staircase is only the way a stack of prisms draws those samples.
Step by step:
- Carriers. Each layer's outline is replaced by its carrier (section 4.5). For the arm it's a rectangle in 230 of 231 layers.
- Runs. Neighbouring layers are grouped while their carriers are one convex outline without holes, with the same number of corners, and move by less than 0.6 mm on average (and 1.5 mm at most) from one layer to the next. The first layer is left out (it's often squashed wider). A run needs at least 8 layers. Anything else is built as printed, exactly as "keep" does.
- Columns. Corner k of one layer is matched to corner k of the next (the rotation of the corner list that moves them least). A round carrier with too many corners to match is resampled at 48 points evenly round it, starting from the point nearest the previous layer's start.
- Fit. Each column's X and Y are fitted against mid-layer height with a smoothing spline (SciPy's
UnivariateSpline, cubic), allowed to smooth away about 0.04 mm of noise per sample. - Real steps split the run. If any sample is more than 0.25 mm from its fitted curve, the curve couldn't follow it: that's a step the designer drew (a ledge, a boss), not drift. The run is split at the worst sample and each half is fitted again. Halves under 8 layers are built as printed.
- Leave alone what doesn't move. If no column moves more than 0.1 mm over the whole run, it's a straight prism, and a plain extruded slab is exact and cheaper.
Why not a fixed threshold per layer? Because the slope changes. On the arm, the outline moves 0.035 mm per layer
near the foot and 0.35 mm near the top, where the arm leans right over. An engraving edge jumps about 0.55 mm.
Building it. The fitted curves are evaluated every 1 mm of height, and each set of points becomes a section:
a straight-sided polygon when the carrier has corners (so each side of the run is one face), a closed spline through
the 48 points when it's round. The points already correspond, so no matching is needed. OpenCASCADE builds the
smooth skin through them (BRepOffsetAPI_ThruSections, not ruled). For the arm's first run, 138 layers become
29 sections and one solid of 6 faces in 0.01 s. Sections 2 mm apart let the smooth skin overshoot by 2.4 mm
between them; 1 mm apart, it stays within 0.012 mm of the fit. The skin is then checked at the middle of every
printed layer, as in 4.4, and if it fails, that run falls back to its printed layers.
4.7 Finding the engraving
With the smooth surface known, a feature is simply what the printed layer lacks below it. Two details make
that work in practice:
- Look deep first, then grow back. The fit sits a few hundredths of a millimetre off the print all the way round, so "fitted outline minus printed outline" is a thin ring with the numerals hanging off it: one piece, measured as 0 mm deep. Instead, Unslice looks for what's missing more than 0.15 mm below the surface (only depth is tested, so narrow strokes survive) and grows each piece back up to the surface.
- Let the depths choose the cut-off. Measured on the arm, the notches fall into two groups with almost nothing between them.
Pieces deeper than the cut-off are grouped over neighbouring layers (two pieces belong together if they're in
adjacent layers and touch), and each group is one feature: on the arm, 16 of them (each digit of each number).
4.8 Putting the engraving back
The cheapest correct cut is the one the designer most likely made: a flat sketch on the face, cut straight in along
the face's normal (an "extrude cut" in CAD terms). Unslice rebuilds that sketch from the layers:
- The plane. The points where each layer's notch opens onto the surface (its mouth) lie on the face. A plane is fitted through them (singular value decomposition), pointing outwards.
- The sketch. For each layer, each separate part of the stroke becomes a strip on that plane: its width is where the stroke runs along the face, its height is the layer's own height, placed on the plane by height alone (placing each strip by its own position let the face's sideways drift pull the strips apart: sketches in 12 to 49 pieces). The strips are merged and tidied (simplified to 0.06 mm).
- The cut is the sketch moved 0.35 mm out from the face, so it opens cleanly, and pushed in by the measured depth times the horizontal part of the normal (the notch was measured across the layer, the cut runs along the normal). The outer part overlaps the inner part by 0.02 mm. Without that, they met along a hairline, came apart, and the bigger (outside) piece was kept: a cut that never reached the floor.
Bands, because faces curve. One plane for a whole 6 mm numeral on the arm's face (radius about 11 mm) sits up to
0.4 mm off the surface at the numeral's ends, so the flat floor goes that much too deep. Each numeral is therefore
cut in bands 1.5 mm tall, each with its own plane (fitted to its own mouths plus one layer either side), and the
bands are fused into one tool. Neighbouring bands reach 0.05 mm into each other so no sliver is left between them.
If that cut doesn't match the print (checked on the layers it crosses and 0.6 mm either side, because a cut across
a slope reaches past its own layers), the feature is cut as the print has it: one prism per layer, from that layer's
notch, reaching 0.35 mm out of the face. That's always right but slower (0.1 to 0.3 s per layer against the smooth
face) and leaves stepped walls inside the numeral. A feature belongs to the fitted run it lies in, and if that run
fell back to printed layers, the feature is already there and isn't cut again.
4.9 Checking the result
Nothing is called done until it's measured:
- Every printed layer: the finished solid is cut at the middle of every layer and compared with that layer's outline (Hausdorff distance, the worst gap between the two outlines). Engraving that wasn't cut back is added to the expected outline first, so the check knows what was promised.
- The limit: two layer heights normally. In "recognise" it's three layer heights (0.6 mm at 0.2 mm layers), for an honest reason. Where an engraved edge runs nearly level (the top of a "0", a crossbar), a cut across a sloped face sits up to one layer higher or lower than the slicer's sample. In a horizontal cut through the solid that shows up as a large sideways gap, even though the surface is only about 0.1 mm off. Lofts are still held to two layer heights.
- Volume against what the layers hold, and a valid closed solid after writing the STEP and reading it back. The last tidy-up (merging faces that share a surface) sometimes breaks a solid after cuts across smooth faces; the less tidied versions are tried in turn and the first valid one is kept.
- If the layers route fails anyway, the old safe route runs: a closed mesh from the layers (marching tetrahedra on the coverage grid) handed to the toolbox's own mesh-to-STEP fitter. Slow, faceted, but always a result.
4.10 Slow computers
The target is a 7th-generation Core i3 laptop. It may take five times longer than a modern PC; it must not crash
or sit silent.
- The CAD kernel runs in its own process. OpenCASCADE can hold Python's lock for minutes, so a progress thread in the same process would never get to speak. The parent process watches; no output for 15 minutes stops it.
- A "still working" line every few seconds: what, how far, how long, memory. The estimate is timed from the start of the current step, and none is given before 2 % of it is done (it once said "about 436 min left" after one layer, because it had counted two minutes of earlier work).
- Memory is budgeted from what's free before the heavy work starts, and the grid coarsened if needed.
- Supports, skirts, brims and purge lines are split off as separate bodies (their labels say what they are), never fused to the part.
5. A tour of the app
Unslice is a tab in Twoo STEP CAD Toolbox: drop a sliced file on it, pick what to keep, press go. The engraving
drop-down is where the three modes live: keep (stepped), fill (smooth), recognise (smooth + text).
6. The mistakes, for free
Every one of these happened on the way from "how hard can it be?" to the result above. The four screenshots are the
real toolbox preview, in order.
| What went wrong | What it looked like | The fix |
|---|---|---|
| Scarf seams | A 10 mm block came back 0.2 mm tall | Layer heights from the slicer's own layer-change comments (4.1) |
| A purge line at Z 0.3 | The second layer's lines worked out at 0.776 mm wide; the part bulged 0.2 mm | Drop start code first; scale back over-wide layers (4.1) |
| The saved STL "pinched" | A T-shaped part reloaded as 3,720 pieces: vertices exactly on grid points merged | Surface level ½ − 1/64; every mesh checked by a round trip through STL |
| Lofts through traced outlines | 42 % under to 3 % over their planned volume; the next fuse swallowed the stack (1,783 mm³ became 60) | Volume checked both ways at every join; ruled lofts; undo and rebuild (4.4) |
| "Valid" is not "right" | OpenCASCADE's checker passed solids that had lost most of their volume | Never trust validity alone; measure volume |
| Cleaning the shape after every join | A crash (segmentation fault) in the shape fixer | Clean once, at the end |
| Straight-segment fallback | Holes came out inside-out (8.556 mm³ instead of 8.043) | Run the shape fixer on that path too |
| Lofts checked only where built | The tangled arm above | Check at every printed layer (4.4) |
| Fill measured notch depth to the nearest edge | A 3 mm slot near a corner looked shallow and got filled | Measure from the notch's own opening (4.5) |
| The fitted outline's thin margin | All 16 numerals measured 0 mm deep: one ring | Look 0.15 mm deep, then grow back (4.7) |
| A hairline join in the cut tool | Cuts that never reached the floor | Overlap 0.02 mm (4.8) |
| One plane per numeral | Floors 0.5 mm too deep at the ends | Bands (4.8) |
| Strips placed by their own position | Sketches in 12 to 49 pieces | Place by height on the plane (4.8) |
| Two strokes in one layer measured as one | A "1" cut far too wide | One strip per stroke part (4.8) |
| A follow-the-surface cut (sketch minus the part offset inwards) | 5 s per offset and 0.59 mm off: worse | Dropped |
| Shifting bands by the stroke's tilt | Better low down, worse up high, broke the final check | Reverted; still open |
| Merging same-surface faces at the end | An invalid solid after some cuts | Fall back to less tidy versions (4.9) |
| The progress estimate | "About 436 min left" | Time each step on its own (4.10) |
7. The numbers
Made-up parts with known answers (sliced by a test script in each slicer's dialect; layers route; 2-core cloud
Linux machine):
| Part | True volume | STEP volume | STEP faces | Time |
|---|---|---|---|---|
| Block 30 x 20 x 10 mm with an 8 mm hole (Cura dialect) | 5,497.4 mm³ | 5,497.3 (−0.00 %) | 7 (6 plane, 1 cylinder) | 3 s |
| Same, hole written as G2/G3 arcs (Bambu dialect) | 5,497.4 mm³ | 5,497.3 (−0.00 %) | 7 | 3 s |
| Same, G-code with no labels at all | 5,497.4 mm³ | 5,468.2 (−0.53 %) | 23 | 5 s |
| T with overhangs and support (Bambu dialect) | 1,800.0 mm³ | 1,800.0 (+0.00 %) | 10 (all plane) | 2 s |
| Cone R12 to R6, 15 mm tall (Prusa dialect) | 3,958.4 mm³ | 3,954.9 (−0.09 %) | 3 (2 plane, 1 smooth) | 5 s |
One real print: the Cura overhang test (244 layers, 20.6 x 47.8 x 48.8 mm, numerals 10 to 70 engraved up the
curved face).
| Mode | Faces | Worst gap to the printed layers | STEP | Time | Looks |
|---|---|---|---|---|---|
| Mesh fitter (before the layers route worked) | 295 flat, 92 round, 73,593 facet triangles | not measured | not measured | 4 min 24 s (toolbox report) | faceted |
| keep | 5,721 | 0.097 mm | 21.5 MB | ~70 s | stepped, crisp numbers |
| fill | 1,002 | not recorded | 13.1 MB | ~40 s | smooth where lofts held, no numbers |
| recognise | 3,793 | 0.54 mm | 16.9 MB | ~2 min | smooth, all 16 numerals back (12 as tangent bands, 4 as printed layers) |
Times are from a 2-core cloud machine (the mesh-fitter time is from the author's own laptop). None was measured on a
7th-gen i3.
8. A test plan, for anyone with a printer
If you have sliced files lying around, please try these and report back (an issue or discussion on the repository,
with screenshots):
- Your own lost model. Slice any part you still have the STL for, run Unslice on the G-code, and compare the STEP with the original in FreeCAD or Fusion (sizes, holes, volume).
- Engraving and embossing. A part with text on a sloped or curved face: try keep, fill and recognise. Do the numbers come back? Do raised letters (the mirror case, not built yet) survive?
- Other slicers. The real-file results above are from Cura. PrusaSlicer, OrcaSlicer and Bambu Studio files (including
.bgcodeand.gcode.3mf) have only been through test files written to imitate them. - Real steps. A stepped part (stairs, a boss on a slope): does recognise keep the steps that were designed?
- A slow PC. On a 7th-gen i3 or similar: does it finish, and does the "still working" line tell the truth?
9. Defensive disclosure
This section is written to be read as prior art. It describes methods implemented in Unslice (versions 0.1.0-wip to
0.2.7-wip, source published at the repository below) and variations of them. All of them are dedicated to the
public. Anyone may use them, free, for any purpose. The purpose of publishing them is to make it hard for anyone to
patent them and restrict their use. Where a number is given, any other value that does the same job is also disclosed.
Where "G-code" is written, any layered machine instruction format is meant (text or binary G-code, zipped project
files, layer images). Not legal advice.
D1. The designed shape, not the printed beads, from labelled outer walls. For each layer of a sliced file, the
loops of moves labelled as outer wall are joined end to end (closing gaps up to a fraction of a line width), filled by
the even-odd rule, and grown outward by half of each line's width with mitred corners, giving the designed outline of
that layer. The line width is read from width comments or worked out from the filament pushed per unit length using
a bead model (rectangle with rounded ends, w = A/h + h(1 − π/4), or any other bead model). Layer heights are taken
from the slicer's layer-change comments, each layer at the height most of its line was printed at, so ramped seams,
spiral (vase) mode and per-object printing don't merge layers. Variations: using inner walls offset by the known
number of perimeters; using skin or infill extents as a fallback.
D2. Unlabelled files. Every extrusion is drawn as a line of its printed width onto a grid with sub-cell coverage
(any antialiasing method); enclosed gaps below an area are filled as infill; islands not touched by any island within
N layers above or below (2, or any other N) are treated as skirts, purge lines or wipes and removed.
D3. Undoing compensation from embedded settings. The slicer's settings block in the file is read for any setting
that changes printed size (hole compensation, contour compensation, overall XY size compensation, first-layer
elephant-foot compensation, and the equivalents under any name), and the layer outlines are offset by the opposite
amount, holes and outer boundaries separately, first layer(s) separately, so the rebuilt part has its designed size.
D4. Slabs and lofts from layer outlines, checked everywhere. Consecutive layers whose outlines differ by less than
a tolerance become one extruded solid; runs whose single outline changes smoothly become a loft through sections chosen
by a Douglas-Peucker test in height on an outline signature (area, centre, or any other); each loft is checked against
the outline of every layer it spans, not only the sections it was built through; every boolean join is checked by
volume (result equal to the sum within a tolerance, both too much and too little rejected); a failing join undoes the
most recent loft, which is rebuilt another way (smooth, ruled, or as its printed layers stacked), going back further if
needed. Outlines are fitted with lines and arcs, and replaced by straight segments when the fitted area differs from
the traced area by more than a threshold.
D5. Checking a rebuilt solid against the layers themselves. The solid is sectioned at the middle of each printed
layer and compared with that layer's outline (Hausdorff distance, mean edge distance, or area difference), and its
volume with the sum of layer area times height; a mesh (STL) is produced by tessellating the accepted solid, falling
back to a mesh built from the layers only when the solid fails.
D6. Support and adhesion as separate bodies. Moves labelled as support, support interface, skirt, brim, raft,
purge or prime tower are rebuilt as separate solids or meshes in the same coordinates as the part and never fused
with it, so they can be deleted or kept in a CAD program or slicer.
D7. Filling shallow features with a carrier outline. Each layer outline is replaced by a carrier: its minimum-area
enclosing rectangle when the outline's convex hull fills more than a share of it (97 %, or any other), otherwise its
convex hull with short edges extended back to sharp corners. Notches between carrier and outline are filled when their
depth, measured from the notch's own opening on the carrier, is at most a limit (1.2 mm, or any other); deeper notches
are removed from the carrier. Lofting is then done on carriers whose corner counts match. Analogous to filling the
valleys of a surface texture up to its peaks.
D8. Step recognition: layers as samples of a surface. The outline of each printed layer is treated as a sample of
the designed surface at the height at which the slicer cut it (mid-layer, or the bottom or top of the layer for
"inclusive" or "exclusive" slicing, or any known height). Carrier outlines of neighbouring layers are put in point
correspondence (corners matched by the rotation that moves them least; or points resampled evenly by arc length from
the point nearest the previous layer's start; or any other correspondence), each corresponding point's coordinates
are fitted against sample height with a smoothing function (smoothing spline, polynomial, any regression), and the
fitted surface replaces the stepped stack. A run is split where a sample departs from its fit by more than a
tolerance (0.25 mm, or any multiple of the layer height or line width), so designed steps are kept and only drift is
smoothed. Runs that don't move are left as extrusions. The first layer may be excluded.
D9. A smooth solid from fitted sections. The fitted surface is evaluated at heig...














