Two ways to bill the same job
Ask two contractors to find all the property boundaries in a county. The first walks every square meter of the county, once per boundary type. The second walks only along the boundaries themselves. Their prices differ by orders of magnitude when the county is mostly empty ranchland — and that’s most counties, and most scalar fields.
Marching squares is the first contractor: it inspects all n² cells for each of L iso-levels — O(n²L) — regardless of how much geometry exists. Doubling grid resolution quadruples cost even if the picture barely changes.
An output-sensitive algorithm is the second contractor: after locating where curves begin, it traces them, doing work proportional to the geometry produced — O(output). A fog-of-war grid that’s 95% empty, a weather field with one storm cell, a terrain tile that’s mostly plateau: all nearly free.
Where the advantage shows up
- Sparse fields: at identical grid size, a field with few contours costs far less than a dense one — the sparser the field, the bigger the win.
- Many levels: each added level in marching squares is another full grid pass; in a sweep it costs only its own geometry. That is why the gap to per-level tools widens on real terrain contoured every 20 m — see the DEM benchmarks.
- High resolution: grids grow as n², but the contours in them grow only as ~n. Output-sensitivity converts that gap into speed.
- Frame budgets: cost tracks visual complexity, so a game or dashboard can bound contouring time by bounding what’s on screen — not by capping grid resolution.
The subtlety: you still have to find the curves
The hard part of output-sensitivity is knowing where geometry starts without scanning everything for every level. Naive “seed point” schemes do a full prepass — which, on real workloads, can cost more than the extraction itself. The sweep in isosweep resolves this with a single ordered traversal that discovers all levels’ crossings as it goes, emitting curves already ordered, closed, and nested.