
    hTH                       % S SK Jr  S SKJrJrJr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  S SKJrJr  S SKJr  S S	KJrJrJrJrJrJ r   S S
K!J"r"J#r#J$r$J%r%  S SK&J'r'  S SK(J)r)J*r*  S SK+J,r,  S SK-J.r.  S SK/J0r0  S SK1J2r2  SSK3J4r4J5r5  SSK6J7r7J8r8  SSK9J:r:  SSKJ;r;  \(       a  S SK<J=r=J>r>J?r?J@r@  S SKAJBrB  S SKCJDrD  SS/rE\\F\F\F\F\F4   rGS\HS'   \I" S5      rJSrKSrL\" S \" S!\R                  S"S#9\" S$S S%S&9\" S'S S%S&9\" S(S S)9\" S*S S%S&9\" S+\R                  \S%\R                  \S,9S-.5      rP\ " \P5      rQ\: " S. S\75      5       rR " S/ S0\,5      rSS3S4S1 jjrTS3S5S2 jjrUg)6    )annotations)TYPE_CHECKINGTupleSequenceIterableUnionIteratorOptional)	TypeAliasSelfN)contextmanager)Vec3Matrix44Z_AXIS)OCSTransformNonUniformScalingError)	validator)DXFAttrDXFAttributesDefSubclassXTypeRETURN_DEFAULTgroup_code_mapping)SUBCLASS_MARKERDXF2000LWPOLYLINE_CLOSEDDXFStructureError)Tags)DXFTag	DXFVertex)VertexArray)virtual_lwpolyline_entitiesexplode_entity)EntityQuery   )
base_classSubclassProcessor)
DXFGraphicacdb_entity)register_entity)default_copy)DXFNamespaceLineArc	DXFEntity)AbstractTagWriter)
BaseLayout
LWPolylineFORMAT_CODESr   LWPointTypexysebvxyseb)
      (   )   *   AcDbPolylineZ   __len__)xtypegetter&   T)defaultoptional'   F   rC   +      )r@   rC   rD   r   fixer)count	elevation	thicknessflagsconst_width	extrusionc                  &  ^  \ rS rSrSrSr\" \\\	5      r
\rU 4S jr\4S#S jjr S$   S%U 4S jjjrS&S jrS'S jrS(U 4S	 jjr\S)S
 j5       r\R,                  S*S j5       r\S)S j5       rS+S,S jjr\S)S j5       r\S)S j5       rS-S jrS.S jrS/S jrS0S jrS1S jrS2S jr S3S jr!S3S jr"\#4S4S jjr$\#4       S5S jjr%\#4     S6S jjr&\'\#4S7S jj5       r(\#4S8S jjr)\#4     S6S jjr*S9S jr+S:S jr,S;S  jr-S$S<S! jjr.S"r/U =r0$ )=r3   ^   zDXF LWPOLYLINE entity
