
    hM                       % S SK Jr  S SKJrJrJrJr  S SKJrJ	r	  S SK
r
S SKrS SKJr  S SKJrJrJrJrJrJrJrJrJr  S SKJrJrJrJrJrJrJ r J!r!   S SK"J#r#  / SQr%\&" \RN                  5      r(\&" \RR                  5      r*\&" \RV                  5      r,\&" \RZ                  5      r. " S	 S
\/5      r0 " S S\05      r1\Rd                  r3S\4S'   \Rj                  r6S\4S'   \Rn                  " / \6S9r8\Rn                  " / \3S9r9 " S S\
Rt                  5      r; " S S\;5      r< " S S\;5      r=S&S jr>Sr?Sr@SrASrBS\@4\A\A4\B\B\B4\?4/rCSS.S&S jjrDS'S  jrES(S! jrF " S" S#\
Rt                  5      rG " S$ S%\G5      rHg! \$ a    Sr# GN+f = f))    )annotations)IterableOptionalIteratorSequence)Self	TypeAliasN)	Matrix44UVecVec2Vec3has_clockwise_orientationBezier3PBezier4PBoundingBox2dBoundingBox)PathCommandPathElementLineToMoveToCurve3ToCurve4Tonesting)
np_support)	NumpyPath2dNumpyPoints2dNumpyPoints3dNumpyShapesExceptionEmptyShapeErrorto_qpainter_pathto_matplotlib_pathsingle_pathsorient_pathsc                      \ rS rSrSrg)r   9    N__name__
__module____qualname____firstlineno____static_attributes__r'       @/var/www/html/env/lib/python3.13/site-packages/ezdxf/npshapes.pyr   r   9       r.   r   c                      \ rS rSrSrg)r    =   r'   Nr(   r'   r.   r/   r    r    =   r0   r.   r    r	   CommandNumpyTypeVertexNumpyTypedtypec                      \ rS rSr% Sr\rS\S'   SS jr\	R                  SS j5       rSS jrSS jrSS	 jrSS
 jrSS jrSS jrSrg)NumpyShape2dG   zThis is an optimization to store many 2D paths and polylines in a compact way
without sacrificing basic functions like transformation and bounding box calculation.
npt.NDArray[VertexNumpyType]	_verticesc                    U R                   n[        U5      S:  a4  [        UR                  S5      5      [        UR	                  S5      5      4$ [        S5      ezBReturns the extents of the bounding box as tuple (extmin, extmax).r   zempty shape has no extends)r;   lenr   minmaxr    selfvs     r/   extentsNumpyShape2d.extentsN   E    NNq6A:a>4a>11!">??r.   c                    g Nr'   rB   s    r/   cloneNumpyShape2d.cloneV       r.   c                    U R                   $ rH   r;   rI   s    r/   np_verticesNumpyShape2d.np_verticesZ       ~~r.   c                `    U R                   n[        U5      S:X  a  gUR                  US5        g)-Transforms the vertices of the shape inplace.r   N   r;   r>   transform_array_inplacerB   mrC   s      r/   transform_inplaceNumpyShape2d.transform_inplace]   )    NNq6Q;	!!!Q'r.   c                X    U R                    Vs/ s H  n[        U5      PM     sn$ s  snf )zYReturns the shape vertices as list of :class:`Vec2` 
e.g. [Vec2(1, 2), Vec2(3, 4), ...] 
r;   r   rA   s     r/   verticesNumpyShape2d.verticesd   s$     "&0AQ000   'c                X    U R                    Vs/ s H  n[        U5      PM     sn$ s  snf )zKReturns the shape vertices as list of 2-tuples 
e.g. [(1, 2), (3, 4), ...]
)r;   tuplerA   s     r/   	to_tuplesNumpyShape2d.to_tuplesj   s$     #'..1.Qa.111r`   c                6    U R                   R                  5       $ )zHReturns the shape vertices as list of lists 
e.g. [[1, 2], [3, 4], ...]
)r;   tolistrI   s    r/   to_listNumpyShape2d.to_listp   s     ~~$$&&r.   c                4    [        U R                  5       5      $ z)Returns the bounding box of all vertices.)r   rD   rI   s    r/   bboxNumpyShape2d.bboxv   s    T\\^,,r.   r'   N)returnztuple[Vec2, Vec2]rm   r   rm   r:   rX   r
   rm   Nonerm   z
