
    h5E                       S SK Jr  S SKJrJrJrJrJ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  S/rSrS	rS
rSr " S S5      r \RB                  S\RD                  S\RF                  S\RH                  S0r%SS jr&g)    )annotations)OptionalIteratorIterableAnyCallable)Self)	Vec3NULLVECOCSBezier3PBezier4PMatrix44has_clockwise_orientationUVecBoundingBox   )CommandLineToMoveToCurve3ToCurve4ToPathElementPathg{Gz?   g-C6?)	_vertices_start_index	_commands_has_sub_paths
_user_datac                  Z   \ rS rSr\r\4S,S jjr\ S-       S.S jj5       r	S/S jr
S0S jrS1S jrS2S jrS3S	 jrS4S
 jrS5S jrS6S jr\r\S7S j5       r\R*                  S8S j5       r\S9S j5       r\R*                  S:S j5       r\S9S j5       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rS>S jrS:S jr S:S jr!S?S jr"S@S jr#SAS jr$SAS jr%SBS  jr&S5S! jr'S5S" jr(S5S# jr)SCSDS$ jjr*SESFS% jjr+SGS& jr,SHS' jr-SIS( jr.SJS) jr/SJS* jr0S+r1g)Kr   )   c                ^    [        U5      /U l        / U l        / U l        SU l        S U l        g )NF)r
   r   r   r   r   r    )selfstarts     A/var/www/html/env/lib/python3.13/site-packages/ezdxf/path/path.py__init__Path.__init__,   s-    &*5k]')(*##    Nc                    U " 5       n[        U5      S:X  a  U$ Xl        X$l        [        U5      Ul        [        S U 5       5      Ul        X4l        U$ )zECreate path instances from a list of vertices and a list of commands.r   c              3  F   #    U  H  o[         R                  :H  v   M     g 7fNr   MOVE_TO.0cmds     r&   	<genexpr>2Path.from_vertices_and_commands.<locals>.<genexpr>C   s     %VW__&<   !)lenr   r   make_vertex_indexr   anyr   r    )clsverticescommand_codes	user_datanew_paths        r&   from_vertices_and_commandsPath.from_vertices_and_commands5   sS     5x=AO%* 1- @"%%V%V"V'r)   c                x    U R                  5       n[        UR                  U R                  5      5      Ul        U$ )zlReturns a new transformed path.