LWPOLYLINEc                @   > [         TU ]  5         [        5       U l        g N)super__init__LWPolylinePointslwpoints)self	__class__s    K/var/www/html/env/lib/python3.13/site-packages/ezdxf/entities/lwpolyline.pyrW   LWPolyline.__init__f   s    (*    c                |    [        U[        5      (       d   e[        R                  " U R                  5      Ul        g)zCopy lwpoints.N)
isinstancer3   copydeepcopyrY   )rZ   entitycopy_strategys      r\   	copy_dataLWPolyline.copy_dataj   s)    &*------6r^   c                   > [         TU ]  U5      nU(       aZ  UR                  S5      nU(       a)  U R                  U5      nUR	                  U[
        USS9  U$ [        SUR                   S35      eU$ )zt
Adds subclass processing for AcDbPolyline, requires previous base class
and AcDbEntity processing by parent class.
   T)subclassrecoverz/missing 'AcDbPolyline' subclass in LWPOLYLINE(#))rV   load_dxf_attribssubclass_by_indexload_verticesfast_load_dxfattribsacdb_lwpolyline_group_codesr   handle)rZ   	processordxftagsr[   s       r\   rl   LWPolyline.load_dxf_attribso   s     g&y1..q1D))$/../! 	 /  
 (Ecjj\QRS  
r^   c                @    [         R                  U5      u  U l        nU$ rU   )rX   	from_tagsrY   )rZ   rt   unprocessed_tagss      r\   rn   LWPolyline.load_vertices   s     *:*D*DT*J''r^   c                2    [        U R                  5      S:  $ Nr   lenrY   )rZ   	tagwriters     r\   preprocess_exportLWPolyline.preprocess_export   s     4==!A%%r^   c                D  > [         TU ]  U5        UR                  [        [        R
                  5        U R                  R                  U/ SQ5        UR                  [        U R                  R                  5       5      5        U R                  R                  US5        g)z(Export entity specific data as DXF tags.)rK   rN   rO   rL   rM   rP   N)rV   export_entity
write_tag2r   acdb_lwpolylinenamers   export_dxf_attribs
write_tagsr   rY   dxftags)rZ   r~   r[   s     r\   r   LWPolyline.export_entity   st    i(_o.B.BC##G	
 	T$--"7"7"9:;##I{;r^   c                ,    U R                  [        5      $ )zxGet/set closed state of polyline.  A closed polyline has a connection
segment from the last vertex to the first vertex.
get_flag_stater   rZ   s    r\   closedLWPolyline.closed       
 ""#455r^   c                0    U R                  [        U5        g rU   )set_flag_stater   )rZ   statuss     r\   r   r      s    -v6r^   c                ,    U R                  [        5      $ )zMGet closed state of LWPOLYLINE.
Compatibility interface to :class:`Polyline`
r   r   s    r\   	is_closedLWPolyline.is_closed   r   r^   c                    Xl         g)zMSet closed state of LWPOLYLINE.
Compatibility interface to :class:`Polyline`
N)r   )rZ   states     r\   closeLWPolyline.close   s	     r^   c                :    [        S U R                   5       5      $ )z2Returns ``True`` if LWPOLYLINE has an arc segment.c              3  @   #    U  H  u  pp4n[        U5      v   M     g 7frU   )bool.0xysebs         r\   	<genexpr>%LWPolyline.has_arc.<locals>.<genexpr>   s     >}qQ1477s   )anyrY   r   s    r\   has_arcLWPolyline.has_arc   s     >>>>r^   c                    U R                   R                  S5      (       a  U R                   R                  S:g  $ [        S U R                   5       5      $ )zqReturns ``True`` if LWPOLYLINE has any segment with width attributes
or the DXF attribute const_width is not 0.

rO           c              3  >   #    U  H  u  pp4oS=(       d    Uv   M     g 7frU    r   s         r\   r   'LWPolyline.has_width.<locals>.<genexpr>   s     ?aAFFs   )rs   hasattrrO   r   rY   r   s    r\   	has_widthLWPolyline.has_width   sE     88M** 88''3..????r^   c                ,    [        U R                  5      $ )z!Returns count of polyline points.r|   r   s    r\   r?   LWPolyline.__len__   s    4==!!r^   c                ,    [        U R                  5      $ )zAReturns iterable of tuples (x, y, start_width, end_width, bulge).)iterrY   r   s    r\   __iter__LWPolyline.__iter__   s    DMM""r^   c                     U R                   U   $ )zReturns point at position `index` as (x, y, start_width, end_width,
bulge) tuple. start_width, end_width and bulge is 0 if not present,
supports extended slicing. Point format is fixed as "xyseb".

All coordinates in :ref:`OCS`.

rY   rZ   indexs     r\   __getitem__LWPolyline.__getitem__   s     }}U##r^   c                4    [        U5      U R                  U'   g)a  
Set point at position `index` as (x, y, [start_width, [end_width,
[bulge]]]) tuple. If start_width or end_width is 0 or left off the
default width value is used. If the bulge value is left off, bulge is 0
by default (straight line).
Does NOT support extend slicing. Point format is fixed as "xyseb".

All coordinates in :ref:`OCS`.

Args:
    index: point index
    value: point value as (x, y, [start_width, [end_width, [bulge]]]) tuple

N)compile_arrayrY   )rZ   r   values      r\   __setitem__LWPolyline.__setitem__   s      -U3er^   c                    U R                   U	 g)z<Delete point at position `index`, supports extended slicing.Nr   r   s     r\   __delitem__LWPolyline.__delitem__   s    MM% r^   c              #  6   #    U  H  nUS   US   4v   M     g7f)zv
Returns iterable of all polyline points as (x, y) tuples in :ref:`OCS`
(:attr:`dxf.elevation` is the z-axis value).

