Ë
    £èhÓ  ã                  óØ   — d dl mZ d dlmZmZmZ d dlZd dlmZm	Z	m
Z
mZmZ ddlmZ ej                  j                   r	 d dlmZ ddgZ	 d	 	 	 	 	 dd	„Z	 d	 	 	 	 	 dd
„Zy# e$ r Y Œ"w xY w)é    )Úannotations)ÚIterableÚIteratorÚSequenceN)ÚVec2ÚUVecÚVec3Úsafe_normal_vectorÚOCSé   )ÚearcutÚmapbox_earcut_2dÚmapbox_earcut_3dc                óº   — t        j                  | «      }t        |«      dk(  rg S g }|r"|D �cg c]  }t        j                  |«      ‘Œ }}t        ||«      S c c}w )a:  Mapbox triangulation algorithm with hole support for 2D polygons.

    Implements a modified ear slicing algorithm, optimized by z-order
    curve hashing and extended to handle holes, twisted polygons, degeneracies
    and self-intersections in a way that doesn't guarantee correctness of
    triangulation, but attempts to always produce acceptable results for
    practical data.

    Source: https://github.com/mapbox/earcut

    Args:
        exterior: exterior polygon as iterable of :class:`Vec2` objects
        holes: iterable of holes as iterable of :class:`Vec2` objects, a hole
            with single point represents a `Steiner point`_.

    Returns:
        yields the result as 3-tuples of :class:`Vec2` objects

    .. _Steiner point: https://en.wikipedia.org/wiki/Steiner_point_(computational_geometry)

    r   )r   ÚlistÚlenr   )ÚexteriorÚholesÚpointsÚholes_Úholes        ú8lib/python3.12/site-packages/ezdxf/math/triangulation.pyr   r      sY   € ô0 �Y‰Y�xÓ €FÜ
ˆ6ƒ{�aÒØˆ	Ø!€FÙÙ.3Ó4©e d”$—)‘)˜D•/¨eˆÐ4Ü�&˜&Ó!Ð!ùò 5s   ®Ac              #  óV  ‡	K  — t        j                  | «      }t        |«      dk(  ry|d   j                  |d   «      r|j	                  «        t        |«      }|dk  ry|dk(  r|d   |d   |d   f–— yt        t        |«      «      }|j                  |d   «      j                  Š	t        |j                  |«      «      }g }|r'|D �cg c]  }t        |j                  |«      «      ‘Œ }}t        ||«      D ]'  }t        |j                  ˆ	fd„|D «       «      «      –— Œ) yc c}w ­w)aU  Mapbox triangulation algorithm with hole support for flat 3D polygons.

    Implements a modified ear slicing algorithm, optimized by z-order
    curve hashing and extended to handle holes, twisted polygons, degeneracies
    and self-intersections in a way that doesn't guarantee correctness of
    triangulation, but attempts to always produce acceptable results for
    practical data.

    Source: https://github.com/mapbox/earcut

    Args:
        exterior: exterior polygon as iterable of :class:`Vec3` objects
        holes: iterable of holes as iterable of :class:`Vec3` objects, a hole
            with single point represents a `Steiner point`_.

    Returns:
        yields the result as 3-tuples of :class:`Vec3` objects

    Raise:
        TypeError: invalid input data type
        ZeroDivisionError: normal vector calculation failed

    r   Néÿÿÿÿé   r   é   c              3  ó`   •K  — | ]%  }t        |j                  |j                  ‰«      –— Œ' y ­w©N)r	   ÚxÚy)Ú.0ÚvÚ	elevations     €r   Ú	<genexpr>z#mapbox_earcut_3d.<locals>.<genexpr>i   s#   øè ø€ ÐJÁ¸Aœd 1§3¡3¨¯©¨Y×7Áùs   ƒ+.)r	   r   r   ÚiscloseÚpopr   r
   Úfrom_wcsÚzÚpoints_from_wcsr   ÚtupleÚpoints_to_wcs)
r   r   ÚpolygonÚcountÚocsÚexterior_ocsÚ	holes_ocsr   Útriangler#   s
            @r   r   r   7   s  øè ø€ ô4 �i‰i˜Ó!€GÜ
ˆ7ƒ|�qÒØàˆq�z×Ñ˜' "™+Ô&Ø�‰ŒÜ�‹L€EØˆq‚yØØ�‚zØ�a‰j˜' !™* g¨a¡jÐ0Ò0Øä
Ô  Ó)Ó
*€CØ—‘˜W Q™ZÓ(×*Ñ*€IÜ˜×+Ñ+¨GÓ4Ó5€LØ"$€IÙÙAFÓGÁ¸”T˜#×-Ñ-¨dÓ3Õ4Àˆ	ÐGô ˜<¨Ö3ˆÜØ×ÑÓJÁÓJÓJó
ó 	
ñ 4ùò	 Hùs   ƒCD)Ã
!D$Ã+>D)r   )r   úIterable[UVec]r   úIterable[Iterable[UVec]] | NoneÚreturnzlist[Sequence[Vec2]])r   r2   r   r3   r4   zIterator[Sequence[Vec3]])Ú
__future__r   Útypingr   r   r   ÚezdxfÚ
ezdxf.mathr   r   r	   r
   r   Ú_mapbox_earcutr   ÚoptionsÚ	use_c_extÚezdxf.acc.mapbox_earcutÚImportErrorÚ__all__r   r   © ó    r   Ú<module>rA      sž   ðõ #ß /Ñ /Û ß @Õ @å "à‡=�=×ÒðÝ2ð
 Øð€ð HLð"Øð"Ø%Dð"àó"ðD HLð3
Øð3
Ø%Dð3
àô3
øðU ò Ùðús   Á A! Á!A)Á(A)