
    h                       S SK Jr  S SKJrJrJrJrJr  S SKrS SK	r	S SK
r
S SKJr  S SKJrJr  S SKJrJrJrJrJrJrJrJrJrJrJrJrJrJr  S SKJ r   \(       a  S SK!J"r"  / S	Qr#\	RH                   " S
 S\	RJ                  5      5       r&\	RH                   " S S\	RJ                  5      5       r' " S S\RP                  5      r) " S S\RP                  5      r* " S S5      r+ S#       S$S jjr,S%S jr-    S&S jr. " S S\)5      r/ " S S\)5      r0 " S S\*5      r1 " S S\*5      r2 " S S \*5      r3 " S! S"\*5      r4S\1\2\3\4/r5g)'    )annotations)UnionIterableSequenceOptionalTYPE_CHECKINGN)const)Tags
group_tags)Vec2Vec3UVecOCSbulge_to_arcConstructionEllipseConstructionArcBSplineNonUniformScalingErroropen_uniform_knot_vectorglobal_bspline_interpolationarc_angle_span_degangle_to_paramparam_to_angle)OCSTransform)AbstractTagWriter)BoundaryPathsPolylinePathEdgePathLineEdgeArcEdgeEllipseEdge
SplineEdgeEdgeTypeBoundaryPathTypeAbstractEdgeAbstractBoundaryPathc                      \ rS rSrSrSrSrg)r$   /          N)__name__
__module____qualname____firstlineno__POLYLINEEDGE__static_attributes__r+       O/var/www/html/env/lib/python3.13/site-packages/ezdxf/entities/boundary_paths.pyr$   r$   /   s    HDr3   r$   c                  $    \ rS rSrSrSrSrSrSrg)r#   5   r)   r*         r+   N)	r,   r-   r.   r/   LINEARCELLIPSESPLINEr2   r+   r3   r4   r#   r#   5   s    D
CGFr3   r#   c                     \ rS rSr% S\S'   S\S'   S\S'   \R                  SS j5       r\\R                  SS	 j5       5       r	\R                  SS
 j5       r
\R                  SS j5       r\R                  SS j5       rSrg)r&   =   r$   typeintpath_type_flags	list[str]source_boundary_objectsc                    g Nr+   selfs    r4   clearAbstractBoundaryPath.clearB   s     r3   c                    g rE   r+   )clstagss     r4   	load_tagsAbstractBoundaryPath.load_tagsE   s    <?r3   c                    g rE   r+   )rG   	tagwriterdxftypes      r4   
export_dxfAbstractBoundaryPath.export_dxfI   s    NQr3   c                    g rE   r+   rG   ocs	elevations      r4   	transformAbstractBoundaryPath.transformL       FIr3   c                    g rE   r+   rF   s    r4   is_validAbstractBoundaryPath.is_validO        #r3   r+   NreturnNone)rL   r
   r`   r&   rP   r   rQ   strr`   ra   rV   r   rW   floatr`   ra   r`   bool)r,   r-   r.   r/   __annotations__abcabstractmethodrH   classmethodrM   rR   rX   r\   r2   r+   r3   r4   r&   r&   =   s    
&&   ?  ?Q QI I# #r3   r&   c                  $   \ rS rSr% S\S'   \\R                  SS j5       5       r\\R                  SS j5       5       r	\R                  SS j5       r
\R                  SS j5       r\R                  SS j5       r\SS	 j5       r\SS
 j5       rSrg)r%   S   r#   r?   c                    g rE   r+   rF   s    r4   start_pointAbstractEdge.start_pointV   s    #&r3   c                    g rE   r+   rF   s    r4   	end_pointAbstractEdge.end_pointZ   s    !$r3   c                    g rE   r+   )rG   rP   s     r4   rR   AbstractEdge.export_dxf^   s    @Cr3   c                    g rE   r+   rU   s      r4   rX   AbstractEdge.transforma   rZ   r3   c                    g rE   r+   rF   s    r4   r\   AbstractEdge.is_validd   r^   r3   c                    U R                   $ rE   )ro   rF   s    r4   real_start_pointAbstractEdge.real_start_pointg   s    r3   c                    U R                   $ rE   )rr   rF   s    r4   real_end_pointAbstractEdge.real_end_pointk   s    ~~r3   r+   Nr`   r   rP   r   r`   ra   rd   rf   )r,   r-   r.   r/   rh   propertyri   rj   ro   rr   rR   rX   r\   r{   r~   r2   r+   r3   r4   r%   r%   S   s    
N&  &$  $C CI I# #     r3   r%   c                  ~   \ rS rSrSSS jjrS rS rS rS S j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\R$                  4   S$S jjrS%S jr  S&       S'S jjrS(S)S jjrS*S jrS+S,S jjrS-S"S jjrS.S/S jjrS"S jrS0S1S jjrS2S3S jjrS4S1S jjrS4S1S jjrS5S6S jjr S S jr!Sr"g)7r   p   Nc                $    U=(       d    / U l         g rE   paths)rG   r   s     r4   __init__BoundaryPaths.__init__q   s    16"
r3   c                ,    [        U R                  5      $ rE   )lenr   rF   s    r4   __len__BoundaryPaths.__len__t   s    4::r3   c                     U R                   U   $ rE   r   )rG   items     r4   __getitem__BoundaryPaths.__getitem__w   s    zz$r3   c                ,    [        U R                  5      $ rE   )iterr   rF   s    r4   __iter__BoundaryPaths.__iter__z       DJJr3   c                :    [        S U R                   5       5      $ )Nc              3  @   #    U  H  oR                  5       v   M     g 7frE   r\   .0ps     r4   	<genexpr>)BoundaryPaths.is_valid.<locals>.<genexpr>~        4A::<<   )allr   rF   s    r4   r\   BoundaryPaths.is_valid}       4444r3   c                0   / nUS   R                   S:X  d   e[        USS9nU Hh  nUS   R                  n[        US-  5      nU(       a  [        R                  U5      O[        R                  U5      nXWl        UR                  U5        Mj     U " U5      $ )Nr   \   	splitcoder*   )	coder   valuerg   r   rM   r   rA   append)rK   rL   r   grouped_path_tags	path_tagsrA   is_polyline_pathpaths           r4   rM   BoundaryPaths.load_tags   s    Aw||r!!!&tr:*I'l00O#Oa$78 $ &&y1''	2 
 $3 LL + 5zr3   c                :    [        S U R                   5       5      $ )Nc              3  Z   #    U  H!  oR                   [        R                  :H  v   M#     g 7frE   )r?   r$   r1   r   s     r4   r   /BoundaryPaths.has_edge_paths.<locals>.<genexpr>   s     GJq66-222Js   )+)anyr   rF   s    r4   has_edge_pathsBoundaryPaths.has_edge_paths   s    GDJJGGGr3   c                    / U l         g)zRemove all boundary paths.Nr   rF   s    r4   rH   BoundaryPaths.clear   	    
