Skip to content

Smooth Staircases

Merges the shapes on visible layers and turns the one-row steps of their outlines, as raster images produce them, into diagonal edges. Open it from Tools → Boolean Operations → Smooth Staircases. The tool needs the Tools option.

When to Use

  • After importing a bitmap image whose pixels were combined into polygons, to replace the stepped outlines of slanted and curved edges with straight diagonals
  • On any layout drawn on a row grid, such as the output of a scanline or pixel-based process, whose outlines should follow the intended edge instead of the rows

Bitmap import can smooth the staircases itself with its Smooth staircases option. Use this tool for drawings imported without it, for other settings, or for geometry from another source.

Options

OptionDescriptionDefault
Row heightHeight of one row of pixels, in the display units: the distance a concave corner moves along its riser. With rows of unequal height, the tallest
SmoothingOne-row steps only: inside corners with a taller riser stay sharp and pockets keep their floor. All steps and narrow pockets: every riser is smoothed and pockets up to three rows wide lose their closed rowOne-row steps only
RowsHorizontal or Vertical: the direction of the pixel rows, along which the steps runHorizontal
Join shapes touching at a cornerSmooths across corners where two pixels touch diagonally, joining the shapes thereOn
Fill RuleHow overlaps of the shapes being merged are interpreted: Non-zero winding rule or Even-odd rule
Draw generated holes using…Cut-lines in re-entrant polygons, Sliced simple polygons, or Extract holes as polygons
Apply ToAll Visible geometry or only the current SelectionAll Visible

The dialog remembers its settings from one use to the next.

How It Works

  1. The shapes of each layer are merged, as by Merge Overlapping
  2. In the merged outlines, a horizontal edge is a step and a vertical edge a riser (for vertical rows, the other way round)
  3. Every concave corner between a step and a riser moves by one row height along the riser, so a staircase of rows becomes a straight diagonal edge, whatever the width of its steps
  4. The result replaces the original shapes, with holes drawn as chosen

One-row steps only is the setting bitmap import uses. All steps and narrow pockets gives the outline of sampling the material on scanlines one row apart; unlike such sampling, two shapes one row apart stay apart.

Command Line

The SmoothStaircases command of --apply-tool and of ToolApply in command files runs the same tool:

SmoothStaircases(RISE,MAXSTEP,MAXRISER,POCKET,BRIDGE,AXIS,UNION)
ArgumentDescription
RISERow height, in the current units
MAXSTEPLongest step that is smoothed, or none for any length
MAXRISERTallest riser whose concave corners are smoothed, or none for any height. Set it to RISE to keep inside corners with a taller riser sharp
POCKETWidest pocket (a notch, slot or hole) whose floor rises by one row; 0 keeps every floor
BRIDGEtrue joins shapes where two pixels touch diagonally; false keeps them apart
AXISY for horizontal rows, as a raster image is scanned; X for vertical rows
UNIONAuto merges the result again only where smoothing can make shapes touch; Always for vertices off the row grid; Never

The two settings of the dialog are SmoothStaircases(R,none,R,0,true,Y,Auto) (one-row steps only) and SmoothStaircases(R,none,none,3R,true,Y,Auto) (all steps and narrow pockets), with R the row height. The command uses the fill rule and holes mode set before it:

Terminal window
linkcad -i mask.png --input-format Image -o mask.gds --output-format GDSII \
--RasterInScalingValue 0.5 --RasterInScalingValueY 0.5 --RasterInMergeType 2 \
--apply-tool "SetUnits(um);SetHolesMode(Split);SmoothStaircases(0.5,none,0.5,0,true,Y,Auto)" \
--quit --no-save-settings

From Python, the same operation is linkcad.edit.SmoothStaircasesTask; see linkcad.edit.

Technical Notes

  • Shapes on different layers are never merged with each other
  • Smoothing only moves corners along risers; it does not round or simplify edges that are not stepped