vibespatial.kernels.constructive.polygon_intersection

GPU-native element-wise polygon intersection kernel.

Computes element-wise intersection of two equal-length OwnedGeometryArrays containing polygons, returning a device-resident OwnedGeometryArray without any D->H transfer in the hot path.

Algorithm: Sutherland-Hodgman polygon clipping on GPU. - For each pair (left[i], right[i]), clips left’s exterior ring by each

edge of right’s exterior ring.

  • Two-pass count-scatter pattern: pass 1 counts output vertices per pair, prefix sum computes offsets, pass 2 scatters clipped vertices.

  • Degenerate results (empty, point, line) produce empty polygons with validity=False.

ADR-0033: Tier 1 (custom NVRTC kernel) – geometry-specific inner loop

with ring traversal and edge-by-edge clipping.

ADR-0002: CONSTRUCTIVE class – stays fp64 on all devices per policy.

PrecisionPlan wired through for observability only.

ADR-0034: NVRTC precompilation via request_nvrtc_warmup at module scope.

Attributes

Functions

polygon_intersection_sh_eligible_mask(left, right)

Return a device mask for rows admissible to the SH intersection kernel.

polygon_intersection(...)

Element-wise polygon intersection of two OwnedGeometryArrays.

Module Contents

vibespatial.kernels.constructive.polygon_intersection.logger
vibespatial.kernels.constructive.polygon_intersection.polygon_intersection_sh_eligible_mask(left: vibespatial.geometry.owned.OwnedGeometryArray, right: vibespatial.geometry.owned.OwnedGeometryArray)

Return a device mask for rows admissible to the SH intersection kernel.

This is a native row-indirected admissibility carrier: indexed views keep their device family-row mapping, and no host metadata or physical row copy is required before deciding which rows can use Sutherland-Hodgman. The mask is deliberately convex-convex: intersecting a concave simple polygon with a convex clip can require multipart output, which this single-ring SH kernel cannot represent.

vibespatial.kernels.constructive.polygon_intersection.polygon_intersection(left: vibespatial.geometry.owned.OwnedGeometryArray, right: vibespatial.geometry.owned.OwnedGeometryArray, *, dispatch_mode: vibespatial.runtime.ExecutionMode | str = ExecutionMode.AUTO, precision: vibespatial.runtime.precision.PrecisionMode | str = PrecisionMode.AUTO) vibespatial.geometry.owned.OwnedGeometryArray

Element-wise polygon intersection of two OwnedGeometryArrays.

Parameters

left, rightOwnedGeometryArray

Input polygon arrays of equal length.

dispatch_modeExecutionMode or str, default AUTO

Execution mode hint (GPU/CPU/AUTO).

precisionPrecisionMode or str, default AUTO

Precision mode. CONSTRUCTIVE kernels stay fp64 per ADR-0002.

Returns

OwnedGeometryArray

Device-resident result when GPU path is taken; host-resident when CPU fallback is used.