r   r&   Nr   )rZ   points     r\   verticesLWPolyline.vertices   s$      E(E!H$$ s   c              #     #    U R                  5       nU R                  SSS9nU R                  5        H"  u  p4UR                  [	        X4U5      5      v   M$     g7f)zGReturns iterable of all polyline points as Vec3(x, y, z) in :ref:`WCS`.rL   r   rG   N)ocsget_dxf_attribr   to_wcsr   )rZ   r   rL   r   r   s        r\   vertices_in_wcsLWPolyline.vertices_in_wcs   sM     hhj''S'A	MMODA**T!	233 $s   AAc              #  z   #    U R                  SSS9nU R                  5        H  u  p#[        X#U5      v   M     g7f)zGReturns iterable of all polyline points as Vec3(x, y, z) in :ref:`OCS`.rL   r   rG   N)r   r   r   )rZ   rL   r   r   s       r\   vertices_in_ocsLWPolyline.vertices_in_ocs   s9     ''S'A	MMODAqY'' $s   9;c                6    U R                   R                  XS9  g)zAppend `point` to polyline, `format` specifies a user defined
point format.

All coordinates in :ref:`OCS`.

Args:
    point: (x, y, [start_width, [end_width, [bulge]]]) tuple
    format: format string, default is "xyseb", see: `format codes`_

formatNrY   append)rZ   r   r   s      r\   r   LWPolyline.append  s     	U2r^   c                L    [        X#S9nU R                  R                  X5        g)zInsert new point in front of positions `pos`, `format` specifies a
user defined point format.

All coordinates in :ref:`OCS`.

Args:
    pos: insert position
    point: point data
    format: format string, default is "xyseb", see: `format codes`_

r   N)r   rY   insert)rZ   posr   r   datas        r\   r   LWPolyline.insert  s      U2S'r^   c                H    U H  nU R                   R                  X2S9  M     g)a   
Append new `points` to polyline, `format` specifies a user defined
point format.

All coordinates in :ref:`OCS`.

Args:
    points: iterable of point, point is (x, y, [start_width, [end_width,
        [bulge]]]) tuple
    format: format string, default is "xyseb", see: `format codes`_

r   Nr   )rZ   pointsr   r   s       r\   append_pointsLWPolyline.append_points  s#     EMM   6 r^   c              #  P   #    U R                  US9nUv   U R                  X!S9  g7f)zContext manager for polyline points. Returns a standard Python list
of points, according to the format string.

All coordinates in :ref:`OCS`.

Args:
    format: format string, see `format codes`_

r   N)
get_points
set_points)rZ   r   r   s      r\   r   LWPolyline.points1  s*      /.s   $&c                T    U R                    Vs/ s H  n[        X!S9PM     sn$ s  snf )zReturns all points as list of tuples, format specifies a user
defined point format.

All points in :ref:`OCS` as (x, y) tuples (:attr:`dxf.elevation` is
the z-axis value).

Args:
    format: format string, default is "xyseb", see `format codes`_

r   )rY   format_point)rZ   r   ps      r\   r   LWPolyline.get_points@  s%     9=F1Q.FFFs   %c                V    U R                   R                  5         U R                  XS9  g)zRemove all points and append new `points`.

All coordinates in :ref:`OCS`.

Args:
    points: iterable of point, point is (x, y, [start_width, [end_width,
        [bulge]]]) tuple
    format: format string, default is "xyseb", see `format codes`_