list[Vec2])rm   zlist[tuple[float, float]])rm   zlist[list[float]])rm   r   )r)   r*   r+   r,   __doc__EMPTY_SHAPEr;   __annotations__rD   abcabstractmethodrJ   rO   rY   r^   rc   rg   rk   r-   r'   r.   r/   r8   r8   G   sR     /:I+9@ 	 (12'-r.   r8   c                  :    \ rS rSrSrSS jrS	S jr\rS
S jrSr	g)r   {   z5Represents an array of 2D points stored as a ndarray.c                    U(       aE  [         R                  " U Vs/ s H  o"R                  UR                  4PM     sn[        S9U l        g g s  snf Nr5   )nparrayxyr4   r;   rB   pointsrC   s      r/   __init__NumpyPoints2d.__init__~   s;    XX%+,V##qssV,ODN ,s   !Ac                f    U R                  S 5      nU R                  R                  5       Ul        U$ rH   	__class__r;   copyrB   rJ   s     r/   rJ   NumpyPoints2d.clone   )    t$..--/r.   c                ,    [        U R                  5      $ rH   r>   r;   rI   s    r/   __len__NumpyPoints2d.__len__       4>>""r.   rN   N)r   zOptional[Iterable[Vec2 | Vec3]]rm   rq   rn   rm   int
r)   r*   r+   r,   rs   r   rJ   __copy__r   r-   r'   r.   r/   r   r   {       ?
 H#r.   r   c                  h   \ rS rSr% SrS\S'   SS jrSS jr\SS j5       r	\SS j5       r
S S	 jrS!S
 jr\rS"S jrS#S jrS$S jr\ S%     S&S jj5       r\S'S j5       r\S'S j5       r\S'S j5       r\S'S j5       rS(S jrS'S jrS!S jrS!S jrS!S jrS)S*S jjrS+S jr\S,S j5       rSr g)-r      a6  Represents a 2D path, the path control vertices and commands are stored as ndarray.

This class cannot build paths from scratch and is therefore not a drop-in replacement
for the :class:`ezdxf.path.Path` class. Operations like transform and reverse are
done inplace to utilize the `numpy` capabilities. This behavior is different from the
:class:`ezdxf.path.Path` class!!!

Construct new paths by the :class:`Path` class and convert them to
:class:`NumpyPath2d` instances::

    path = Path((0, 0))
    path.line_to((50, 70))
    ...
    path2d = NumpyPath2d(path)

znpt.NDArray[CommandNumpyType]	_commandsc                   Uc  [         U l        [        U l        g UR	                  5        Vs/ s H  o"R
                  UR                  4PM     nn[        U5      S:X  a   [        UR                  5      /n[        R                  " U[        S9U l        [        R                  " UR                  5       [        S9U l        g s  snf ! [         a    / n N^f = f)Nr   r5   )rt   r;   NO_COMMANDSr   control_verticesr~   r   r>   r   start
IndexErrorr|   r}   r4   command_codesr3   )rB   pathrC   r^   s       r/   r   NumpyPath2d.__init__   s    <(DN(DN(,(=(=(?@(?1SS!##J(?@x=A ,- (/B$"4"4"6>NO A  s   !C C CCc                ,    [        U R                  5      $ rH   )r>   r   rI   s    r/   r   NumpyPath2d.__len__   r   r.   c                2    [        U R                  S   5      $ )z>Returns the start point as :class:`~ezdxf.math.Vec2` instance.r   r   r;   rI   s    r/   r   NumpyPath2d.start   s     DNN1%&&r.   c                2    [        U R                  S   5      $ )z<Returns the end point as :class:`~ezdxf.math.Vec2` instance.r   rI   s    r/   endNumpyPath2d.end   s     DNN2&''r.   c                X    U R                    Vs/ s H  n[        U5      PM     sn$ s  snf rH   r]   rA   s     r/   r   NumpyPath2d.control_vertices   s"    !%0AQ000r`   c                    U R                  S 5      nU R                  R                  5       Ul        U R                  R                  5       Ul        U$ rH   )r   r   r   r;   r   s     r/   rJ   NumpyPath2d.clone   s=    t$..--/..--/r.   c                ,    [        U R                  5      $ )zInternal API.)listr   rI   s    r/   r   NumpyPath2d.command_codes   s    DNN##r.   c              #  z  #    U R                  5       nSnU R                   H  nU[        :X  a  [        X   5      v   US-  nM#  U[        :X  a  [        XS-      X   5      v   US-  nMI  U[        :X  a"  [        XS-      X   XS-      5      v   US-  nMu  U[        :X  d  M  [        X   5      v   US-  nM     g 7f)N   rT      )
r^   r   CMD_LINE_TOr   CMD_CURVE3_TOr   CMD_CURVE4_TOr   CMD_MOVE_TOr   )rB   r^   indexcmds       r/   commandsNumpyPath2d.commands   s     ==?>>Ck!X_--
%x	2HODD
%QY'(19:M  
#X_--
 "s   BB;"B;c                    U R                    Vs/ s H  n[        U5      PM     nnU R                   Vs/ s H  n[        U5      PM     nn[        R
                  " X$5      $ s  snf s  snf )z0Returns a new :class:`ezdxf.path.Path` instance.)r;   r   r   r   r   from_vertices_and_commands)rB   rC   r^   cr   s        r/   to_pathNumpyPath2d.to_path   sS    %)^^4^DG^4(,71GAJ7..xBB 57s
   A!A&c                   U " S 5      n[        U5      n[        U5      S:X  a  U$ U(       a0  US   R                  US   5      (       d  UR                  US   5        U Vs/ s H  oDR                  UR
                  4PM     nn[        R                  " U[        S9Ul	        [        R                  " [        U5      S-
  [        [        S9Ul        U$ s  snf )Nr   r   r5   r   )
fill_valuer6   )r   r>   iscloseappendr~   r   r|   r}   r4   r;   fullr   r3   r   )clsr^   closenew_pathrC   r   s         r/   from_verticesNumpyPath2d.from_vertices   s     t9>x=AO!,,Xb\::OOHQK(&./h33*h/XXfODWWK!O;K
  0s    !Cc                (    [         U R                  ;   $ )z_Returns ``True`` if the path is a :term:`Multi-Path` object that
contains multiple sub-paths.

)r   r   rI   s    r/   has_sub_pathsNumpyPath2d.has_sub_paths   s     dnn,,r.   c                    [        U R                  5      S:  a%  U R                  R                  U R                  5      $ g)z>Returns ``True`` if the start point is close to the end point.r   F)r>   r;   r   r   r   rI   s    r/   	is_closedNumpyPath2d.is_closed  s1     t~~"::%%dhh//r.   c                (    [         U R                  ;   $ )z3Returns ``True`` if the path has any line segments.)r   r   rI   s    r/   	has_linesNumpyPath2d.has_lines  s     dnn,,r.   c                \    [         U R                  ;   =(       d    [        U R                  ;   $ )z4Returns ``True`` if the path has any curve segments.)r   r   r   rI   s    r/   
has_curvesNumpyPath2d.has_curves  s!     .Q-4>>2QQr.   c           	       ^ ^^^^^^^	 SUUUU UUUU	4S jjnT R                   m[        T5      S:X  a  / $ [        T;  a  T /$ / mT R                  mSm	SmSmSmT HU  nU[        :X  a  TS-  mO=U[
        :X  a  TS-  mO-U[        :X  a  TS-  mOU[        :X  a  U" 5         TS-  mTm	TS-   mTS-  mMW     TS   [        :w  a  U" 5         T$ )zYield all sub-paths as :term:`Single-Path` objects.

It's safe to call :meth:`sub_paths` on any path-type:
:term:`Single-Path`, :term:`Multi-Path` and :term:`Empty-Path`.

c                 x   > TR                  S 5      n TTTS-    U l        TTT U l        TR                  U 5        g )Nr   )r   r;   r   r   )	s	cmd_indexcmd_start_indexr   rB   	sub_pathsr^   	vtx_indexvtx_start_indexs	    r/   append_sub_path.NumpyPath2d.sub_paths.<locals>.append_sub_path  s?    nnT*A"?Y]CAK"?9=AKQr.   r   r   rT   r   r   )rm   rq   )r   r>   r   r;   r   r   r   )
rB   r   r   r   r   r   r   r^   r   r   s
   `  @@@@@@@r/   r   NumpyPath2d.sub_paths  s    	  	  >>x=AIh&6M "	>>		Ck!Q	%Q	%Q	#!Q	"+"+a-NI  B<;&r.   c                    U R                   (       a  [        S5      e[        c  [        U R	                  5       5      $ [        R                  " U R
                  5      $ )zReturns ``True`` if 2D path has clockwise orientation.

Raises:
    TypeError: can't detect orientation of a :term:`Multi-Path` object

z/can't detect orientation of a multi-path object)r   	TypeErrorr   r   r^   r;   rI   s    r/   r   %NumpyPath2d.has_clockwise_orientation?  sE     MNN,T]]_==77GGr.   c                   U R                   n[        U R                   5      (       d  U $ US   [        :X  ag  [        R                  " USS 5      R                  5       U l         [        R                  " U R                  SS2S4   SS9R                  5       U l        U $ [        R                  " U5      R                  5       U l         [        R                  " U R                  SS9R                  5       U l        U $ )z!Reverse path orientation inplace.r   N.r   axis)r   r>   r   r|   flipr   r;   )rB   r   s     r/   reverseNumpyPath2d.reverseM  s    >>4>>""KB<;&
  WWXcr]388:DNWWT^^CRCH%=AFKKMDN   WWX.335DNWWT^^!<AACDNr.   c                P    U R                  5       (       d  U R                  5         U $ )zvApply clockwise orientation inplace.

Raises:
    TypeError: can't detect orientation of a :term:`Multi-Path` object

r   r   rI   s    r/   	clockwiseNumpyPath2d.clockwise^  s!     --//LLNr.   c                P    U R                  5       (       a  U R                  5         U $ )z~Apply counter-clockwise orientation inplace.

Raises:
    TypeError: can't detect orientation of a :term:`Multi-Path` object

r   rI   s    r/   counter_clockwiseNumpyPath2d.counter_clockwisei  s!     ))++LLNr.   c           	   #    #    [        U R                  5      (       d  gU R                  5       nUS   nUv   SnU R                   H  nU[        :X  d
  U[        :X  a  X5   nUS-  nUv   OU[
        :X  aT  X5US-    u  pUS-  n[        R                  " [        XHU45      R                  X5      5      n	[        U	5        U	 Sh  vN   OmU[        :X  aU  X5US-    u  pnUS-  n[        R                  " [        XJX45      R                  X5      5      n	[        U	5        U	 Sh  vN   O[        SU 35      eUnM     g Ny N7f)z4Flatten path to vertices as :class:`Vec2` instances.Nr   r   rT   r   zInvalid command: )r>   r   r^   r   r   r   r   generater   
flatteningnextr   r   
ValueError)rB   distancesegmentsr^   r   r   r   end_locationctrlptsctrl1ctrl2s               r/   r   NumpyPath2d.flatteningu  s?    4>>""==?>>Ck!SK%7'
""%%-eai%@"
mme<89DDXX S	%-5eai-H*l
mmeE@ALL 
 S	 #4SE!:;; E3 "  s%   C E D<AE !D>"E >E c                   [        U5      (       d  g[        U R                  5      (       d  US   nUSS nOU nUR                  /nUR                  /nUR                  nU H  n[        UR                  5      S:X  a  M  UR	                  UR
                  5      (       dI  UR                  [        R                  " [        4[        S95        UR                  UR                  5        OUR                  UR                  SS 5        UR                  nUR                  UR                  5        M     [        R                  " USS9U l        [        R                  " U5      U l        g)zExtend an existing path by appending additional paths. The paths are
connected by MOVE_TO commands if the end- and start point of sequential paths
are not coincident (multi-path).
Nr   r   r5   r   )r>   r   r;   r   r   r   r   r|   r}   r   r3   concatenate)rB   pathsfirstr^   r   r   	next_paths          r/   extendNumpyPath2d.extend  s   
 5zz4>>""!HE!"IEE&+oo%6&+oo%6III9&&'1,;;y//+?O PQ	 3 34	 3 3AB 78--COOI//0  q91r.   c                x    U (       d  [        S5      $ U S   R                  5       nUR                  U SS 5        U$ )zReturns a new path of concatenated paths. The paths are connected by
MOVE_TO commands if the end- and start point of sequential paths are not
coincident (multi-path).
Nr   r   )r   rJ   r  )r   r  s     r/   r   NumpyPath2d.concatenate  s9     t$$a U12Yr.   )r   r;   N)r   zOptional[Path]rm   rq   r   )rm   r   rr   rn   )rm   z	list[int])rm   zIterator[PathElement])rm   r   )F)r^   zIterable[Vec2 | Vec3]r   boolrm   r   )rm   r  )rm   z
list[Self])   )r   floatr   r   rm   zIterator[Vec2])r   Sequence[NumpyPath2d]rm   rq   )r   r
  rm   r   )!r)   r*   r+   r,   rs   ru   r   r   propertyr   r   r   rJ   r   r   r   r   classmethodr   r   r   r   r   r   r   r   r   r   r   r  staticmethodr   r-   r'   r.   r/   r   r      s   " -,P# ' ' ( (1 H$&C <A,59	 " - -   - - R R+ZH"	
"!T2< 
 
r.   r   c           	        SSK JnJn  [        U 5      n [	        U 5      S:X  a  [        S5      eU" 5       nU  GH  nUR                  5        Vs/ s H  oR" UR                  UR                  5      PM!     nnUR                  US   5        SnUR                  5        H  nU[        :X  a  UR                  Xg   5        US-  nM'  U[        :X  a   UR                  Xg   XgS-      5        US-  nMQ  U[        :X  a&  UR!                  Xg   XgS-      XgS-      5        US-  nM  U["        :X  d  M  UR                  Xg   5        US-  nM     GM     U$ s  snf )z>Convert the given `paths` into a single :class:`QPainterPath`.r   )QPainterPathQPointFone or more paths requiredr   rT   r   )ezdxf.addons.xqtr  r  r   r>   r   r^   r~   r   moveTor   r   lineTor   quadTor   cubicTor   )	r   r  r  qpathr   rC   r   r   r   s	            r/   r!   r!     s*   6KE
5zQ566NE-1]]_=_'!##qss#_=VAY%%'Ck!V]+
%V]F19,=>
%fmVAI->qy@QR
#V]+
 (	 $ L# >s   &Er   rT   r   r  )r   F)detect_holesc                  SSK Jn  [        U 5      n [        U 5      S:X  a  [	        S5      eU(       a  [        U 5      n / n/ nU  Hf  nUR                  UR                  5       5        UR                  [        5        UR                  5        H  nUR                  [        U   5        M     Mh     [        R                  " U5      n U" Xt5      $ ! [         a4  n[	        S[        U5       S[        U5       S[        U5       35      eSnAff = f)zConvert the given `paths` into a single :class:`matplotlib.path.Path`.

Matplotlib requires counter-clockwise oriented outside paths and clockwise oriented
holes. Set the `detect_holes` argument to ``True`` if this path orientation is not
yet satisfied.
r   )r   r  zmatplotlib.path.Path(z, z): N)matplotlib.pathr   r   r>   r   r$   r   rO   
MPL_MOVETOr   r  	MPL_CODESr|   r   	Exceptionstr)	r   r  r   r^   codesr   r   r   es	            r/   r"   r"     s     %KE
5zQ566U#!#HE((*+Z %%'CLL3( ( 
 ^^H%FYF"" Y0VRE
|3sSTvhWXXYs   C 
D/DDc                p    / nU  H-  nUR                  5       nU(       d  M  UR                  U5        M/     U$ rH   )r   r  )r   single_paths_pr   s       r/   r#   r#     s7    ')MKKM	9  +  r.   c                   [        U 5      n[        U5      S:  a  U $ [        R                  " U5      n[        R                  " U5      u  p4U H  nUR                  5         M     U H  nUR                  5         M     X4-   $ )zgReturns a new list of paths, with outer paths oriented counter-clockwise and
holes oriented clockwise.
rT   )r#   r>   r   make_polygon_structurewinding_deconstructionr   r   )r   r   polygonsouter_pathsholesr   s         r/   r$   r$     sy     $0#6I
9~--i8H !77AK    r.   c                      \ rS rSr% Sr\rS\S'   SS jr\	R                  SS j5       rSS jrSS jrSS	 jrSS
 jrSrg)NumpyShape3di4  zThis is an optimization to store many 3D paths and polylines in a compact way
without sacrificing basic functions like transformation and bounding box calculation.
r:   r;   c                    U R                   n[        U5      S:  a4  [        UR                  S5      5      [        UR	                  S5      5      4$ [        S5      er=   )r;   r>   r   r?   r@   r    rA   s     r/   rD   NumpyShape3d.extents;  rF   r.   c                    g rH   r'   rI   s    r/   rJ   NumpyShape3d.cloneC  rL   r.   c                    U R                   $ rH   rN   rI   s    r/   rO   NumpyShape3d.np_verticesG  rQ   r.   c                `    U R                   n[        U5      S:X  a  gUR                  US5        g)rS   r   Nr   rU   rW   s      r/   rY   NumpyShape3d.transform_inplaceJ  r[   r.   c                X    U R                    Vs/ s H  n[        U5      PM     sn$ s  snf )z4Returns the shape vertices as list of :class:`Vec3`.)r;   r   rA   s     r/   r^   NumpyShape3d.verticesQ  s"    !%0AQ000r`   c                4    [        U R                  5       5      $ rj   )r   rD   rI   s    r/   rk   NumpyShape3d.bboxU  s    4<<>**r.   r'   N)rm   ztuple[Vec3, Vec3]rn   ro   rp   )rm   z
list[Vec3])rm   r   )r)   r*   r+   r,   rs   rt   r;   ru   rD   rv   rw   rJ   rO   rY   r^   rk   r-   r'   r.   r/   r+  r+  4  sH     /:I+9@ 	 (1+r.   r+  c                  :    \ rS rSrSrSS jrS	S jr\rS
S jrSr	g)r   iZ  z5Represents an array of 3D points stored as a ndarray.c                    U(       aC  [         R                  " U Vs/ s H  n[        U5      R                  PM     sn[        S9U l        g g s  snf r{   )r|   r}   r   xyzr4   r;   r   s      r/   r   NumpyPoints3d.__init__]  s9    XX&,-faf-_DN -s   Ac                f    U R                  S 5      nU R                  R                  5       Ul        U$ rH   r   r   s     r/   rJ   NumpyPoints3d.clonec  r   r.   c                ,    [        U R                  5      $ rH   r   rI   s    r/   r   NumpyPoints3d.__len__j  r   r.   rN   N)r   zOptional[Iterable[UVec]]rm   rq   rn   r   r   r'   r.   r/   r   r   Z  r   r.   r   )r   Iterable[NumpyPath2d])r   r@  rm   list[NumpyPath2d])r   rA  rm   rA  )I
__future__r   typingr   r   r   r   typing_extensionsr   r	   rv   numpyr|   numpy.typingnpt
ezdxf.mathr
   r   r   r   r   r   r   r   r   
ezdxf.pathr   r   r   r   r   r   r   r   	ezdxf.accr   ImportError__all__r   MOVE_TOr   LINE_TOr   	CURVE3_TOr   	CURVE4_TOr   r  r   r    int8r3   ru   float64r4   r}   rt   r   ABCr8   r   r   r!   r  
MPL_LINETO
MPL_CURVE3
MPL_CURVE4r  r"   r#   r$   r+  r   r'   r.   r/   <module>rW     s   # 9 9 - 
  
 
 
	 	 	$
 '//"'//"G%%&G%%&	9 		* 	 !gg ) %ZZ 'hhr1hhr!121-377 1-h#L #(y, yx	< 



 	MZ(M	 FK Y>*#+377 #+L#L #o  Js   E; ;FF