findContoursAdaptive

fun findContoursAdaptive(shapeFunction: ShapeFunction, area: Rectangle, maxDepth: Int): List<ShapeContour>(source)

Finds contours for shapeFunction using an adaptive quadtree and dual contouring, as described in https://www.mattkeeter.com/projects/contours/. Unlike plain marching squares, cells are only subdivided down to maxDepth where the boundary actually needs the extra resolution, and dual vertices are placed on sharp features (corners, thin edges) instead of naive edge midpoints.

Return

a list of ShapeContour instances

Parameters

shapeFunction

the scalar field to contour; negative is "inside"

area

the rectangular area in which shapeFunction is evaluated

maxDepth

the maximum quadtree depth, i.e. the area is split into up to 2^maxDepth cells along each axis