r   N)rY   clearr   )rZ   r   r   s      r\   r   LWPolyline.set_pointsM  s%     	61r^   c                8    U R                   R                  5         g)zRemove all points.N)rY   r   r   s    r\   r   LWPolyline.clear]  s    r^   c                V  ^ U R                   n[        U R                   R                  U5      mTR                  (       d  U R                  (       a  [        S5      e[        U4S jU R                  5        5       5      n/ n[        X0R                  5       HV  u  pVUu    pxpTR                  U5      nTR                  U	5      n	UR                  UR                  UR                  XU
45        MX     U R                  U5        U(       a  US   R                  Ul        UR#                  S5      (       a   TR                  UR$                  5      Ul        UR#                  S5      (       a   TR'                  UR(                  5      Ul        TR*                  Ul        U R-                  U5        U $ )aZ  Transform the LWPOLYLINE entity by transformation matrix `m` inplace.

A non-uniform scaling is not supported if the entity contains circular
arc segments (bulges).

Args:
    m: transformation :class:`~ezdxf.math.Matrix44`

Raises:
    NonUniformScalingError: for non-uniform scaling of entity containing
        circular arc segments (bulges)

zHLWPOLYLINE containing arcs (bulges) does not support non uniform scalingc              3  F   >#    U  H  nTR                  U5      v   M     g 7frU   )transform_vertex)r   vr   s     r\   r   'LWPolyline.transform.<locals>.<genexpr>w  s!     P9OA,,Q//9Os   !r   rO   rM   )rs   r   rP   scale_uniformr   r   listr   ziprY   transform_widthr   r   r   r   zrL   r   rO   transform_thicknessrM   new_extrusionpost_transform)rZ   mrs   r   rY   r   r   _start_width	end_widthbulger   s              @r\   	transformLWPolyline.transforma  sM    hh488--q1  T\\(Z 
 P9M9M9OPP--0DA23/Aqy--k:K++I6IOOQSS!##{uEF 1 	! $QKMMCM;;}%%!11#//BCO;;{##33CMMBCM))Ar^   c              #  Z   #    [        U 5       H  nUR                  U 5        Uv   M     g7f)zYields the graphical representation of LWPOLYLINE as virtual DXF
primitives (LINE or ARC).

These virtual entities are located at the original location, but are not
stored in the entity database, have no handle and are not assigned to
any layout.

N)r"   set_source_of_copy)rZ   r   s     r\   virtual_entitiesLWPolyline.virtual_entities  s)      -T2A  &G 3s   )+c                    [        X5      $ )a  Explode the LWPOLYLINE entity as DXF primitives (LINE or ARC) into
the target layout, if the target layout is ``None``, the target layout
is the layout of the source entity. This method destroys the source entity.

Returns an :class:`~ezdxf.query.EntityQuery` container referencing all DXF
primitives.

Args:
    target_layout: target layout for the DXF primitives, ``None`` for
        same layout as the source entity.

r#   )rZ   target_layouts     r\   explodeLWPolyline.explode  s     d22r^   )r   rY   )rc   r   returnNonerU   )rr   zOptional[SubclassProcessor]r  r-   )rt   r   r  r   )r~   r1   r  r   )r~   r1   r  r  )r  r   )r   r   r  r  )T)r   r   r  r  )r  int)r  zIterator[LWPointType])r   r  r  r5   )r   r  r   Sequence[float]r  r  )r   r  r  r  )r  zIterator[tuple[float, float]])r  zIterator[Vec3]r   r  r   strr  r  )r   r  r   r  r   r  r  r  )r   zIterable[Sequence[float]]r   r  r  r  )r   r  r  zIterator[list[Sequence[float]]])r   r  r  zlist[Sequence[float]])r  r  )r   r   r  r3   )r  zIterator[Union[Line, Arc]])r  zOptional[BaseLayout]r  r%   )1__name__
__module____qualname____firstlineno____doc__DXFTYPEr   r'   r*   r   
DXFATTRIBSr   MIN_DXF_VERSION_FOR_EXPORTrW   r,   re   rl   rn   r   r   propertyr   setterr   r   r   r   r?   r   r   r   r   r   r   r   DEFAULT_FORMATr   r   r   r   r   r   r   r   r  r  r	  __static_attributes____classcell__r[   s   @r\   r3   r3   ^   s   Gz;HJ!(+ 5A 7 8<4	 0 &
	< 6 6 ]]7 7 6 6 ? ? 	@ 	@"#$4"!%4( <J 3 ?M((.(8;(	($ @N7/79<7	7$ #1 / / (6 G @N2/29<2	2 ,\3 3r^   c                  h   ^  \ rS rSrSrSrSrSrSrSr	\
SS j5       r\4SU 4S	 jjjrSS
 jrSrU =r$ )rX   i  )valuesr8   r:   r;   r<      c                  ^ ^ SUU 4S jjn[        5       n/ nSn0 mU H  nUR                  [        ;   aa  UR                  S:X  a6  Ub  UR                  U" U5      5        [	        UR
                  SS 5      n0 mM]  UR
                  TUR                  '   Mx  UR                  U5        M     Ub  UR                  U" U5      5        T " US9U4$ )zSetup point array from tags.c                
  > U R                  TR                  TR                  S5      5        U R                  TR                  TR                  S5      5        U R                  TR                  TR                  S5      5        U $ r{   )r   getSTART_WIDTH_CODEEND_WIDTH_CODE
BULGE_CODE)r   attribsclss    r\   build_vertex0LWPolylinePoints.from_tags.<locals>.build_vertex  s]    LLS%9%91=>LLS%7%7;<LLS^^Q78Lr^   Nr8   r   rh   )r   )r   list[float]r  r,  )r   codeLWPOINTCODESr   r   r   )r)  rt   r*  rx   r   r   tagr(  s   `      @r\   rw   LWPolylinePoints.from_tags  s    	 	  6)+$(#%Cxx<'88r>( U(;< 1Q0E G(+		GCHH% '',  OOL/0!#333r^   c                2   > [         TU ]  [        XS95        g )Nr   )rV   r   r   )rZ   r   r   r[   s      r\   r   LWPolylinePoints.append  s    }U:;r^   c              #    #    U  H  nUu  p#pEn[        U R                  X#45      v   U(       d  U(       a0  [        U R                  U5      v   [        U R                  U5      v   U(       d  Mi  [        U R
                  U5      v   M     g 7frU   )r    VERTEX_CODEr   r%  r&  r'  )rZ   r   r   r   r   r   r   s          r\   r   LWPolylinePoints.dxftags  ss     E27/A+%D,,qf55i T22K@@T00)<<uT__e44 s   A(B.Br   )rt   zIterable[DXFTag]r  ztuple[Self, Tags]r  )r  zIterator[DXFTag])r  r  r  r  	__slots__r4  r%  r&  r'  VERTEX_SIZEclassmethodrw   r  r   r   r  r  r  s   @r\   rX   rX     sN    IKNJK4 4: <J < <
5 
5r^   rX   c                p   ^ U u  p#pEnX#4n[        5       m[        U4S jUR                  5        5       5      $ )a  Reformat point components.

Format codes:

    - ``x`` = x-coordinate
    - ``y`` = y-coordinate
    - ``s`` = start width
    - ``e`` = end width
    - ``b`` = bulge value
    - ``v`` = (x, y) as tuple

Args:
    point: list or tuple of (x, y, start_width, end_width, bulge)
    format: format string, default is "xyseb"

Returns:
    Sequence[float]: tuple of selected components

c              3  D   >#    U  H  o[         ;   d  M  TU   v   M     g 7frU   )r4   )r   r-  varss     r\   r   format_point.<locals>.<genexpr>  s     O,:Nds     )localstuplelower)	r   r   r   r   r   r   r   r   r;  s	           @r\   r   r     s5    ( MA!	
A8DOOOOr^   c                \   [         R                   " SS5      nUR                  5        Vs/ s H  o3[        ;   d  M  UPM     nn[        X5       HU  u  p4U[        ;  a  M  US:X  a+  [	        U5      nUR
                  US'   UR                  US'   MB  XBSR                  U5      '   MW     U$ s  snf )a  Gather point components from input data.

Format codes:

    - ``x`` = x-coordinate
    - ``y`` = y-coordinate
    - ``s`` = start width
    - ``e`` = end width
    - ``b`` = bulge value
    - ``v`` = (x, y [,z]) tuple (z-axis is ignored)

Args:
    data: list or tuple of point components
    format: format string, default is "xyseb"

Returns:
    array.array: array.array('d', (x, y, start_width, end_width, bulge))

d)r   r   r   r   r   r   r   r&   r7   )arrayr?  r4   r   r   r   r   r   )r   r   ar-  r   vertexs         r\   r   r     s    ( 	C23A%||~F~t1Ed~FF6(|#3;%[F88AaD88AaD%*gmmD!" ) H Gs
   B)B))r7   )r   r  r   r  r  r  )r   r  r  zarray.array)V
__future__r   typingr   r   r   r   r   r	   r
   typing_extensionsr   r   rB  ra   
contextlibr   
ezdxf.mathr   r   r   ezdxf.math.transformtoolsr   r   ezdxf.lldxfr   ezdxf.lldxf.attributesr   r   r   r   r   r   ezdxf.lldxf.constr   r   r   r   ezdxf.lldxf.tagsr   ezdxf.lldxf.typesr   r    ezdxf.lldxf.packedtagsr!   ezdxf.render.polyliner"   ezdxf.exploder$   ezdxf.queryr%   	dxfentityr'   r(   dxfgfxr)   r*   factoryr+   r,   ezdxf.entitiesr-   r.   r/   r0   ezdxf.lldxf.tagwriterr1   ezdxf.layoutsr2   __all__floatr5   __annotations__	frozensetr4   r  r.  callbackpoint3dis_not_null_vectorr   rp   r3   rX   r   r   r   r^   r\   <module>ra     sn   #   .   % - - J !   " / . = ( # 4 + $ AA7(
(ueUE5@AY A"#
  5>>)DRT:RT: Q' r1t<--22 
< 1A  J3 J3 J3Z
35{ 35lP4r^   