IFClite TypeScript API
    Preparing search index...

    Class Contours2D

    A set of closed 2D rings, grouped into disjoint shapes.

    Rings carry no duplicated closing vertex (connect the last point back to the first). Winding is meaningful: a counter-clockwise ring covers area, a clockwise one removes it, so an outer boundary and its holes are distinguishable without any extra tagging — the property meshOutline2d's flattened contour list relies on too.

    Index
    • Build a contour set from flat coordinates plus per-ring vertex counts.

      coords is [x0, y0, x1, y1, …] with every ring concatenated in order; ringLengths[i] is the VERTEX count (not the float count) of ring i. Throws when the counts do not add up to coords.length / 2.

      Shape grouping is a property of boolean results: a set built here is an unstructured ring soup, so shapeCount reports 0 until it has been through an operation (resolve2d alone is enough). Degenerate rings (under 3 vertices, non-finite, or exactly collinear) are dropped at construction, so isEmpty/bounds() report the same rings a later boolean would keep rather than exposing an unsanitised soup.

      Parameters

      • coords: Float64Array
      • ring_lengths: Uint32Array

      Returns Contours2D

    isEmpty: boolean

    True when the set holds no rings. Degenerate rings are dropped at construction and never emitted by an operation, so this also means the set covers no area.

    ringCount: number

    Total number of boundary rings across every shape.

    shapeCount: number

    Number of disjoint shapes, or 0 for a set that has not been through an operation yet (see the constructor).

    • Returns void

    • Axis-aligned bounds as [minX, minY, maxX, maxY], or undefined when empty. Cheap enough to gate the boolean itself: an accumulated occluder whose bounds miss the next element needs no difference at all.

      Returns Float64Array<ArrayBufferLike> | undefined

    • Every ring's coordinates concatenated. Paired with ringLengths() this reconstructs the set through the constructor, and reads a whole result back in one boundary crossing instead of one per ring. It round-trips the constructor's sanitised rings — degenerate rings and explicit closing vertices are dropped at construction, so those are not echoed back.

      Returns Float64Array

    • Returns void

    • Ring index as a flat [x0, y0, x1, y1, …] array, or undefined when out of range.

      Parameters

      • index: number

      Returns Float64Array<ArrayBufferLike> | undefined

    • Vertex count of each ring, in the same order as coords().

      Returns Uint32Array

    • Ring index at which each shape starts. Entry s is shape s's OUTER ring; the rings up to the next entry (or ringCount) are its holes.

      Returns Uint32Array

    • Adopt the rings of a meshOutline2d result, widening its f32 coordinates to the f64 the boolean engine works in.

      The outline's axisMin/axisMax are dropped — they describe the cut axis, which a 2D boolean has no notion of; keep them on the JS side if the caller still needs them for band classification.

      Parameters

      Returns Contours2D