
    hi                        S SK Jr  S SKJrJrJr  S SKrS SKJrJ	r	J
r
JrJr  SSKJr  \R                  R                   (       a   S SKJr  SS/r S     SS	 jjr S     SS
 jjrg! \ a     N'f = f)    )annotations)IterableIteratorSequenceN)Vec2UVecVec3safe_normal_vectorOCS   )earcutmapbox_earcut_2dmapbox_earcut_3dc                    [         R                  " U 5      n[        U5      S:X  a  / $ / nU(       a&  U Vs/ s H  n[         R                  " U5      PM     nn[        X#5      $ s  snf )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        J/var/www/html/env/lib/python3.13/site-packages/ezdxf/math/triangulation.pyr   r      sW    0 YYx F
6{a	!F.34ed$))D/e4&!! 5s    A"c              #  |  ^	#    [         R                  " U 5      n[        U5      S:X  a  gUS   R                  US   5      (       a  UR	                  5         [        U5      nUS:  a  gUS:X  a  US   US   US   4v   g[        [        U5      5      nUR                  US   5      R                  m	[        UR                  U5      5      n/ nU(       a*  U Vs/ s H  n[        UR                  U5      5      PM     nn[        XV5       H)  n[        UR                  U	4S jU 5       5      5      v   M+     gs  snf 7f)a  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  f   >#    U  H&  n[        UR                  UR                  T5      v   M(     g 7fN)r	   xy).0v	elevations     r   	<genexpr>#mapbox_earcut_3d.<locals>.<genexpr>i   s%     JAd133Y77s   .1)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 ii!G
7|qqz'"+&&LEqyzaj'!*gaj00
 )
*CWQZ(**I++G45L"$IAFGT#--d34	G <3JJJ
 	
 4	 Hs   CD<$D7<A D<r   )r   Iterable[UVec]r   Iterable[Iterable[UVec]] | Nonereturnzlist[Sequence[Vec2]])r   r3   r   r4   r5   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>rB      s    # / /  @ @ "==2
  HL""%D""D HL3
3
%D3
3
U  s   A* *A32A3