Function validatePolygon

Validates one Polygon2View for polygon topology.

PolygonValidationResult validatePolygon(T)(
  scope Polygon2View!T polygon
) pure nothrow @safe
if (isValidationScalar!T);

Supported scalar types are int, long, float, and double. real is deliberately outside the robust topology domain.

A valid polygon:

- is empty, or has a valid simple exterior ring; - contains only valid simple interior rings; - has no inter-ring crossing or positive-length boundary overlap; - allows at most one geometric contact point between each ring pair; - contains every interior ring within the exterior ring; - contains no nested interior rings; - has connected polygon interior.

A single tangential contact between different rings is permitted when the remaining polygon topology is valid. Several rings may meet at the same geometric point when this does not disconnect the polygon interior.

Ring orientation does not affect validity.

Validation is exact for topology. No epsilon or rounded intersection coordinate is used.

An empty Polygon2View is valid.

The first detected issue is returned deterministically.

This operation may allocate temporary storage while checking connected polygon interior and therefore does not promise @nogc.

Let n be the total number of stored vertices, r the number of rings, and c the number of touching ring pairs. Temporary storage is O(r + c). Because c may be quadratic in the number of rings, auxiliary storage is O(n^2) in the worst case.

Complexity

O(n^2 log n) time in the worst case.