# This file is automatically generated by pyo3_stub_gen
# ruff: noqa: E501, F401, F403, F405
r"""
Collision detection for nesting algorithms.

Provides overlap checks with bounding-box, convex hull, and detailed
polygon intersection, including hierarchical variants for performance.
"""

import collections.abc
import numpy
from raygeo.geo.algo import spatial_grid2d
from raygeo.geo import types
__all__ = [
    "does_any_overlap",
    "does_any_overlap_hierarchical",
    "does_any_overlap_hierarchical_grid",
    "is_contained",
]

def does_any_overlap(candidate: types.Polygon, placed: collections.abc.Sequence[types.Polygon], min_area: float = 1) -> bool:
    r"""
    Check if a candidate polygon overlaps any placed polygon.
    
    :param candidate: Candidate polygon.
    :param placed: List of already-placed polygons.
    :param min_area: Minimum overlap area to consider (in clipper coords).
    :returns: True if any overlap detected.
    :complexity: O(n * m) where n = candidate vertices, m = placed polygon vertices.
    """

def does_any_overlap_hierarchical(candidate_polys: collections.abc.Sequence[numpy.ndarray], candidate_hulls: collections.abc.Sequence[numpy.ndarray], placed_polys_groups: collections.abc.Sequence[collections.abc.Sequence[numpy.ndarray]], placed_hulls_groups: collections.abc.Sequence[collections.abc.Sequence[numpy.ndarray]], min_area: float = 1) -> bool:
    r"""
    Hierarchical overlap: bbox -> hull -> detailed polygon.
    
    :param candidate_polys: Candidate polygons to check.
    :param candidate_hulls: Convex hulls of candidate polygons.
    :param placed_polys_groups: Groups of already-placed polygons.
    :param placed_hulls_groups: Convex hulls of placed groups.
    :param min_area: Minimum overlap area (clipper coords).
    :returns: True if any overlap detected.
    :complexity: O(n * m) with bbox/hull early-exit acceleration.
    """

def does_any_overlap_hierarchical_grid(candidate_polys: collections.abc.Sequence[numpy.ndarray], candidate_hulls: collections.abc.Sequence[numpy.ndarray], placed_polys_groups: collections.abc.Sequence[collections.abc.Sequence[numpy.ndarray]], placed_hulls_groups: collections.abc.Sequence[collections.abc.Sequence[numpy.ndarray]], spatial_grid: spatial_grid2d.SpatialGrid, candidate_bbox: tuple[float, float, float, float], min_area: float = 1) -> bool:
    r"""
    Hierarchical overlap with spatial grid: bbox -> hull -> detailed polygon.
    
    :param candidate_polys: Candidate polygon vertices.
    :param candidate_hulls: Candidate convex hulls.
    :param placed_polys_groups: Groups of already-placed polygon vertices.
    :param placed_hulls_groups: Groups of already-placed convex hulls.
    :param spatial_grid: SpatialGrid for fast neighbor lookup.
    :param candidate_bbox: Bounding box of the candidate.
    :param min_area: Minimum overlap area to consider.
    :returns: ``True`` if any overlap is detected.
    :complexity: O(n * m / k) where k = grid cell density factor.
    """

def is_contained(inner: collections.abc.Sequence[types.Polygon], outer: types.Polygon) -> bool:
    r"""
    Check if inner polygons are fully contained within outer polygon.
    
    :param inner: List of polygons to check.
    :param outer: Outer polygon.
    :returns: True if all inner polygons are inside outer.
    :complexity: O(n * m) where n = inner polygons, m = outer polygon vertices.
    """

