# This file is automatically generated by pyo3_stub_gen
# ruff: noqa: E501, F401, F403, F405
r"""
Pure-geometry fillet operations.

Domain-neutral utilities for creating circular fillet arcs,
appending them to polylines, and trimming to safe spans.

* ``create_fillet_polyline`` — circular arc tangent to a direction.
* ``append_end_fillets`` — fillet both ends of an open polyline.
* ``trim_to_safe_fillet_span`` — longest sub-span whose end fillets avoid obstacles.
* ``get_descending_radius_fillet`` — try fillets at descending radii until one fits.
"""

import collections.abc
__all__ = [
    "append_end_fillets",
    "create_fillet_polyline",
    "fillet_arc_ends",
    "find_safe_sweep_end",
    "get_descending_radius_fillet",
    "trim_to_safe_fillet_span",
    "try_fillet_one_end",
]

def append_end_fillets(polyline: collections.abc.Sequence[tuple[float, float]], radius: float, sweep_angle: float, start_side: float, end_side: float) -> list[tuple[float, float]]:
    r"""
    Append fillet arcs to both ends of an open polyline.
    
    A reversed fillet is added at the start (using *start_side*) and a
    forward fillet at the end (using *end_side*), producing a smooth
    rounded path.
    
    :param polyline: Input open polyline.
    :param radius: Fillet radius.
    :param sweep_angle: Arc sweep angle in radians.
    :param start_side: Offset side for the start fillet (+1 left, -1 right).
    :param end_side: Offset side for the end fillet (+1 left, -1 right).
    :returns: Full polyline with fillets.
    """

def create_fillet_polyline(p: tuple[float, float], dir: tuple[float, float], radius: float, sweep_angle: float, side: float, reverse: bool) -> tuple[tuple[float, float], list[tuple[float, float]]]:
    r"""
    Create a circular fillet arc tangent to *dir* at *p*.
    
    ``side`` selects the offset side (+1 = left of *dir*, -1 = right).
    When ``reverse`` is ``True`` the arc curls back opposite to *dir*.
    
    :param p: Start point (x, y).
    :param dir: Tangent direction vector (dx, dy).
    :param radius: Fillet radius.
    :param sweep_angle: Arc sweep angle in radians.
    :param side: Offset side (+1 left, -1 right).
    :param reverse: Whether the arc is reversed.
    :returns: ``(center, polyline)`` — arc centre and fillet vertices.
    """

def fillet_arc_ends(arc: collections.abc.Sequence[tuple[float, float]], pocket_boundary: collections.abc.Sequence[tuple[float, float]], islands: collections.abc.Sequence[collections.abc.Sequence[tuple[float, float]]] = [], tool_radius: float = 3, wall_margin: float = 0) -> list[tuple[float, float]]:
    r"""
    Round both ends of a cutting arc with quarter-circle fillets.
    
    The arc is trimmed to the longest sub-arc whose tool sweep
    (arc + end fillets of *tool_radius*) does not collide with
    *pocket_boundary* or *islands*.  A 90° fillet of *tool_radius*
    is then appended at each end.
    
    :param arc: Cutting arc vertices (open polyline).
    :param pocket_boundary: Outer boundary of the pocket.
    :param islands: List of island (hole) polygons (default []).
    :param tool_radius: Tool / fillet radius in mm (default 3.0).
    :param wall_margin: Extra clearance past tangency (default 0.0).
    :returns: Filleted arc as an open polyline.
    """

def find_safe_sweep_end(arc: collections.abc.Sequence[tuple[float, float]], pocket_boundary: collections.abc.Sequence[tuple[float, float]], islands: collections.abc.Sequence[collections.abc.Sequence[tuple[float, float]]] = [], tool_radius: float = 3, wall_margin: float = 0) -> tuple[tuple[float, float], tuple[float, float]] | None:
    r"""
    Find the longest safe sub-arc by iterative sweep shortening.
    
    Returns the two points ``(enter, exit)`` delimiting the longest
    sub-arc of *arc* whose tool sweep (arc + end fillets of
    *tool_radius*) does not collide with *pocket_boundary* or
    *islands*.  Shortens from each end until the sweep is clear.
    Returns ``None`` when no usable safe sub-arc remains.
    
    :param arc: Cutting arc vertices (open polyline).
    :param pocket_boundary: Outer boundary of the pocket.
    :param islands: List of island (hole) polygons (default []).
    :param tool_radius: Tool radius in mm (default 3.0).
    :param wall_margin: Extra clearance past tangency (default 0.0).
    :returns: ``(enter, exit)`` or ``None``.
    """

def get_descending_radius_fillet(arc: collections.abc.Sequence[tuple[float, float]], outer_boundary: collections.abc.Sequence[tuple[float, float]], inner_obstacles: collections.abc.Sequence[collections.abc.Sequence[tuple[float, float]]] = [], radius: float = 3, margin: float = 0) -> list[tuple[float, float]]:
    r"""
    Try fillets at descending radii until one fits.
    
    Starts at *radius* and halves until either both (or one) end
    fillet fits, or the radius drops below 0.1; returns the
    filleted arc, or an empty list if none fits.
    
    The safety distance (``radius + margin``) stays fixed as the
    fillet radius shrinks, so the tool clearance remains constant.
    
    :param arc: Cutting arc vertices (open polyline).
    :param outer_boundary: Outer boundary polygon.
    :param inner_obstacles: List of obstacle polygons (default []).
    :param radius: Initial fillet radius in mm (default 3.0).
    :param margin: Extra clearance past tangency (default 0.0).
    :returns: Filleted arc or empty list.
    """

def trim_to_safe_fillet_span(polyline: collections.abc.Sequence[tuple[float, float]], outer_boundary: collections.abc.Sequence[tuple[float, float]], inner_obstacles: collections.abc.Sequence[collections.abc.Sequence[tuple[float, float]]] = [], radius: float = 3, margin: float = 0) -> tuple[tuple[float, float], tuple[float, float]] | None:
    r"""
    Find the longest sub-span whose end fillets avoid obstacles.
    
    Shortens from each end until the sweep is clear.
    Returns ``(enter, exit)`` or ``None``.
    
    :param polyline: Open polyline to trim.
    :param outer_boundary: Outer boundary polygon.
    :param inner_obstacles: List of obstacle polygons (default []).
    :param radius: Fillet radius (default 3.0).
    :param margin: Extra clearance past tangency (default 0.0).
    :returns: ``(enter, exit)`` or ``None``.
    """

def try_fillet_one_end(arc: collections.abc.Sequence[tuple[float, float]], outer_boundary: collections.abc.Sequence[tuple[float, float]], inner_obstacles: collections.abc.Sequence[collections.abc.Sequence[tuple[float, float]]] = [], radius: float = 3, margin: float = 0) -> list[tuple[float, float]]:
    r"""
    Try a fillet at just one end of an arc when both ends don't fit.
    
    Tests the enter (start) fillet first, then the exit (end) fillet,
    and returns the first that does not collide with the boundary or
    obstacles.  Falls back to the original arc if neither fits.
    
    :param arc: Cutting arc vertices (open polyline).
    :param outer_boundary: Outer boundary polygon.
    :param inner_obstacles: List of obstacle polygons (default []).
    :param radius: Fillet radius (default 3.0).
    :param margin: Extra clearance past tangency (default 0.0).
    :returns: Arc with optional single-end fillet, or original arc.
    """

