Skip to content

Intermact API Reference / @intermact/core / stitchSegments

Function: stitchSegments()

stitchSegments(segments, eps?): AbsXY[][]

Defined in: packages/core/src/pcg/marching-squares.ts:145

Stitch loose iso-segments into connected polylines by endpoint matching. Greedy and deterministic; nearly-coincident endpoints are merged within eps.

Each seed segment is grown in both directions (appending at the tail and prepending at the head), so a polyline whose seed sits in the middle of a long iso-curve is recovered as a single line instead of being split. When the two ends meet within eps the loop is detected as closed and the duplicate endpoint is retained so callers can stroke it as a closed ring. Every input segment is consumed by exactly one output polyline.

Parameters

segments

readonly IsoSegment[]

eps?

number = 1e-4

Returns

AbsXY[][]

Intermact v1.0 — 文档覆盖 Phase-1 / Phase-2 / Phase-3(全阶段)