import { type Ring, type Vec2 } from '../../source'; /** Distance from p to the segment ab. */ export declare function distanceToSegment(p: Vec2, a: Vec2, b: Vec2): number; /** Two consecutive centreline points closer than this are one point (1 cm; the validator rejects repeats under 1 mm after rounding). */ export declare const REPEATED_POINT_M = 0.01; /** * Drops consecutive points of an open polyline that sit within `epsilon` of the previous kept point, with their * parallel `ys`. The first and last points are the road's nodes, so they always survive: a repeat of the last * point replaces the point before it. Order and every other point are untouched, so the result is deterministic. */ export declare function dropRepeatedPoints(plan: readonly Vec2[], ys: readonly number[], epsilon?: number): { plan: Vec2[]; ys: number[]; }; /** Douglas-Peucker over an open polyline; returns the indices of the kept points (always the first and the last). */ export declare function simplifyOpen(points: readonly Vec2[], tolerance: number, from?: number, to?: number): number[]; /** Douglas-Peucker over a closed ring. The ring is split at its two most distant points so no corner is privileged. */ export declare function simplifyClosed(ring: readonly Vec2[], tolerance: number): Ring; /** Drop consecutive repeats and exactly collinear points, in place of a closed ring. */ export declare function cleanRing(ring: readonly Vec2[], eps?: number): Ring; /** Andrew's monotone chain; returns the hull counter-clockwise from above. */ export declare function convexHull(points: readonly Vec2[]): Ring; export declare function rectRing(minX: number, minZ: number, maxX: number, maxZ: number): Ring; export interface TracedLoops { /** Loops around set cells (foreground on one side), as grid-corner coordinates, outer boundaries. */ outers: Vec2[][]; /** Loops around unset cells fully enclosed by set cells. */ holes: Vec2[][]; } /** * Trace the boundaries of a bitmap (`mask[j * width + i]`, 1 = set) into closed loops of grid-corner points * (corner (i, j) is the top-left of cell (i, j)). Diagonal-only contacts are filled first, so no loop pinches itself and * every loop is simple; the filled cells are returned in `filled`. Straight runs are merged into one edge. */ export declare function traceMask(mask: Uint8Array, width: number, height: number): TracedLoops & { filled: number; }; export interface PolygonWithHoles { ring: Ring; holes: Ring[]; } /** Attach each hole to the smallest outer ring that contains it. Orients outers CCW and holes CW from above. */ export declare function assignHoles(outers: readonly Ring[], holes: readonly Ring[]): { polygons: PolygonWithHoles[]; orphanHoles: number; }; /** A polygon is clean when neither ring crosses or touches itself or another. */ export declare function polygonIsClean(polygon: PolygonWithHoles): boolean;