Args:
     m: transformation matrix of type :class:`~ezdxf.math.Matrix44`

)clonelisttransform_verticesr   )r$   mr<   s      r&   	transformPath.transformG   s0     ::<!!"6"6t~~"FGr)   c                4    [        U R                  5       5      $ )z_Returns the bounding box of all control vertices as
:class:`~ezdxf.math.BoundingBox` instance.
)r   control_verticesr$   s    r&   bbox	Path.bboxR   s     400233r)   c                ,    [        U R                  5      $ )zReturns count of path elements.)r5   r   rH   s    r&   __len__Path.__len__X   s    4>>""r)   c                   [        U[        5      (       a  [        S5      eU R                  U   nU R                  U   nU R
                  nU[        R                  :X  a  [        XC   5      $ U[        R                  :X  a  [        XC   5      $ U[        R                  :X  a  [        XCS-      XC   5      $ U[        R                  :X  a  [        XCS-      XC   XCS-      5      $ [        SU 35      e)zBReturns the path element at given index, slicing is not supported.zslicing not supportedr      Invalid command: )
isinstanceslice	TypeErrorr   r   r   r   r.   r   LINE_TOr   	CURVE3_TOr   	CURVE4_TOr   
ValueError)r$   itemr1   indexr9   s        r&   __getitem__Path.__getitem__\   s    dE""344nnT"!!$'>>'//!(/**'//!(/**'###HQY/AA'##### 
 ,SE233r)   c                T   ^  U 4S j[        [        T R                  5      5       5       $ )Nc              3  .   >#    U  H
  nTU   v   M     g 7fr,    )r0   ir$   s     r&   r2    Path.__iter__.<locals>.<genexpr>r   s     <!;AQ!;s   )ranger5   r   rH   s   `r&   __iter__Path.__iter__q   s    <s4>>':!;<<r)   c                4    [        U R                  5       5      $ )z"Returns all path elements as list.)rA   rb   rH   s    r&   commandsPath.commandst   s    DMMO$$r)   c                    U R                  5       nU R                  R                  5       Ul        U R                  U5        U$ )z?Returns a new copy of :class:`Path` with shared immutable data.)	__class__r   copy_copy_properties)r$   ri   s     r&   __copy__Path.__copy__x   s5    ~~,,.d#r)   c                    [        U R                  5      [        UR                  5      :X  d   eU R                  R                  5       Ul        U R                  R                  5       Ul        U R
                  Ul        U R                  Ul        g r,   )r5   r   r   ri   r   r   r    )r$   r@   s     r&   rj   Path._copy_properties   sg    4>>"c%//&::::..--/!..335#22??r)   c                    U R                   $ )zAttach arbitrary user data to a :class:`Path` object.
The user data is copied by reference, no deep copy is applied
therefore a mutable state is shared between copies.
r    rH   s    r&   r;   Path.user_data   s     r)   c                    Xl         g r,   rp   )r$   datas     r&   r;   rq      s    r)   c                     U R                   S   $ )zS:class:`Path` start point, resetting the start point of an empty
path is possible.
r   r   rH   s    r&   r%   
Path.start   s    
 ~~a  r)   c                l    U R                   (       a  [        S5      e[        U5      U R                  S'   g )NzRequires an empty path.r   )r   rW   r
   r   r$   locations     r&   r%   rv      s'    >>677 $XDNN1r)   c                     U R                   S   $ )z:class:`Path` end point.ru   rH   s    r&   endPath.end   s     ~~b!!r)   c                R    U R                   (       a  [        U R                  5      $ / $ )z6Yields all path control vertices in consecutive order.)r   rA   r   rH   s    r&   rG   Path.control_vertices   s    >>''	r)   c                ,    [        U R                  5      $ )zInternal API.)rA   r   rH   s    r&   r:   Path.command_codes   s    DNN##r)   c                h    U R                   n[        U5      S:  a  US   R                  US   5      $ g)z>Returns ``True`` if the start point is close to the end point.r   r   r{   F)r   r5   isclose)r$   r9   s     r&   	is_closedPath.is_closed   s5     >>x=1A;&&x|44r)   c                <    [         R                  U R                  ;   $ )z3Returns ``True`` if the path has any line segments.)r   rT   r   rH   s    r&   	has_linesPath.has_lines   s     $..00r)   c                    [         R                  U R                  ;   =(       d    [         R                  U R                  ;   $ )z4Returns ``True`` if the path has any curve segments.)r   rV   r   rU   rH   s    r&   
has_curvesPath.has_curves   s/     /V73D3D3V	
r)   c                    U R                   $ )z_Returns ``True`` if the path is a :term:`Multi-Path` object that
contains multiple sub-paths.

)r   rH   s    r&   has_sub_pathsPath.has_sub_paths   s     """r)   c                d    U R                   (       a  [        S5      e[        U R                  5      $ )zReturns ``True`` if 2D path has clockwise orientation, ignores
z-axis of all control vertices.

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

z/can't detect orientation of a multi-path object)r   rS   r   r   rH   s    r&   r   Path.has_clockwise_orientation   s(     MNN(88r)   c                   UR                   nU[        R                  :X  a  U R                  UR                  5        gU[        R
                  :X  a  U R                  UR                  5        gU[        R                  :X  a'  U R                  UR                  UR                  5        gU[        R                  :X  a2  U R                  UR                  UR                  UR                  5        g[        SU 35      e)zAppend a single path element.rP   N)typer   rT   line_tor|   r.   move_torU   	curve3_toctrlrV   	curve4_toctrl1ctrl2rW   )r$   r1   ts      r&   append_path_elementPath.append_path_element   s    HHLL!'//!LL!'###NN377CHH-'###NN377CIIsyy90455r)   c                    U R                   R                  [        R                  5        U R                  R                  [        U R                  5      5        U R                  R                  [        U5      5        g)z4Add a line from actual path end point to `location`.N)r   appendr   rT   r   r5   r   r
   rx   s     r&   r   Path.line_to   sK    goo.  T^^!45d8n-r)   c                   U R                   nU(       d  [        U5      U R                  S'   gSU l        US   [        R
                  :X  aD  UR                  5         U R                  R                  5         U R                  R                  5         UR                  [        R
                  5        U R                  R                  [        U R                  5      5        U R                  R                  [        U5      5        g)a+  Start a new sub-path at `location`. This creates a gap between the
current end-point and the start-point of the new sub-path. This converts
the instance into a :term:`Multi-Path` object.

If the :meth:`move_to` command is the first command, the start point of
the path will be reset to `location`.

r   NTr{   )
r   r
   r   r   r   r.   popr   r   r5   )r$   ry   re   s      r&   r   Path.move_to   s     >> $XDNN1"B<7??*LLNNN !!#(  T^^!45d8n-r)   c                   U R                   R                  [        R                  5        U R                  R                  [        U R                  5      5        U R                  R                  [        U5      [        U5      45        g)u   Add a quadratic Bèzier-curve from actual path end point to
`location`, `ctrl` is the control point for the quadratic Bèzier-curve.
N)	r   r   r   rU   r   r5   r   extendr
   )r$   ry   r   s      r&   r   Path.curve3_to  sX     	g//0  T^^!45tDz4>:;r)   c                $   U R                   R                  [        R                  5        U R                  R                  [        U R                  5      5        U R                  R                  [        U5      [        U5      [        U5      45        g)u   Add a cubic Bèzier-curve from actual path end point to `location`,
`ctrl1` and `ctrl2` are the control points for the cubic Bèzier-curve.
N)	r   r   r   rV   r   r5   r   r   r
   )r$   ry   r   r   s       r&   r   Path.curve4_to  s^     	g//0  T^^!45tE{DKhHIr)   c                ^    U R                   (       d  U R                  U R                  5        gg)zKClose path by adding a line segment from the end point to the start
point.
N)r   r   r%   rH   s    r&   close
Path.close  s      ~~LL$ r)   c                    U R                   (       aM  U R                  5       nUc   S5       eU R                  R                  U5      (       d  U R	                  U5        ggU R                  5         g)zClose last sub-path by adding a line segment from the end point to
the start point of the last sub-path. Behaves like :meth:`close` for
:term:`Single-Path` instances.
Nz2internal error: required MOVE_TO command not found)r   _start_of_last_sub_pathr|   r   r   r   )r$   start_points     r&   close_sub_pathPath.close_sub_path  sd    
 668K'DCD'88##K00[) 1 JJLr)   c                    [         R                  nU R                  n[        U5      S-
  nUS:  a1  X#   U:X  a  U R                  U R
                  U      $ US-  nUS:  a  M1  g )Nr   r   )r   r.   r   r5   r   r   )r$   r   re   rY   s       r&   r   Path._start_of_last_sub_path,  sd    //>>H!ai')~~d&7&7&>??QJE ai r)   c                   U R                  5       nUR                  (       d  U$ UR                  S   [        R                  :X  ao  UR                  R	                  5         UR
                  R	                  5         UR                  R	                  5         [        S UR                   5       5      Ul        UR                  R                  5         UR
                  R                  5         [        UR                  5      Ul        U$ )zJReturns a new :class:`Path` with reversed commands and control
vertices.

r{   c              3  F   #    U  H  o[         R                  :H  v   M     g 7fr,   r-   r/   s     r&   r2    Path.reversed.<locals>.<genexpr>G  s      &2@3w&.r4   )r@   r   r   r.   r   r   r   r7   r   reverser6   )r$   paths     r&   reversedPath.reversed7  s    
 zz|~~K>>"0
 NN NN !!#"% &26..& #D 	  -dnn=r)   c                l    U R                  5       (       a  U R                  5       $ U R                  5       $ )zReturns new :class:`Path` in clockwise orientation.

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

)r   r@   r   rH   s    r&   	clockwisePath.clockwiseO  s+     ))++::<==?"r)   c                l    U R                  5       (       a  U R                  5       $ U R                  5       $ )zReturns new :class:`Path` in counter-clockwise orientation.

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

)r   r   r@   rH   s    r&   counter_clockwisePath.counter_clockwise[  s+     ))++==?"::<r)   c                F   ^ SU4S jjnSU4S jjnU R                  X#5      $ )u)  Approximate path by vertices, `segments` is the count of
approximation segments for each Bézier curve.

Does not yield any vertices for empty paths, where only a start point
is present!

Approximation of :term:`Multi-Path` objects is possible, but gaps are
indistinguishable from line segments.

c                N   > [        [        XU45      R                  T5      5      $ r,   )iterr   approximate)p0p1p2segmentss      r&   curve3 Path.approximate.<locals>.curve3t  s"    "".::8DEEr)   c                N   > [        [        XX#45      R                  T5      5      $ r,   )r   r   r   )r   r   r   p3r   s       r&   curve4 Path.approximate.<locals>.curve4w  s#    ""!12>>xHIIr)   r   r
   r   r
   r   r
   returnIterator[Vec3]
r   r
   r   r
   r   r
   r   r
   r   r   _approximate)r$   r   r   r   s    `  r&   r   Path.approximateh  s"    	F	J   00r)   c                L   ^^ SUU4S jjnSUU4S jjnU R                  X45      $ )u  Approximate path by vertices and use adaptive recursive flattening
to approximate Bèzier curves. The argument `segments` is the
minimum count of approximation segments for each curve, if the distance
from the center of the approximation segment to the curve is bigger than
`distance` the segment will be subdivided.

Does not yield any vertices for empty paths, where only a start point
is present!

Flattening of :term:`Multi-Path` objects is possible, but gaps are
indistinguishable from line segments.

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 Bézier curve

c                r   > TS:X  a  [        S5      e[        [        XU45      R                  TT5      5      $ Ng        zinvalid max distance: 0.0)rW   r   r   
flattening)r   r   r   distancer   s      r&   r   Path.flattening.<locals>.curve3  s7    3 #<>>"".99(HMNNr)   c                r   > TS:X  a  [        S5      e[        [        XX#45      R                  TT5      5      $ r   )rW   r   r   r   )r   r   r   r   r   r   s       r&   r   Path.flattening.<locals>.curve4  s8    3 #<>>""!12==hQRRr)   r   r   r   )r$   r   r   r   r   s    ``  r&   r   Path.flattening|  s.    *	O 	O
	S 	S
   00r)   c              #  <  #    U R                   (       d  g U R                  S   nUv   U R                  n[        U R                  U R                   5       H  u  pVU[        R
                  :X  d  U[        R                  :X  a	  XE   nUv   OU[        R                  :X  a(  XEUS-    u  pU" X8U5      n	[        U	5        U	 S h  vN   OKU[        R                  :X  a)  XEUS-    u  pnU" X:X5      n	[        U	5        U	 S h  vN   O[        SU 35      eUnM     g  NW N7f)Nr   rO      rP   )r   r   zipr   r   rT   r.   rU   nextrV   rW   )r$   r   r   r%   r9   sir1   end_locationr   ptsr   r   s               r&   r   Path._approximate  s    ~~q!>>4,,dnn=GBgoo%)?'|"")))%-26%:"U,7S	)))-526-B*lU5?S	 #4SE!:;; E! > 
 s$   B>D D<D=D>DDc                R   ^^ [        UU4S jU R                   5       5      U l        g)z;Transform path from given `ocs` to WCS coordinates inplace.c              3  r   >#    U  H,  nTR                  UR                  [        T5      S 95      v   M.     g7f))zN)to_wcsreplacefloat)r0   v	elevationocss     r&   r2   Path.to_wcs.<locals>.<genexpr>  s0      
?M!CJJqyy5#3y455~s   47N)rA   r   )r$   r   r   s    ``r&   r   Path.to_wcs  s      
?C~~
 
r)   c              #  X  #    U R                  U R                  S9nU R                  Ul        [        R                  nU R                  5        HT  nUR                  U:X  a0  Uv   U R                  UR                  S9nU R                  Ul        MC  UR                  U5        MV     Uv   g7f)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`.

)r%   N)	rh   r%   r    r   r.   re   r   r|   r   )r$   r   r   r1   s       r&   	sub_pathsPath.sub_paths  s      ~~DJJ~/////==?Cxx7"
~~CGG~4"&//((- # 
s   B(B*c                    [        U5      (       aD  U R                  UR                  5        UR                  5        H  nU R	                  U5        M     gg)zExtend the path by another path. The source path is automatically a
:term:`Multi-Path` object, even if the previous end point matches the
start point of the appended path. Ignores paths without any commands
(empty paths).

N)r5   r   r%   re   r   r$   r   r1   s      r&   extend_multi_pathPath.extend_multi_path  s@     t99LL$}}((- ' r)   c                D   [        U5      S:X  a  gU R                  (       aF  U R                  R                  UR                  5      (       d  U R                  UR                  5        OUR                  U l        UR                  5        H  nU R                  U5        M     g)zAppend another path to this path. Adds a :code:`self.line_to(path.start)`
if the end of this path != the start of appended path.

r   N)r5   r   r|   r   r%   r   re   r   r   s      r&   append_pathPath.append_path  sl    
 t9>>>88##DJJ//TZZ(DJ==?C$$S) #r)   )r   r   r   r    r   r%   )r%   r   r,   )r9   
list[Vec3]r:   zlist[Command]r;   r   r   r	   )rC   r   r   r	   )r   r   )r   int)r   r   )r   zIterator[PathElement])r   zlist[PathElement])r   r	   )r@   r   r   None)r   r   )rs   r   )r   r
   )ry   r   r   r   )r   r   )r   	list[int])r   bool)r1   r   r   r   )ry   r   r   r   r   r   )ry   r   r   r   r   r   r   r   )r   r   )r   zOptional[Vec3])   )r   r   r   r   )r   )r   r   r   r   r   r   )r   r   r   r   r   r   )r   r   r   r   r   r   )r   zIterator[Self])r   r   r   r   )2__name__
__module____qualname____firstlineno___slots	__slots__r   r'   classmethodr=   rD   rI   rL   rZ   rb   re   rk   rj   r@   propertyr;   setterr%   r|   rG   r:   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   __static_attributes__r^   r)   r&   r   r   )   s   I%, $ RV!2?LO	 "	4#4*=%+ E    ! ! \\/ / " "$   1 1 
 
 # #
96...<J%	0
# 1(1B!4
&
.*r)   rO   r   c                \    [         nSn/ nU  H  nUR                  U5        X!U   -  nM     U$ )Nr   )CMD_SIZEr   )r:   cmd_sizer%   start_indexcodes        r&   r6   r6     s=    HEK5!$  r)   N)r:   zIterable[Command]r   r   )'
__future__r   typingr   r   r   r   r   typing_extensionsr	   
ezdxf.mathr
   r   r   r   r   r   r   r   r   re   r   r   r   r   r   r   __all__MAX_DISTANCEMIN_SEGMENTSG1_TOLr  r   r.   rT   rU   rV   r  r6   r^   r)   r&   <module>r     s    #  #
 
 
  (		S@* @*H OOQOOQqq	r)   