r3   c              #     #    U R                    H+  nUR                  [        R                  -  (       d  M'  Uv   M-     g7f)z+Iterable of external paths, could be empty.N)r   rA   r	   BOUNDARY_PATH_EXTERNALrG   bs     r4   external_pathsBoundaryPaths.external_paths   s/     A  5#?#???    0?	?c              #     #    U R                    H+  nUR                  [        R                  -  (       d  M'  Uv   M-     g7f)z,Iterable of outermost paths, could be empty.N)r   rA   r	   BOUNDARY_PATH_OUTERMOSTr   s     r4   outermost_pathsBoundaryPaths.outermost_paths   s/     A  5#@#@@@ r   c              #     #    [         R                  [         R                  -   nU R                   H$  n[	        UR
                  U-  5      SL d  M   Uv   M&     g7f)z*Iterable of default paths, could be empty.FN)r	   r   r   r   rg   rA   )rG   not_defaultr   s      r4   default_pathsBoundaryPaths.default_paths   sF     33e6R6RRAA%%34= s   A
A	Ac                   ^^ SS jm[        U4S j[        U R                  5       5       5      nSmU[        R                  :X  a  SmOU[        R
                  :X  a  SmU4S jU 5       $ )a=  Iterable of paths to process for rendering, filters unused
boundary paths according to the given hatch style:

- NESTED: use all boundary paths
- OUTERMOST: use EXTERNAL and OUTERMOST boundary paths
- IGNORE: ignore all paths except EXTERNAL boundary paths

Yields paths in order of EXTERNAL, OUTERMOST and DEFAULT.

c                h    U [         R                  -  (       a  gU [         R                  -  (       a  gg)Nr   r)   r*   )r	   r   r   flagss    r4   path_type_enum5BoundaryPaths.rendering_paths.<locals>.path_type_enum   s'    u333666r3   c              3  P   >#    U  H  u  pT" UR                   5      X4v   M     g 7frE   )rA   )r   ir   r   s      r4   r   0BoundaryPaths.rendering_paths.<locals>.<genexpr>   s'      
BW$!^A--.5BWs   #&r)   r7   r*   c              3  <   >#    U  H  u  po1T:  d  M  Uv   M     g 7frE   r+   )r   	path_type_r   ignores       r4   r   r      s     EoiAf2Ds   	)r`   r@   )sorted	enumerater   r	   HATCH_STYLE_NESTEDHATCH_STYLE_OUTERMOST)rG   hatch_styler   r   r   s      @@r4   rendering_pathsBoundaryPaths.rendering_paths   sb    	  
BKDJJBW
 
 %222FE777FEEEr3   c                    [        U[        5      (       d  [        S[        U5       35      eU R                  R                  U5        g)z3Append a new boundary path.

.. versionadded:: 1.4
zinvalid path type: N)
isinstancer&   	TypeErrorr?   r   r   )rG   r   s     r4   r   BoundaryPaths.append   s;    
 $ 4551$t*>??

$r3   c                T    [         R                  XU5      nU R                  U5        U$ )a  Create and add a new :class:`PolylinePath` object.

Args:
    path_vertices: iterable of polyline vertices as (x, y) or
        (x, y, bulge)-tuples.
    is_closed: 1 for a closed polyline else 0
    flags: default(0), external(1), derived(4), textbox(8) or outermost(16)

)r   from_verticesr   )rG   path_vertices	is_closedr   new_paths        r4   add_polyline_pathBoundaryPaths.add_polyline_path   s'      --mNHr3   c                H    [        5       nXl        U R                  U5        U$ )zCreate and add a new :class:`EdgePath` object.

Args:
    flags: default(0), external(1), derived(4), textbox(8) or outermost(16)

)r   rA   r   )rG   r   r   s      r4   add_edge_pathBoundaryPaths.add_edge_path   s"     :#( Hr3   c                    UR                  S[        U R                  5      5        U R                   H  nUR                  X5        M     g )N[   )
write_tag2r   r   rR   )rG   rP   rQ   r   s       r4   rR   BoundaryPaths.export_dxf   s4    RTZZ1JJDOOI/ r3   c                    UR                   (       d  U R                  SS9  U R                  5         U R                   H  nUR	                  XS9  M     g)z_Transform HATCH boundary paths.

These paths are 2d elements, placed in the OCS of the HATCH.

Tjust_with_bulgerW   N)scale_uniformpolyline_to_edge_pathsarc_edges_to_ellipse_edgesr   rX   )rG   rV   rW   r   s       r4   rX   BoundaryPaths.transform   sF       '''=++-JJDNN3N4 r3   c                   ^ SS jmSU4S jjn[        U R                  5       HO  u  p4[        U[        5      (       d  M  U(       a  UR	                  5       (       d  M:  U" U5      U R                  U'   MQ     g)zConvert polyline paths including bulge values to line- and arc edges.

Args:
    just_with_bulge: convert only polyline paths including bulge
        values if ``True``

c              3    #    S nSnU  GHs  u  p4n[        X45      nUc  UnUnM  US:w  Ga  [        5       n[        XU5      u  Ul        nn	Ul        UR                  [
        R                  " XR                  5      -   n
U
R                  USS9Ul        [        R                  " U5      S-  Ul        [        R                  " U	5      S-  Ul        [        R                  " UR                  UR                  5      (       a-  [        R                  " UR                  S5      (       a  SUl        Uv   OH[        5       nUR                  UR                  4Ul        UR                  UR                  4Ul        Uv   UnUnGMv     g 7f)N        g&.>)abs_tol     v@r   )r   r    r   centerradiusr   
from_angleiscloseccwmathdegreesstart_angle	end_angler   xystartend)points
prev_point
prev_bulger  r  bulgepointarcr  r  	chk_pointlines               r4   _edges4BoundaryPaths.polyline_to_edge_paths.<locals>._edges  sF    &*J #J%eQ
%!&J!&J$!)C %Z
C
#!
 #

T__[**-U UI'//
D/ICG&*ll;&?%&GCO$(LL$;e$CCM||COOS]]CCI I ).I#:D",,,
!=DJ %1DHJ"
"
C  &s   F Fc                   > [        5       n[        U R                  5      nU R                  (       a  UR	                  US   5        [        T" U5      5      Ul        U$ Nr   )r   listverticesr   r   edges)polyline_path	edge_pathr  r  s      r4   to_edge_path:BoundaryPaths.polyline_to_edge_paths.<locals>.to_edge_path4  sJ     
I!-"8"89H&&,"6(#34IOr3   N)r`   z"Iterable[Union[LineEdge, ArcEdge]])r`   r   )r   r   r   r   	has_bulge)rG   r   r  
path_indexr   r  s        @r4   r   $BoundaryPaths.polyline_to_edge_paths  sX    $	#L	 !*$** 5J$--"4>>+;+;)5d);

:&	 !6r3   c                    / nU R                    H>  nUR                  [        R                  :X  a  [	        XAU5      nUR                  U5        M@     X0l         g)a5  Convert all edge paths to simple polyline paths without bulges.

Args:
    distance: maximum distance from the center of the curve to the
        center of the line segment between two approximation points to
        determine if a segment should be subdivided.
    segments: minimum segment count per curve

N)r   r?   r$   r1   flatten_to_polyline_pathr   )rG   distancesegments	convertedr   s        r4   edge_to_polyline_paths$BoundaryPaths.edge_to_polyline_pathsB  sK     	JJDyy,111/IT"  
r3   c                    SS jnU R                    H[  n[        U[        5      (       d  M  UR                  n[	        U5       H&  u  pE[        U[
        5      (       d  M  U" U5      X4'   M(     M]     g)z'Convert all arc edges to ellipse edges.c                    [        5       nU R                  Ul        SUl        U R                  S4Ul        U R
                  Ul        U R                  Ul        U R                  Ul        U$ )N      ?r   )r!   r   ratior   
major_axisr  r  r   )r  ellipses     r4   
to_ellipse<BoundaryPaths.arc_edges_to_ellipse_edges.<locals>.to_ellipseV  sT    !mG ZZGNGM"%**c!2G"%//G #G''GKNr3   N)r  r    r`   r!   )r   r   r   r  r   r    )rG   r+  r   r  
edge_indexedges         r4   r   (BoundaryPaths.arc_edges_to_ellipse_edgesS  sY    	 JJD$))

(1%(8$J!$00,6t,<) )9 r3   c                  ^ SU4S jjn[        U R                  5       H]  u  p4[        U[        5      (       d  M  UR                  n[        U5       H&  u  pg[        U[
        5      (       d  M  U" U5      XV'   M(     M_     g)z
Convert all ellipse edges to spline edges (approximation).

Args:
    num: count of control points for a **full** ellipse, partial
        ellipses have proportional fewer control points but at least 3.

c                @  > [        U R                  U R                  U R                  U R                  U R
                  S9n[        [        [        T5      UR                  -  [        R                  -  5      S5      n[        R                  " X5      n[        5       nUR                  Ul        U R                   (       d  UR#                  5       n[$        R&                  " UR(                  5      Ul        UR+                  5       Ul        UR/                  5       Ul        U$ )Nr   r)  r(  start_param	end_paramr7   )r   r   r)  r(  r3  r4  maxr@   re   
param_spanr   taur   ellipse_approximationr"   degreer   reverser   r  control_pointsknotsknot_valuesweights)er*  counttoolsplinenums        r4   to_spline_edgeCBoundaryPaths.ellipse_edges_to_spline_edges.<locals>.to_spline_edgeq  s     *xx<<ggMM++G E#J););;dhhFGKE00@D\F KKFM55||~$(IId.A.A$BF!!%F!\\^FNMr3   N)r?  r!   r`   r"   )r   r   r   r   r  r!   )rG   rC  rD  r  r   r  r-  r.  s    `      r4   ellipse_edges_to_spline_edges+BoundaryPaths.ellipse_edges_to_spline_edgesg  sb    	, !*$** 5J$))

(1%(8$J!$44,:4,@) )9 !6r3   c                  ^ SU4S jjnU R                    Ht  n[        U[        5      (       d  M  / nUR                   HB  n[        U[        5      (       a  UR                  U" U5      5        M1  UR                  U5        MD     XCl        Mv     g)zConvert all spline edges to line edges (approximation).

Args:
    factor: count of approximation segments = count of control
        points x factor

c              3    >#    U R                   n[        U R                  5      (       a@  [        U R                  U R                  S-   U R
                  [        U5      (       a  UOS S9nO\[        U R                  5      (       a,  [        R                  " U R                  U R                  5      nO[        R                  " S5      e[        [        UR                  5      S5      S-
  T-  n[        UR                  U5      5      n[        US S USS  5       H5  u  pV[        5       nUR                  Ul        UR                  Ul        Uv   M7     g 7f)Nr)   )r;  orderr<  r>  z2SplineEdge() without control points or fit points.r7   )r>  r   r;  r   r9  r=  
fit_pointsfrom_fit_pointsr	   DXFStructureErrorr5  r  approximatezipr   vec2r  r  )	spline_edger>  bsplinesegment_countr  v1v2r.  factors	           r4   to_line_edges?BoundaryPaths.spline_edges_to_line_edges.<locals>.to_line_edges  s    !))G;--..!#.#=#=%,,q0%11'*7||G	 [++,,!11**K,>,> --H  !W%;%;!<a@1DNMG//>?HhsmXab\:zWW
77
	 ;s   EEN)rR  r"   )r   r   r   r  r"   extendr   )rG   rW  rX  r   	new_edgesr.  s    `    r4   spline_edges_to_line_edges(BoundaryPaths.spline_edges_to_line_edges  sm    	2 JJD$))	 JJD!$
33!((t)<=!((.	 '
 '
 r3   c                  ^ U4S jnU R                    Ht  n[        U[        5      (       d  M  / nUR                   HB  n[        U[        5      (       a  UR                  U" U5      5        M1  UR                  U5        MD     XCl        Mv     g)zConvert all ellipse edges to line edges (approximation).

Args:
    num: count of control points for a **full** ellipse, partial
        ellipses have proportional fewer control points but at least 3.

c              3  @  >#    [        U R                  U R                  U R                  U R                  U R
                  S9n[        [        [        T5      UR                  -  [        R                  -  5      S5      nUR                  US-   5      nU R                  (       d  [        [        U5      5      n[        UR!                  U5      5      n[#        US S USS  5       H5  u  pV[%        5       nUR&                  Ul        UR&                  Ul        Uv   M7     g 7f)Nr2  r7   r)   rK  )r   r   r)  r(  r3  r4  r5  r@   re   r6  r   r7  paramsr   reversedr  r  rP  r   rQ  r  r  )	r.  r*  rT  r`  r  rU  rV  r  rC  s	           r4   rX  @BoundaryPaths.ellipse_edges_to_line_edges.<locals>.to_line_edges  s     ){{??jj ,,..G  E#J1C1C$Cdhh$N OQRSM^^MA$56F 88!$v,/G,,V45HhsmXab\:zWW
77
	 ;s   DDN)r   r   r   r  r!   rZ  r   )rG   rC  rX  r   r[  r.  s    `    r4   ellipse_edges_to_line_edges)BoundaryPaths.ellipse_edges_to_line_edges  sm    	, JJD$))	 JJD!$44!((t)<=!((.	 '
 '
 r3   c                d    U R                  SS9  U R                  5         U R                  U5        g)zConvert all bulge, arc and ellipse edges to spline edges
(approximation).

Args:
    num: count of control points for a **full** circle/ellipse, partial
        circles/ellipses have proportional fewer control points but at
        least 3.

Tr   N)r   r   rF  )rG   rC  s     r4   all_to_spline_edges!BoundaryPaths.all_to_spline_edges  s/     	##D#9'')**3/r3   c                    U R                  SS9  U R                  5         U R                  U5        U R                  U5        g)ay  Convert all bulge, arc and ellipse edges to spline edges and
approximate this splines by line edges.

Args:
    num: count of control points for a **full** circle/ellipse, partial
        circles/ellipses have proportional fewer control points but at
        least 3.
    spline_factor: count of spline approximation segments = count of
        control points x spline_factor

Tr   N)r   r   rc  r\  )rG   rC  spline_factors      r4   all_to_line_edgesBoundaryPaths.all_to_line_edges  s=     	##D#9'')((-''6r3   c                R   U R                    H  n[        U[        5      (       a  UR                  5       s  $ [        U[        5      (       aF  UR
                   H4  nUR                  [        R                  [        R                  1;   d  M3      g   M  [        [        U5      5      e   g)zWReturns ``True`` if any boundary path has bulge values or arc edges
or ellipse edges.

TF)r   r   r   r  r   r  r?   r#   r:   r;   r   )rG   r   r.  s      r4   has_critical_elements#BoundaryPaths.has_critical_elements  s{    
 JJD$--~~''D(++ JJDyyX\\83C3C$DD# '  T
++  r3   r   rE   )r   z$Optional[list[AbstractBoundaryPath]]rf   )rL   r
   r`   r   r_   )r`   Iterable[AbstractBoundaryPath])r   r@   r`   ro  )r   r&   r`   ra   Tr)   r   zIterable[tuple[float, ...]]r   rg   r   r@   r`   r   )r)   )r   r@   r`   r   rb   )r   rd   T   )r   re   r!  r@   )    )rC  r@   r`   ra   )   )rW  r@   r`   ra   )@   )rw  rv  )rC  r@   ri  r@   r`   ra   )#r,   r-   r.   r/   r   r   r   r   r\   rk   rM   r   r   rH   r   r   r   r	   r   r   r   r   r   rR   rX   r   r#  r   rF  r\  rc  rf  rj  rm  r2   r+   r3   r4   r   r   p   s    =  5    H H "'!9!9FF	'F>  	2  	
 
&
0
5;<z"=(%AN*'X''R07"r3   r   r   c                    SS K nUR                  R                  U [        5       SS9nS UR	                  X5       5       n[
        R                  UU R                  S9$ )Nr   )rV   rW   c              3  P   #    U  H  oR                   UR                  4v   M     g 7frE   )r  r  )r   vs     r4   r   +flatten_to_polyline_path.<locals>.<genexpr>  s     K$Jqacc
$Js   $&r   )
ezdxf.pathr   from_hatch_boundary_pathr   
flatteningr   r   rA   )r   r   r!  ezdxfez_pathr  s         r4   r  r    s_      jj11$CEQ1OGKG$6$6x$JKH%%"" &  r3   c                   / n[        U 5      (       av  U S   R                  S;   aN  U R                  5       nUR                  S:X  a  UR                  UR                  5        OUR                  5         U$  / $ [        U 5      (       a  Mv  / $ )NrK  )a   J  r  )r   r   popr   r   r:  )r   source_boundary_object_tagslast_tags      r4    pop_source_boundary_objects_tagsr  !  sz    "$
i..R=* }}H}}#+228>>B ,33522I i.. Ir3   c                p    U R                  S[        U5      5        U H  nU R                  SU5        M     g )Nr  r  )r   r   )rP   handleshandles      r4   export_source_boundary_objectsr  2  s2     S\*S&) r3   c                      \ rS rSr\R
                  rSS jrSS jr\	  S       SS jj5       r
\	SS j5       r S     SS jjrSS jrSS jrSS	 jrSS
 jrSrg)r   i:  c                X    [         R                  U l        SU l        / U l        / U l        g )NF)r	   BOUNDARY_PATH_POLYLINErA   r   r  rC   rF   s    r4   r   PolylinePath.__init__=  s*    $)$@$@ ;= 35$r3   c                    gNTr+   rF   s    r4   r\   PolylinePath.is_validG      r3   c                l    [        5       nUR                  X5        U[        R                  -  Ul        U$ )a  Create a new :class:`PolylinePath` object from vertices.

Args:
    path_vertices: iterable of polyline vertices as (x, y) or
        (x, y, bulge)-tuples.
    is_closed: 1 for a closed polyline else 0
    flags: default(0), external(1), derived(4), textbox(8) or outermost(16)

)r   set_verticesr	   r  rA   )rK   r   r   r   r   s        r4   r   PolylinePath.from_verticesJ  s1       >m7#(5+G+G#G r3   c                   [        5       n[        U5      Ul        U H  nUu  pEUS:X  a&  UR                  R	                  US   US   S45        M3  US:X  a<  UR                  R                  5       u  pgnUR                  R	                  XgU45        Mu  US:X  a  M}  US:X  a  XRl        M  US:X  a  XRl        M  US	:X  d  M  M     U$ )
N
   r   r)   r   *   H   I   r   ]   )r   r  rC   r  r   r  r   rA   )	rK   rL   r   tagr   r   r  r  r  s	            r4   rM   PolylinePath.load_tags_  s    ~'G'M$CKDrz$$eAha#%>?"mm//1e$$aE]3!&',$! " r3   c                    / nU HW  n[        U5      S:X  a  Uu  pVSnO+[        U5      S:X  a  Uu  pVnO[        R                  " S5      eUR                  XVU45        MY     X0l        X l        g)z`Set new `vertices` as new polyline path, a vertex has to be a
(x, y) or a (x, y, bulge)-tuple.

r*   r   r7   z7Invalid vertex format, expected (x, y) or (x, y, bulge)N)r   r	   DXFValueErrorr   r  r   )rG   r  r   new_verticesvertexr  r  r  s           r4   r  PolylinePath.set_verticesv  sv     F6{aV!$e))M  u.  %"r3   c                .    / U l         SU l        / U l        g)zbRemoves all vertices and all handles to associated DXF objects
(:attr:`source_boundary_objects`).
FN)r  r   rC   rF   s    r4   rH   PolylinePath.clear  s     ')$r3   c                :    [        S U R                   5       5      $ )Nc              3  *   #    U  H	  u  po3v   M     g 7frE   r+   )r   r  r  r  s       r4   r   )PolylinePath.has_bulge.<locals>.<genexpr>  s     :M[Q55Ms   )r   r  rF   s    r4   r  PolylinePath.has_bulge  s    :DMM:::r3   c                   U R                  5       nUR                  nU" S[        U R                  5      5        US:X  a/  U" S[        U5      5        U" S[        U R                  5      5        OCUS:X  a/  U" S[        U R                  5      5        U" S[        U5      5        O[        SU 35      eU" S[        U R                  5      5        U R                   HG  u  pVnUR                  S[        U5      [        U5      45        U(       d  M5  U" S	[        U5      5        MI     US:X  a  [        XR                  5        g g )
Nr   HATCHr  r  MPOLYGONzunsupported DXF type r  r  r  )r  r   r@   rA   r   
ValueErrorr   r  write_vertexre   r  rC   )rG   rP   rQ   r  	write_tagr  r  r  s           r4   rR   PolylinePath.export_dxf  s   NN$	((	"c$../0gb#i.)b#dnn-.
"b#dnn-.b#i.)4WI>??"c$--()==KA%""2a%(';<y"eEl+ )
 g*96R6RS r3   c                   ^ ^^^ TR                   (       + mUUUU 4S jnT R                  (       a  [        U" 5       5      T l        gg)zTransform polyline path.c               3     >#    TR                    HU  u  pnU(       a  T(       a  [        S5      eTR                  [        XT5      5      nUR                  UR
                  U4v   MW     g 7f)Nz<Polyline path with arcs does not support non-uniform scaling)r  r   transform_vertexr   r  r  )r  r  r  rz  rW   has_non_uniform_scalingrV   rG   s       r4   
_transform*PolylinePath.transform.<locals>._transform  s_     #}}e 40"  ((aI)>?cc133o%  -s   A'A*N)r   r  r  )rG   rV   rW   r  r  s   ``` @r4   rX   PolylinePath.transform  s8    &)&7&7"7
	& 
	& == .DM r3   )r   rA   rC   r  Nr_   rf   rp  rq  )rL   r
   r`   r   rr  )r  zIterable[Sequence[float]]r   rg   r`   ra   rb   rd   )r,   r-   r.   r/   r$   r0   r?   r   r\   rk   r   rM   r  rH   r  rR   rX   r2   r+   r3   r4   r   r   :  s    $$D5  	2  	
 
 (  . FJ#1#>B#	#,*;T,/r3   c                  J   \ rS rSr\R
                  rSS jrS rSS jr	\
SS j5       rSS jrSS jr    S           SS jjr     S             SS	 jjr        S                 SS jjr  S       SS jjrSS jrSS jrSS jrSrg
) r   i  c                J    [         R                  U l        / U l        / U l        g rE   )r	   BOUNDARY_PATH_DEFAULTrA   r  rC   rF   s    r4   r   EdgePath.__init__  s    $::)+
')$r3   c                ,    [        U R                  5      $ rE   )r   r  rF   s    r4   r   EdgePath.__iter__  r   r3   c                :    [        S U R                   5       5      $ )Nc              3  @   #    U  H  oR                  5       v   M     g 7frE   r   )r   r?  s     r4   r   $EdgePath.is_valid.<locals>.<genexpr>  r   r   )r   r  rF   s    r4   r\   EdgePath.is_valid  r   r3   c                $   U " 5       n[        U5      Ul        [        USS9 Hj  n[        U5      S:X  a  M  US   R                  nSUs=:  a  S:  d  M2  O  M6  UR
                  R                  [        U   R                  USS  5      5        Ml     U$ )Nr  r   r      r)   )	r  rC   r   r   r   r  r   EDGE_CLASSESrM   )rK   rL   r  	edge_tags	edge_types        r4   rM   EdgePath.load_tags  s    E	,LT,R	)#DB7I9~"!!**I9 q  &&|I'>'H'HSTSU'WX 8 r3   c                H    U R                    H  nUR                  XS9  M     g)zTransform edge boundary paths.r   N)r  rX   )rG   rV   rW   r.  s       r4   rX   EdgePath.transform  s    JJDNN3N4 r3   c                    [        5       n[        U5      Ul        [        U5      Ul        U R                  R                  U5        U$ )zAdd a :class:`LineEdge` from `start` to `end`.

Args:
    start: start point of line, (x, y)-tuple
    end: end point of line, (x, y)-tuple

)r   r   r  r  r  r   )rG   r  r  r  s       r4   add_lineEdgePath.add_line  s8     z%[
9

$r3   c                    [        5       n[        U5      Ul        X&l        X6l        XFl        [        U5      Ul        U R                  R                  U5        U$ )a  Add an :class:`ArcEdge`.

**Adding Clockwise Oriented Arcs:**

Clockwise oriented :class:`ArcEdge` objects are sometimes necessary to
build closed loops, but the :class:`ArcEdge` objects are always
represented in counter-clockwise orientation.
To add a clockwise oriented :class:`ArcEdge` you have to swap the
start- and end angle and set the `ccw` flag to ``False``,
e.g. to add a clockwise oriented :class:`ArcEdge` from 180 to 90 degree,
add the :class:`ArcEdge` in counter-clockwise orientation with swapped
angles::

    edge_path.add_arc(center, radius, start_angle=90, end_angle=180, ccw=False)

Args:
    center: center point of arc, (x, y)-tuple
    radius: radius of circle
    start_angle: start angle of arc in degrees (`end_angle` for a
        clockwise oriented arc)
    end_angle: end angle of arc in degrees (`start_angle` for a
        clockwise oriented arc)
    ccw: ``True`` for counter-clockwise ``False`` for
        clockwise orientation

)
r    r   r   r   r  r  rg   r   r  r   )rG   r   r   r  r  r   r  s          r4   add_arcEdgePath.add_arc  sJ    D i&\

%! s)

#
r3   c                   US:  a  [         R                  " S5      e[        5       n[        U5      Ul        [        U5      Ul        X7l        XGl        XWl        [        U5      Ul
        U R                  R                  U5        U$ )aP  Add an :class:`EllipseEdge`.

**Adding Clockwise Oriented Ellipses:**

Clockwise oriented :class:`EllipseEdge` objects are sometimes necessary
to build closed loops, but the :class:`EllipseEdge` objects are always
represented in counter-clockwise orientation.
To add a clockwise oriented :class:`EllipseEdge` you have to swap the
start- and end angle and set the `ccw` flag to ``False``,
e.g. to add a clockwise oriented :class:`EllipseEdge` from 180 to 90
degree, add the :class:`EllipseEdge` in counter-clockwise orientation
with swapped angles::

    edge_path.add_ellipse(center, major_axis, ratio, start_angle=90, end_angle=180, ccw=False)

Args:
    center: center point of ellipse, (x, y)-tuple
    major_axis: vector of major axis as (x, y)-tuple
    ratio: ratio of minor axis to major axis as float
    start_angle: start angle of ellipse in degrees (`end_angle` for a
        clockwise oriented ellipse)
    end_angle: end angle of ellipse in degrees (`start_angle` for a
        clockwise oriented ellipse)
    ccw: ``True`` for counter-clockwise ``False`` for
        clockwise orientation

r'  z!argument 'ratio' has to be <= 1.0)r	   r  r!   r   r   r)  r(  r  r  rg   r   r  r   )rG   r   r)  r(  r  r  r   r*  s           r4   add_ellipseEdgePath.add_ellipse  st    J 3;%%&IJJ-f!*- *% 3i

'"r3   Nc	                F   [        5       n	Ub  [        R                  " U5      U	l        Ub  [        R                  " U5      U	l        Ub  [        U5      U	l        O0[        [        [        U	R                  5      US-   5      5      U	l        Ub  [        U5      U	l        XYl	        [        [        [        U	R                  5      5      5      U	l        [        U5      U	l        Ub  [        U5      U	l        Ub  [        U5      U	l        U R                   R#                  U	5        U	$ )aL  Add a :class:`SplineEdge`.

Args:
    fit_points: points through which the spline must go, at least 3 fit
        points are required. list of (x, y)-tuples
    control_points: affects the shape of the spline, mandatory and
        AutoCAD crashes on invalid data. list of (x, y)-tuples
    knot_values: (knot vector) mandatory and AutoCAD crashes on invalid
        data. list of floats; `ezdxf` provides two tool functions to
        calculate valid knot values: :func:`ezdxf.math.uniform_knot_vector`,
        :func:`ezdxf.math.open_uniform_knot_vector` (default if ``None``)
    weights: weight of control point, not mandatory, list of floats.
    degree: degree of spline (int)
    periodic: 1 for periodic spline, 0 for none periodic spline
    start_tangent: start_tangent as 2d vector, optional
    end_tangent: end_tangent as 2d vector, optional

.. warning::

    Unlike for the spline entity AutoCAD does not calculate the
    necessary `knot_values` for the spline edge itself. On the contrary,
    if the `knot_values` in the spline edge are missing or invalid
    AutoCAD **crashes**.

r)   )r"   r   r  rL  r;  r=  r   r   r>  r9  r@   rg   rationalperiodicstart_tangentend_tangentr  r   )
rG   rL  r;  r=  r>  r9  r  r  r  rB  s
             r4   
add_splineEdgePath.add_splineQ  s    H ! $		* 5F%$(IIn$=F!"!%k!2F!%(V-B-B)CVaZP"F !']FNd3v~~#678h-$#'#6F "!%k!2F

&!r3   c                h    [        XUS9nU R                  UUR                  UR                  5       S9$ )N)rL  r9  method)rL  r;  r=  )r   r  r;  r<  )rG   rL  r9  r  rS  s        r4   add_spline_control_frame!EdgePath.add_spline_control_frame  s@     /!
 !"11  
 	
r3   c                    / U l         g)zDelete all edges.N)r  rF   s    r4   rH   EdgePath.clear  r   r3   c                
   UR                  S[        U R                  5      5        UR                  S[        U R                  5      5        U R                   H  nUR                  U5        M     [        XR                  5        g )Nr   r  )r   r@   rA   r   r  rR   r  rC   )rG   rP   rQ   r.  s       r4   rR   EdgePath.export_dxf  s]    RT%9%9!:;RTZZ1JJDOOI& &y2N2NOr3   c                   [        U R                  5      S:  a  g[        U R                  5      nUR                  S5      nUR	                  U5        U/nUR
                  nU Hl  nUR                  nUR                  U5      U:  a'  [        5       nXXl	        Xxl
        UR	                  U5        XcLa  UR	                  U5        UR
                  nMn     X@l        g)zInsert line-edges between the existing edges if the gap between these edges
are bigger than `len_tol`.

.. versionadded:: 1.4

r*   Nr   )r   r  r  r  r   r~   r{   r   r   r  r  )	rG   len_tolcurrent_edges
first_edger[  rr   r.  ro   	line_edges	            r4   
close_gapsEdgePath.close_gaps  s     tzz?QTZZ("&&q)
Z()3	--	!D//K!!+.8$J	"+ +  +%  &++I " 
r3   )r  rA   rC   r_   rf   )rL   r
   r`   r   rd   )r  r   r  r   r`   r   )r'  r   r   T)r   r   r   re   r  re   r  re   r   rg   r`   r    )r'  r   r'  r   r   T)r   r   r)  r   r(  re   r  re   r  re   r   rg   r`   r!   )NNNNr7   r   NN)rL  Optional[Iterable[UVec]]r;  r  r=  Optional[Iterable[float]]r>  r  r9  r@   r  r@   r  Optional[UVec]r  r  r`   r"   )r7   r   )rL  zIterable[tuple[float, float]]r9  r@   r  rc   r`   r"   rb   )r  re   r`   ra   )r,   r-   r.   r/   r$   r1   r?   r   r   r\   rk   rM   rX   r  r  r  r  r  rH   rR   r  r2   r+   r3   r4   r   r     s     D*
 5 	 	5
"   ,, , 	,
 , , 
,b &  33 3 	3
 3 3 3 
3n 043715-1(,&*9,9 19 /	9
 +9 9 9 &9 $9 
9|  	
1
 
 	

 

Pr3   r   c                      \ rS rSrS r\R                  rS rSS j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	rg
)r   i  c                H    [        SS5      U l        [        SS5      U l        g r  r   r  r  rF   s    r4   r   LineEdge.__init__  s    !QZ
1:r3   c                    gr  r+   rF   s    r4   r\   LineEdge.is_valid  r  r3   c                    U R                   $ rE   )r  rF   s    r4   ro   LineEdge.start_point  s    zzr3   c                    U R                   $ rE   )r  rF   s    r4   rr   LineEdge.end_point  s    xxr3   c                    U " 5       nU H7  nUu  pEUS:X  a  [        U5      Ul        M  US:X  d  M'  [        U5      Ul        M9     U$ )Nr     r  rK   rL   r.  r  r   r   s         r4   rM   LineEdge.load_tags  sE    uCKDrz!%[
;  r3   c                8   UR                  SS5        U R                  tp#nUR                  S[        U5      5        UR                  S[        U5      5        U R                  tp#nUR                  S[        U5      5        UR                  S[        U5      5        g )Nr  r)   r     r     )r   r  re   r  )rG   rP   r  r  r   s        r4   rR   LineEdge.export_dxf  s|    R#::qRq*Rq*88qRq*Rq*r3   c                    UR                  U R                  U5      U l        UR                  U R                  U5      U l        g rE   )transform_2d_vertexr  r  rU   s      r4   rX   LineEdge.transform  s2    ,,TZZC
**488Y?r3   )r  r  Nrf   r   )rL   r
   r`   r   r   rd   )r,   r-   r.   r/   	EDGE_TYPEr#   r9   r?   r   r\   r   ro   rr   rk   rM   rR   rX   r2   r+   r3   r4   r   r     sa    I==D      	+@r3   r   c                      \ rS rSr\R
                  rS rSS jrSS jr	\
SS 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rg)r    i  c                ^    [        SS5      U l        SU l        SU l        SU l        SU l        g )Nr   r'  r   T)r   r   r   r  r  r   rF   s    r4   r   ArcEdge.__init__  s,    3n "% %r3   c                    gr  r+   rF   s    r4   r\   ArcEdge.is_valid  r  r3   c                6    U R                  5       R                  $ rE   )construction_toolro   rF   s    r4   ro   ArcEdge.start_point   s    %%'333r3   c                T    U R                   (       a  U R                  $ U R                  $ rE   r   ro   rr   rF   s    r4   r{   ArcEdge.real_start_point      88###~~r3   c                6    U R                  5       R                  $ rE   )r	  rr   rF   s    r4   rr   ArcEdge.end_point
  s    %%'111r3   c                T    U R                   (       a  U R                  $ U R                  $ rE   r   rr   ro   rF   s    r4   r~   ArcEdge.real_end_point      88>>!r3   c                @   U " 5       nSnSnU HY  nUu  pgUS:X  a  [        U5      Ul        M  US:X  a  Xrl        M-  US:X  a  UnM7  US:X  a  UnMA  US:X  d  MI  [        U5      Ul        M[     UR                  (       a  X2l        XBl        U$ SU-
  Ul        SU-
  Ul        U$ )Nr   r  (   2   3   r  r   )r   r   r   rg   r   r  r  rK   rL   r.  r  r  r  r   r   s           r4   rM   ArcEdge.load_tags  s    uCKDrz"5k#; ( 88$ N   %s{D"U]DNr3   c                
   UR                  SS5        U R                  tp#nU R                  (       a  U R                  nU R                  nOSU R                  -
  nSU R                  -
  nUR                  S[        U5      5        UR                  S[        U5      5        UR                  SU R                  5        UR                  SU5        UR                  SU5        UR                  S	[        U R                  5      5        g )
Nr  r*   r   r  r  r  r  r  r  )r   r   r   r  r  re   r   r@   rG   rP   r  r  r   r  r  s          r4   rR   ArcEdge.export_dxf5  s    R#;;q88$$E..C DNN*E$***CRq*Rq*R-R'R%RTXX/r3   c                   UR                  U R                  U5      U l        UR                  [        U R                  SS5      5      U l        [
        R                  " [        U R                  U R                  5      S5      (       dA  UR                  U R                  5      U l        UR                  U R                  5      U l	        g UR                  U R                  5      U l        U R                  S-   U l	        g )Nr   r   )r   r   transform_lengthr   r   r   r   r   r  r  transform_deg_anglerU   s      r4   rX   ArcEdge.transformG  s    --dkk9E**4Q+BC||t//@%
 
  #66t7G7GHD 44T^^DDN  #66t7G7GHD!--5DNr3   c                j    [        U R                  U R                  U R                  U R                  S9$ )z5Returns ConstructionArc() for the OCS representation.)r   r   r  r  )r   r   r   r  r  rF   s    r4   r	  ArcEdge.construction_tool\  s-    ;;;;((nn	
 	
r3   )r   r   r  r   r  Nr_   rf   r   )rL   r
   r`   r    r   rd   )r`   r   )r,   r-   r.   r/   r#   r:   r?   r  r   r\   r   ro   r{   rr   r~   rk   rM   rR   rX   r	  r2   r+   r3   r4   r    r      s    <<DI 4 4  
 2 2    
  @0$6*
r3   r    c                  >   \ rS rSrS r\R                  rSS jrSS jr	\
SS j5       r\
SS j5       r\
SS j5       r\
SS j5       r\
SS j5       r\R                   SS	 j5       r\
SS
 j5       r\R                   SS j5       r\SS j5       rSS jrSS jrSS jrSrg)r!   if  c                |    [        S5      U l        [        S5      U l        SU l        SU l        SU l        SU l        g )N)r   r   r  r'  r   r   T)r   r   r)  r(  r  r  r   rF   s    r4   r   EllipseEdge.__init__j  s7    :&z*
"% %r3   c                    gr  r+   rF   s    r4   r\   EllipseEdge.is_validu  r  r3   c                J    U R                  5       R                  R                  $ rE   )r	  ro   rQ  rF   s    r4   ro   EllipseEdge.start_pointx  s    %%'33888r3   c                J    U R                  5       R                  R                  $ rE   )r	  rr   rQ  rF   s    r4   rr   EllipseEdge.end_point|  s    %%'11666r3   c                T    U R                   (       a  U R                  $ U R                  $ rE   r  rF   s    r4   r{   EllipseEdge.real_start_point  r  r3   c                T    U R                   (       a  U R                  $ U R                  $ rE   r  rF   s    r4   r~   EllipseEdge.real_end_point  r  r3   c                j    [        U R                  [        R                  " U R                  5      5      $ rE   )r   r(  r   radiansr  rF   s    r4   r3  EllipseEdge.start_param  s"    djj$,,t7G7G*HIIr3   c                b    [         R                  " [        U R                  U5      5      U l        g rE   )r   r  r   r(  r  rG   params     r4   r3  r3    s    <<tzz5(IJr3   c                j    [        U R                  [        R                  " U R                  5      5      $ rE   )r   r(  r   r2  r  rF   s    r4   r4  EllipseEdge.end_param  s     djj$,,t~~*FGGr3   c                b    [         R                  " [        U R                  U5      5      U l        g rE   )r   r  r   r(  r  r5  s     r4   r4  r8    s    nTZZ&GHr3   c                p   U " 5       nSnSnU Hq  nUu  pgUS:X  a  [        U5      Ul        M  US:X  a  [        U5      Ul        M7  US:X  a  Xrl        ME  US:X  a  UnMO  US:X  a  UnMY  US:X  d  Ma  [	        U5      Ul        Ms     UR
                  (       a  X2l        XBl        U$ SU-
  Ul        SU-
  Ul        U$ )	Nr   r  r  r  r  r  r  r   )r   r   r)  r(  rg   r   r  r  r  s           r4   rM   EllipseEdge.load_tags  s    uCKDrz"5k"&u+"
;  88$ N   %s{D"U]DNr3   c                   UR                  SS5        U R                  tp#nUR                  S[        U5      5        UR                  S[        U5      5        U R                  tp#nUR                  S[        U5      5        UR                  S[        U5      5        UR                  SU R                  5        U R
                  (       a  U R                  nU R                  nOSU R                  -
  nSU R                  -
  nUR                  S	U5        UR                  S
U5        UR                  S[        U R
                  5      5        g )Nr  r7   r  r  r  r  r  r   r  r  r  )	r   r   re   r)  r(  r   r  r  r@   r  s          r4   rR   EllipseEdge.export_dxf  s   R#;;qRq*Rq*??qRq*Rq*R,88$$E..C DNN*E$***CR'R%RTXX/r3   c           	         [        [        U R                  5      [        U R                  5      [        SSS5      U R                  U R
                  U R                  S9$ )z9Returns ConstructionEllipse() for the OCS representation.r   r)   )r   r)  	extrusionr(  r3  r4  )r   r   r   r)  r(  r3  r4  rF   s    r4   r	  EllipseEdge.construction_tool  sK    "$DOO,1am** ((nn	
 		
r3   c                   U R                  5       nUR                  R                  nU" UR                  R	                  US95      Ul        U" UR
                  5      Ul        UR                  Ul        UR                  UR                  5        UR                  R                  nU" UR                  5      R                  U l        U" UR
                  5      R                  U l        UR                  U l        UR                  U l        UR                  U l        U R                   S-  U l        U R"                  S-  U l        [$        R&                  " U R"                  S5      (       a  SU l        g g )Nzr   r   )r	  old_ocsto_wcsr   replacer)  old_extrusionr?  rX   mnew_ocsfrom_wcsrQ  r(  r3  r4  r  r  r   r   )rG   rV   rW   r?  
ocs_to_wcs
wcs_to_ocss         r4   rX   EllipseEdge.transform  s   ""$ [[''
ahh...;<!!,,/'' 	
CEE [[))
 *//$Q\\277WW
 ==  ++e3%/<<**"DN +r3   )r   r   r  r4  r)  r(  r  r3  Nr_   rf   r   )r`   re   )r6  re   r`   ra   )rL   r
   r`   r!   r   )r`   r   rd   )r,   r-   r.   r/   r  r#   r;   r?   r   r\   r   ro   rr   r{   r~   r3  setterr4  rk   rM   rR   r	  rX   r2   r+   r3   r4   r!   r!   f  s    ID	 9 9 7 7  
    
 J J K K H H I I ! !F0,
##r3   r!   c                      \ rS rSrS r\R                  rSS jrSS j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
rg)r"   i	  c                    SU l         SU l        SU l        / U l        / U l        / U l        / U l        S U l        S U l        g )Nr7   r   )	r9  r  r  r=  r;  rL  r>  r  r  rF   s    r4   r   SplineEdge.__init__  sE    (**,&($&-1+/r3   c                    [        U R                  5      (       aJ  U R                  S-   n[        U R                  5      nX:  a  gX!-   n[        U R                  5      U:w  a  g g[        U R                  5      S:  a  gg)Nr)   Fr*   T)r   r;  r9  r=  rL  )rG   rJ  r@  required_knot_counts       r4   r\   SplineEdge.is_valid  sz    t""##KK!OE++,E}"'-4##$(;; <  !A%r3   c                     U R                   S   $ r  r;  rF   s    r4   ro   SplineEdge.start_point&  s    ""1%%r3   c                     U R                   S   $ )NrK  rV  rF   s    r4   rr   SplineEdge.end_point*  s    ""2&&r3   c                "   U " 5       nU GH   nUu  pEUS:X  a  XRl         M  US:X  a  XRl        M$  US:X  a  XRl        M2  US:X  a  UR                  R	                  U5        MU  US:X  a  UR
                  R	                  U5        Mx  US:X  a&  UR                  R	                  [        U5      5        M  US:X  a&  UR                  R	                  [        U5      5        M  US:X  a  [        U5      Ul	        M  US	:X  d  M  [        U5      Ul
        GM     U$ )
N^   r  J   r  r  r  r        )r9  r  r  r=  r   r>  r;  r   rL  r  r  r  s         r4   rM   SplineEdge.load_tags.  s    uCKDrz# % %  ''.##E*##**4;7&&tE{3%)%["#'; ' ( r3   c                  ^  SU 4S jjn[        T R                  5      (       aJ  [        T R                  5      [        T R                  5      :X  a  ST l        O[        R
                  " S5      eST l        UR                  nU" SS5        U" S[        T R                  5      5        U" S[        T R                  5      5        U" S	[        T R                  5      5        U" S
[        T R                  5      5        U" S[        T R                  5      5        [        T R                  5      (       a&  T R                   H  nU" S[        U5      5        M     O[        R
                  " S5      e[        R                  " T R                  5      nT R                  (       aj  [        UT R                  5       HO  u  pgU" S[        UR                  5      5        U" S[        UR                   5      5        U" S[        U5      5        MQ     O/U H)  u  pU" S[        U5      5        U" S[        U	5      5        M+     [        T R"                  5      S:  a^  U" U5        U" S[        T R"                  5      5        T R"                   H)  tpn
U" S[        U5      5        U" S[        U	5      5        M+     O'UR$                  [        R&                  :  a	  U" SS5        T R(                  b2  T R(                  tpn
U" S[        U5      5        U" S[        U	5      5        T R*                  b3  T R*                  tpn
U" S[        U5      5        U" S[        U	5      5        g g )Nc                   > [        U 5      S:  a<  TR                  c  U S   U S   -
  Tl        TR                  c  U S   U S   -
  Tl        g g g )Nr)   r   rK  )r   r  r  )r  rG   s    r4   set_required_tangents4SplineEdge.export_dxf.<locals>.set_required_tangentsH  sZ    6{Q%%-)/VAY)>D&##+'-bzF2J'>D$ , r3   r)   zASplineEdge: count of control points and count of weights mismatchr   r  r8   r[  r  r\  _   `   r  z(SplineEdge: missing required knot valuesr  r  r  r  r  r  r]     r^     )r  z
list[Vec2])r   r>  r;  r  r	   r  r   r@   r9  r  r=  re   r   r  rP  r  r  rL  
dxfversionDXF2010r  r  )rG   rP   rc  r  r   cpr  weightr  r  r   s   `          r4   rR   SplineEdge.export_dxfG  s   	? t||4<< C(;(;$<< !)) 
 DM((	"a"c$++&'"c$--()"c$--()"c$**+,"c$--./ t  ))"eEl+ * %%&PQQ YYt**+==!$R!6"eEGGn-"eEGGn-"eFm, "7
 "eAh'"eAh' 
 t!#!"%b#doo./ OOq"eAh'"eAh' , !!U]]2b!)))HA1b%(#b%(#'''HA1b%(#b%(# (r3   c                  ^^ [        UU4S jU R                   5       5      U l        [        UU4S jU R                   5       5      U l        U R                  bB  [	        U R                  5      R                  TS9nTR                  U5      R                  U l        U R                  bC  [	        U R                  5      R                  TS9nTR                  U5      R                  U l        g g )Nc              3  H   >#    U  H  nTR                  UT5      v   M     g 7frE   r   r   rz  rW   rV   s     r4   r   'SplineEdge.transform.<locals>.<genexpr>  s%      #
;NaC##Ay11;N   "c              3  H   >#    U  H  nTR                  UT5      v   M     g 7frE   rp  rq  s     r4   r   rr    s$      
;JaC##Ay11?rs  rB  )	r  r;  rL  r  r   rF  transform_directionrQ  r  )rG   rV   rW   ts    `` r4   rX   SplineEdge.transform  s    " #
;?;N;N#
 
  
;???
 
 )T''(0090=A!$!8!8!;!@!@D'T%%&...;A"66q9>>D (r3   c                p    [        U R                  U R                  U R                  S-   U R                  S9$ )z-Returns BSpline() for the OCS representation.r)   )r;  r<  rJ  r>  )r   r;  r=  r9  r>  rF   s    r4   r	  SplineEdge.construction_tool  s3    ..""++/LL	
 	
r3   )	r;  r9  r  rL  r=  r  r  r  r>  Nr_   rf   r   )rL   r
   r`   r"   r   rd   )r`   r   )r,   r-   r.   r/   r  r#   r<   r?   r   r\   r   ro   rr   rk   rM   rR   rX   r	  r2   r+   r3   r4   r"   r"   	  sg    I??D
0 & & ' '  0B$H?
r3   r"   rs  )r   r&   r   re   r!  r@   r`   r   )r   r
   r`   rB   )rP   r   r  zSequence[str])6
__future__r   typingr   r   r   r   r   ri   enumr   ezdxf.lldxfr	   ezdxf.lldxf.tagsr
   r   
ezdxf.mathr   r   r   r   r   r   r   r   r   r   r   r   r   r   ezdxf.math.transformtoolsr   ezdxf.lldxf.tagwriterr   __all__uniqueIntEnumr$   r#   ABCr&   r%   r   r  r  r  r   r   r   r    r!   r"   r  r+   r3   r4   <module>r     sl   # E E 
    -     37 t||  
 t||  $377 $,377 :` `H BD
*/;>"* *+8*D/' D/N~# ~B+@| +@\s
l s
l`#, `#FW
 W
t hjAr3   