Ë
    £èhAW  ã                  ó¸  — U d dl mZ d dlmZmZmZmZmZmZm	Z	 d dl
mZ d dlmZ d dlmZ d dlZd dlZd dlmZmZmZmZmZmZmZmZmZ erd dlmZ d d	lm Z m!Z!m"Z"m#Z#m$Z$m%Z% g d
¢Z& edd«      Z' edd«      Z(eeeeef   Z)de*d<   ee   Z+de*d<   ed   Z,de*d<    G d„ d«      Z- G d„ de-«      Z.	 	 	 	 	 	 	 	 	 	 dd„Z/ ed«      Z0 G d„ de-«      Z1 G d„ de«      Z2y)é    )Úannotations)ÚTYPE_CHECKINGÚIterableÚTupleÚUnionÚcastÚSequenceÚOptional)Ú	TypeAlias)Úabstractmethod)Ú
namedtupleN)	ÚVec2ÚVec3ÚUVecÚBSplineÚConstructionRayÚOCSÚParallelRaysErrorÚbulge_to_arcÚConstructionArc)ÚDrawing)Ú
DXFGraphicÚSolidÚTraceÚFace3dÚ
LWPolylineÚPolyline)ÚTraceBuilderÚLinearTraceÚCurvedTraceÚLinearStation)ÚvertexÚstart_widthÚ	end_widthÚCurveStation)Úvertex0Úvertex1r   ÚFaceÚPolygon)r   r   r   ÚQuadrilateralc                  ó8   — e Zd Zedd„«       Zdd„Z	 d	 	 	 dd„Zy)	ÚAbstractTracec                 ó   — y ©N© ©Úselfs    ú2lib/python3.12/site-packages/ezdxf/render/trace.pyÚfaceszAbstractTrace.faces1   s   € ð 	ó    c           	     ó
  — dd„}g }g }| j                  «       D ]-  \  }}}}|j                  ||f«       |j                  ||f«       Œ/ t         ||«      «      }|j                  t        t         ||«      «      «      «       |S )Nc              3  ó–   K  — t        | «      sy t        | «      }t        |«      }|–— |D ]  }|j                  |«      rŒ|–— |}Œ y ­wr.   )ÚlenÚiterÚnextÚisclose)ÚverticesÚ	_verticesÚprevr"   s       r2   Úmergez$AbstractTrace.polygon.<locals>.merge:   sG   è ø€ Ü�x”=Øä˜X›ˆIÜ˜	“?ˆDØŠJÛ#�Ø—|‘| FÕ+Ø ’LØ!‘Dñ $ùs   ‚=A	Á 	A	)r;   r)   ÚreturnzIterable[UVec])r3   ÚextendÚlistÚreversed)	r1   r>   Úforward_contourÚbackward_contourÚup1Údown1Údown2Úup2Úcontours	            r2   ÚpolygonzAbstractTrace.polygon9   sƒ   € ó
	"ð ')ˆØ')ÐØ&*§j¡j¦lÑ"ˆC�˜˜sØ×"Ñ" E¨5 >Ô2Ø×#Ñ# S¨# JÕ/ð '3ô ‘u˜_Ó-Ó.ˆØ�‰”x¤¡UÐ+;Ó%<Ó =Ó>Ô?Øˆr4   Nc              #  ó<  K  — ddl m} |dvrt        d|› d�«      ‚t        |xs i «      }| j	                  «       D ]]  }t        d«      D ]  }||   |d|› �<   Œ |dk7  r|d	   |d
<   |d   |d<    ||||«      }|r|j                  j                  |«       |–— Œ_ y­w)a÷  
        Yields faces as SOLID, TRACE or 3DFACE entities with DXF attributes
        given in `dxfattribs`.

        If a document is given, the doc attribute of the new entities will be
        set and the new entities will be automatically added to the entity
        database of that document.

        Args:
            dxftype: DXF type as string, "SOLID", "TRACE" or "3DFACE"
            dxfattribs: DXF attributes for SOLID, TRACE or 3DFACE entities
            doc: associated document

        r   )Únew>   ÚSOLIDÚTRACEÚ3DFACEzInvalid dxftype Ú.é   ÚvtxrO   é   Úvtx2é   Úvtx3N)Úezdxf.entities.factoryrL   Ú	TypeErrorÚdictr3   ÚrangeÚentitydbÚadd)r1   ÚdxftypeÚ
dxfattribsÚdocrL   ÚfaceÚiÚentitys           r2   Úvirtual_entitieszAbstractTrace.virtual_entitiesP   s¸   è ø€ õ" 	/àÐ6Ñ6ÜÐ.¨w¨i°qÐ9Ó:Ð:Ü˜*Ò*¨Ó+ˆ
Ø—J‘J–LˆDÜ˜1–X�Ø(,¨Q©�
˜S  ˜9Ò%ð ð ˜(Ò"à%)¨!¡W�
˜6Ñ"Ø%)¨!¡W�
˜6Ñ"Ù˜ *¨cÓ2ˆFÙØ—‘× Ñ  Ô(Ø‹Lñ !ùs   ‚BB©r?   zIterable[Face])r?   r)   ©rN   NN©r_   zOptional[Drawing]r?   zIterable[Quadrilateral])Ú__name__Ú
__module__Ú__qualname__r   r3   rJ   rc   r/   r4   r2   r,   r,   0   s5   „ Øòó ðóð0 JNð!Ø5Fð!à	 ô!r4   r,   c                  óX   — e Zd ZdZd	d„Zd„ Zd„ Zed
d„«       Z	 d	 	 	 	 	 	 	 dd„Z	dd„Z
y)r   ztLinear 2D banded lines like polylines with start- and end width.

    Accepts 3D input, but z-axis is ignored.

    c                ó    — g | _         d| _        y ©Ngê-�™—q=)Ú	_stationsÚabs_tolr0   s    r2   Ú__init__zLinearTrace.__init__{   s   € Ø.0ˆŒØˆ�r4   c                ó,   — t        | j                  «      S r.   ©r7   rm   r0   s    r2   Ú__len__zLinearTrace.__len__   ó   € Ü�4—>‘>Ó"Ð"r4   c                ó    — | j                   |   S r.   ©rm   ©r1   Úitems     r2   Ú__getitem__zLinearTrace.__getitem__‚   ó   € Ø�~‰~˜dÑ#Ð#r4   c                ó,   — t        | j                  «      S )z%`True` if at least one station exist.)Úboolrm   r0   s    r2   Ú
is_startedzLinearTrace.is_started…   s   € ô �D—N‘NÓ#Ð#r4   Nc           	     ó   — |€|}t        |«      }| j                  }t        |«      r:|d   j                  j	                  || j
                  ¬«      r|j                  «        |j                  t        |t        |«      t        |«      «      «       y)aa  Add a trace station (like a vertex) at location `point`,
        `start_width` is the width of the next segment starting at this station,
        `end_width` is the end width of the next segment.

        Adding the last location again, replaces the actual last location e.g.
        adding lines (a, b), (b, c), creates only 3 stations (a, b, c), this is
        very important to connect to/from splines.

        Args:
            point: 2D location (vertex), z-axis of 3D vertices is ignored.
            start_width: start width of next segment
            end_width:  end width of next segment

        Néÿÿÿÿ)rn   )
r   rm   r{   r"   r:   rn   ÚpopÚappendr!   Úfloat)r1   Úpointr#   r$   Ústationss        r2   Úadd_stationzLinearTrace.add_stationŠ   sp   € ð" ÐØ#ˆIÜ�U“ˆØ—>‘>ˆä�Œ>˜h r™l×1Ñ1×9Ñ9¸%ÈÏÉÐ9ÔVà�L‰LŒNØ�‰œ e¬U°;Ó-?ÄÀyÓAQÓRÕSr4   c           	   #  ó  ‡‡ K  — | j                   Š t        ‰ «      }|dk  ry	 	 	 	 dˆˆ fd„}	 	 	 	 	 	 	 	 d	d„}‰ d   j                  j                  ‰ d   j                  «      }g Št	        |dz
  «      D ]:  }‰ |   \  }}}‰ |dz      j                  }	‰j                  t        ||	||«      «       Œ<  |d«      \  }
}d}d}‰d   \  }}}}t	        t        ‰«      «      D ]¨  }‰|   \  }}}}|dk(  r;|r0 |t        ‰«      dz
  «      \  }} |||
|«      } ||||«      }|}|}n|}|}|
}|}n |||
|«      } ||||«      }|t        ‰«      dz
  k  r+ ||dz   «      \  }} ||||«      } |||
|«      }|
}|}|}
|}n|}|}||||f–— Œª y­w)
a2  Yields all faces as 4-tuples of :class:`~ezdxf.math.Vec2` objects.

        First and last miter is 90 degrees if the path is not closed, otherwise
        the intersection of first and last segment is taken into account,
        a closed path has to have explicit the same last and first vertex.

        rU   Nc                óJ   •‡ — ˆ ˆfd„}‰‰    \  }}}} |||«       |||«      fS )z0Create offset rays from segment offset vertices.c                ó®   •— | j                  |«      r8‰‰   j                  ‰‰dz      j                  z
  j                  }t        | |«      S t        | |«      S )Né   )r:   r"   Úangler   )Úv1Úv2r‰   Úsegmentrƒ   s      €€r2   Úrayz3LinearTrace.faces.<locals>.offset_rays.<locals>.ray·   sX   ø€ Ø—:‘:˜b”>ð ! Ñ)×0Ñ0°8¸GÀa¹KÑ3H×3OÑ3OÑOß‘eð ô +¨2¨uÓ5Ð5ä*¨2¨rÓ2Ð2r4   r/   )rŒ   r�   Úleft1Úleft2Úright1Úright2Úsegmentsrƒ   s   `     €€r2   Úoffset_raysz&LinearTrace.faces.<locals>.offset_rays²   s6   ù€ õ
3ð ,4°GÑ+<Ñ(ˆE�5˜& &Ù�u˜eÓ$¡c¨&°&Ó&9Ð9Ð9r4   c                óð   — t        | j                  j                  |j                  «      «      }|dk  st        t        j                  |z
  «      dk  r|S 	 | j                  |«      S # t        $ r |cY S w xY w)z7Intersect two rays but take parallel rays into account.g„*5{  ?)ÚabsÚ	directionÚangle_betweenÚmathÚpiÚ	intersectr   )Úray1Úray2Údefaultr‰   s       r2   rš   z$LinearTrace.faces.<locals>.intersectÄ   sj   € ô
 ˜Ÿ™×4Ñ4°T·^±^ÓDÓEˆEØ�xÒ¤3¤t§w¡w°¡Ó#7¸(Ò#BØ�ðØ—~‘~ dÓ+Ð+øÜ$ò Ø’ðús   ÁA' Á'A5Á4A5r   r~   rˆ   )rŒ   Úintr?   z'tuple[ConstructionRay, ConstructionRay])r›   r   rœ   r   r�   r   r?   r   )rm   r7   r"   r:   rZ   r€   Ú_normal_offset_points)!r1   Úcountr“   rš   Ú	is_closedÚstationÚstart_vertexr#   r$   Ú
end_vertexÚoffset_ray1Úoffset_ray2Úprev_offset_ray1Úprev_offset_ray2Úlast_up1Úlast_up2Ú
last_down1Ú
last_down2ra   rE   rH   rF   rG   Úlast_offset_ray1Úlast_offset_ray2Úvtx0Úvtx1Únext_offset_ray1Únext_offset_ray2rT   rV   r’   rƒ   s!                                  @@r2   r3   zLinearTrace.faces¥   s5  ùè ø€ ð —>‘>ˆÜ�H“ˆØ�1Š9Øð	:Øð	:à4ö	:ð$	Ø!ð	Ø)8ð	ØCGð	àó	ð ˜Q‘K×&Ñ&×.Ñ.¨x¸©|×/BÑ/BÓCˆ	àˆô ˜U Q™YÖ'ˆGØ3;¸GÑ3DÑ0ˆL˜+ yØ! '¨A¡+Ñ.×5Ñ5ˆJð �O‰OÜ% l°JÀÈYÓWõð (ñ $/¨q£>Ñ ˆ�[ØÐØÐð 6>¸b±\Ñ2ˆ�(˜J¨
ä”s˜8“}Ö%ˆAØ%-¨a¡[Ñ"ˆC��e˜UØ�AŠváñ :EÄSÈÃ]ÐUVÑEVÓ9WÑ6Ð$Ð&6Ù$Ð%5°{ÀCÓH�DÙ$Ð%5°{ÀEÓJ�Dð  $�HØ!%‘Jð �DØ �DØ#.Ð Ø#.Ñ ñ !Ð!1°;ÀÓD�Ù Ð!1°;ÀÓF�à”3�x“= 1Ñ$Ò$á5@ÀÀQÁÓ5GÑ2Ð Ð"2Ù Ð!1°;ÀÓF�Ù Ð!1°;ÀÓD�Ø#.Ð Ø#.Ð Ø.�Ø.‘ð "�Ø�Ø˜˜d DÐ(Ó(ñM &ùs   „FF
©r?   ÚNone)r?   r{   r.   )r‚   r   r#   r�   r$   zOptional[float]r?   r´   rd   )rg   rh   ri   Ú__doc__ro   rr   rx   Úpropertyr|   r„   r3   r/   r4   r2   r   r   t   sa   „ ñóò#ò$ð ò$ó ð$ð
 MQðTØðTØ(-ðTØ:IðTà	óTô6o)r4   r   c                ó¾   — || z
  j                  «       }|j                  d«      }|j                  |dz  «      }|j                  |dz  «      }| |z   ||z   | |z
  ||z
  fS )NTrU   )Ú	normalizeÚ
orthogonal)ÚstartÚendr#   r$   Ú
dir_vectorÚorthoÚoffset_startÚ
offset_ends           r2   rŸ   rŸ     st   € ð ˜‘+×(Ñ(Ó*€JØ×!Ñ! $Ó'€EØ—?‘? ;°¡?Ó3€LØ—‘ ¨Q¡Ó/€Jà�ÑØˆjÑØ�ÑØˆjÑð	ð r4   )r   r   c                  ó‚   — e Zd ZdZd
d„Zd„ Zd„ Ze	 	 	 	 	 	 	 	 	 	 dd„«       Ze	 d	 	 	 	 	 	 	 	 	 dd„«       Z	dd„Z
dd„Zy	)r    zë2D banded curves like arcs or splines with start- and end width.

    Represents always only one curved entity and all miter of curve segments
    are perpendicular to curve tangents.

    Accepts 3D input, but z-axis is ignored.

    c                ó   — g | _         y r.   ru   r0   s    r2   ro   zCurvedTrace.__init__3  s	   € Ø-/ˆ�r4   c                ó,   — t        | j                  «      S r.   rq   r0   s    r2   rr   zCurvedTrace.__len__6  rs   r4   c                ó    — | j                   |   S r.   ru   rv   s     r2   rx   zCurvedTrace.__getitem__9  ry   r4   c                óF  —  | «       }|dz   }t        j                  d|j                  |«      }t        |j	                  |d¬«      t        j                  |||«      «      D ]>  \  \  }}	}
t        |	«      j                  d«      }|j                  t        |«      ||
«       Œ@ |S )zþ
        Create curved trace from a B-spline.

        Args:
            spline: :class:`~ezdxf.math.BSpline` object
            start_width: start width
            end_width: end width
            segments: count of segments for approximation

        rˆ   r   )ÚnT)ÚnpÚlinspaceÚmax_tÚzipÚderivativesr   r¹   Ú_append)ÚclsÚspliner#   r$   r’   Úcurve_tracer    Útr‚   Ú
derivativeÚwidthÚnormals               r2   Úfrom_splinezCurvedTrace.from_spline<  sš   € ñ$ “eˆØ˜1‘ˆÜ�K‰K˜˜6Ÿ<™<¨Ó/ˆÜ*-Ø×Ñ˜q AÐÓ&¬¯©°KÀÈEÓ(Rö+
Ñ&ÑˆU�J ô ˜*Ó%×0Ñ0°Ó6ˆFØ×Ñ¤ U£¨V°UÕ;ð	+
ð
 Ðr4   c                ó¬  — |j                   dk  rt        d|j                   › d�«      ‚ | «       }t        t        j                  |j
                  dz  |z  «      d«      dz   }t        |j                  «      }t        |j                  |j                  |«      «      t        j                  |||«      «      D ]  \  }}	|j                  |||z
  |	«       Œ |S )a²  
        Create curved trace from an arc.

        Args:
            arc: :class:`~ezdxf.math.ConstructionArc` object
            start_width: start width
            end_width: end width
            segments: count of segments for full circle (360 degree)
                approximation, partial arcs have proportional less segments,
                but at least 3

        Raises:
            ValueError: if arc.radius <= 0

        r   zInvalid radius: rP   g     €v@rS   rˆ   )ÚradiusÚ
ValueErrorÚmaxr˜   ÚceilÚ
angle_spanr   ÚcenterrÉ   r;   ÚanglesrÆ   rÇ   rË   )
rÌ   Úarcr#   r$   r’   rÎ   r    rÚ   r‚   rÑ   s
             r2   Úfrom_arczCurvedTrace.from_arcX  s½   € ð. �:‰:˜Š?ÜÐ/°·
±
¨|¸1Ð=Ó>Ð>Ù“eˆÜ”D—I‘I˜cŸn™n¨uÑ4°xÑ?Ó@À!ÓDÀqÑHˆÜ�c—j‘jÓ!ˆÜØ�L‰L˜Ÿ™ EÓ*Ó+Ü�K‰K˜ Y°Ó6ö
‰LˆE�5ð ×Ñ  u¨v¡~°uÕ=ð	
ð
 Ðr4   c                óº   — t         j                  |«      rt         }n|j                  |dz  «      }| j                  j	                  t        ||z   ||z
  «      «       y)z÷
        Add a curve trace station (like a vertex) at location `point`.

        Args:
            point: 2D curve location (vertex), z-axis of 3D vertices is ignored.
            normal: curve normal
            width:  width of station

        rU   N)Ú	_NULLVEC2r:   r¸   rm   r€   r%   )r1   r‚   rÒ   rÑ   s       r2   rË   zCurvedTrace._append{  sL   € ô ×Ñ˜VÔ$Ü‰Fà×%Ñ% e¨a¡iÓ0ˆFØ�‰×Ñœl¨5°6©>¸5À6¹>ÓJÕKr4   c              #  ó˜   K  — t        | j                  «      }|dk  ryd}d}| j                  D ]  \  }}|€|}|}Œ||||f–— |}|}Œ y­w)zBYields all faces as 4-tuples of :class:`~ezdxf.math.Vec2` objects.rU   Nrq   )r1   r    r¯   r°   rT   rV   s         r2   r3   zCurvedTrace.faces‹  se   è ø€ ä�D—N‘NÓ#ˆØ�1Š9ØàˆØˆØŸ.œ.‰JˆD�$Øˆ|Ø�Ø�ØØ˜˜d DÐ(Ò(ØˆDØ‰Dñ )ùs   ‚AA
Nr³   )
rÍ   r   r#   r�   r$   r�   r’   rž   r?   r    ©é@   )
rÜ   r   r#   r�   r$   r�   r’   rž   r?   r    )r‚   r   rÒ   r   rÑ   r�   r?   r´   rd   )rg   rh   ri   rµ   ro   rr   rx   ÚclassmethodrÓ   rÝ   rË   r3   r/   r4   r2   r    r    )  s¯   „ ñó0ò#ò$ð ðàðð ðð ð	ð
 ðð 
òó ðð6 ð ð àð ð ð ð ð	 ð
 ð ð 
ò ó ð óDLô r4   r    c                  óx   — e Zd ZdZdd„Zd„ Zd„ Zdd„Zdd„Zdd„Z	dd„Z
dd	„Z	 d	 	 	 dd„Zd„ Zeddd„«       Zy
)r   a  Sequence of 2D banded lines like polylines with start- and end width or
    curves with start- and end width.


    .. note::

        Accepts 3D input, but z-axis is ignored. The :class:`TraceBuilder` is a
        2D only object and uses only the :ref:`OCS` coordinates!

    c                ó    — g | _         d| _        y rl   )Ú_tracesrn   r0   s    r2   ro   zTraceBuilder.__init__©  s   € Ø,.ˆŒØˆ�r4   c                ó,   — t        | j                  «      S r.   )r7   ræ   r0   s    r2   rr   zTraceBuilder.__len__­  s   € Ü�4—<‘<Ó Ð r4   c                ó    — | j                   |   S r.   )ræ   rv   s     r2   rx   zTraceBuilder.__getitem__°  s   € Ø�|‰|˜DÑ!Ð!r4   c                ó:   — | j                   j                  |«       y)zAppend a new trace.N)ræ   r€   ©r1   Útraces     r2   r€   zTraceBuilder.append³  s   € à�‰×Ñ˜EÕ"r4   c              #  ób   K  — | j                   D ]  }|j                  «       E d{  –—†  Œ y7 Œ­w)zaYields all faces as 4-tuples of :class:`~ezdxf.math.Vec2` objects
        in :ref:`OCS`.
        N)ræ   r3   rê   s     r2   r3   zTraceBuilder.faces·  s(   è ø€ ð —\”\ˆEØ—{‘{“}×$Ñ$ñ "Ø$ús   ‚#/¥-¦/c              #  ó‚   ‡K  — | j                  «       D ]'  }t        |j                  ˆfd„|D «       «      «      –— Œ) y­w)zaYields all faces as 4-tuples of :class:`~ezdxf.math.Vec3` objects
        in :ref:`WCS`.
        c              3  ó`   •K  — | ]%  }t        |j                  |j                  ‰«      –— Œ' y ­wr.   ©r   ÚxÚy©Ú.0ÚvÚ	elevations     €r2   Ú	<genexpr>z)TraceBuilder.faces_wcs.<locals>.<genexpr>Ã  s#   øè ø€ Ð)RÉTÈ¬$¨q¯s©s°A·C±C¸×*CÉTùó   ƒ+.N)r3   ÚtupleÚpoints_to_wcs)r1   Úocsrõ   r`   s     ` r2   Ú	faces_wcszTraceBuilder.faces_wcs¾  s5   øè ø€ ð —J‘J–LˆDÜ˜×)Ñ)Ó)RÉTÓ)RÓRÓSÓSñ !ùs   ƒ<?c              #  óR   K  — | j                   D ]  }|j                  «       –— Œ y­w)z{Yields for each sub-trace a single polygon as sequence of
        :class:`~ezdxf.math.Vec2` objects in :ref:`OCS`.
        N)ræ   rJ   rê   s     r2   ÚpolygonszTraceBuilder.polygonsÅ  s"   è ø€ ð —\”\ˆEØ—-‘-“/Ó!ñ "ùs   ‚%'c              #  ó–   ‡K  — | j                   D ]5  }t        |j                  ˆfd„|j                  «       D «       «      «      –— Œ7 y­w)z{Yields for each sub-trace a single polygon as sequence of
        :class:`~ezdxf.math.Vec3` objects in :ref:`WCS`.
        c              3  ó`   •K  — | ]%  }t        |j                  |j                  ‰«      –— Œ' y ­wr.   rï   rò   s     €r2   rö   z,TraceBuilder.polygons_wcs.<locals>.<genexpr>Ò  s#   øè ø€ Ð!UÁ_À¤$ q§s¡s¨A¯C©C°×";Á_ùr÷   N)ræ   rø   rù   rJ   )r1   rú   rõ   rë   s     ` r2   Úpolygons_wcszTraceBuilder.polygons_wcsÌ  s>   øè ø€ ð —\”\ˆEÜØ×!Ñ!Ó!UÀUÇ]Á]Ä_Ó!UÓUóó ñ "ùs   ƒAA	Nc              #  óh   K  — | j                   D ]  }|j                  |||«      E d{  –—†  Œ y7 Œ­w)ar  Yields faces as SOLID, TRACE or 3DFACE entities with DXF attributes
        given in `dxfattribs`.

        If a document is given, the doc attribute of the new entities will be
        set and the new entities will be automatically added to the entity
        database of that document.

        .. note::

            The :class:`TraceBuilder` is a 2D only object and uses only the
            :ref:`OCS` coordinates!

        Args:
            dxftype: DXF type as string, "SOLID", "TRACE" or "3DFACE"
            dxfattribs: DXF attributes for SOLID, TRACE or 3DFACE entities
            doc: associated document

        N)ræ   rc   )r1   r]   r^   r_   rë   s        r2   rc   zTraceBuilder.virtual_entitiesÕ  s1   è ø€ ð* —\”\ˆEØ×-Ñ-¨g°zÀ3ÓG×GÑGñ "ØGús   ‚&2¨0©2c                ó*  — | j                   }t        |«      dk  ryt        |d   t        «      ret        |d   t        «      rQt	        t        |j                  d«      «      }t	        t        |d   «      }|D ]  \  }}}|j                  |||«       Œ yyy)zEClose multi traces by merging first and last trace, if linear traces.rU   Nr   r~   )ræ   r7   Ú
isinstancer   r   r   r„   )r1   ÚtracesÚfirstÚlastr‚   r#   r$   s          r2   ÚclosezTraceBuilder.closeí  s„   € à—‘ˆÜˆv‹;˜Š?ØÜ�f˜Q‘i¤Ô-´*¸VÀB¹ZÌÔ2UÜœ f§j¡j°£mÓ4ˆEÜœ V¨B¡ZÓ0ˆDÛ16Ñ-��{ IØ× Ñ  ¨°YÕ?ñ 27ð 3VÐ-r4   c           	     óœ  — |j                  «       }|dk(  rpt        d|«      }|j                  j                  }g }|j                  D ]/  \  }}}}	}
t        ||«      }|r|}|}	|j                  |||	|
f«       Œ1 |j                  }�n5|dk(  �r!t        d|«      }|j                  st        d«      ‚|j                  }|j                  j                  }|j                  j                  }g }|j                  D ]´  }t        |j                  j                  «      }|j                  j                  d«      r|j                  j                   }n|}|j                  j                  d«      r|j                  j"                  }	n|}	|j                  j$                  }
|j                  |||	|
f«       Œ¶ nt        d|› �«      ‚|r1|d	   d	   j'                  |d
   d	   «      s|j                  |d	   «        | «       }d}d}d}d}t)        «       }|D �]  \  }}}	}
|dk7  ršt+        |||«      \  }}}}|d	kD  r�t-        ||t/        j0                  |«      t/        j0                  |«      d¬«      }|j2                  j'                  |«      r|}|}n|}|}|j                  t4        j7                  ||||«      «       d}|
dk7  rC|j8                  r.|j;                  |||	«       |j                  |«       t)        «       }|
}|}|	}|}Œð|j;                  |||	«       �Œ |j8                  r|j                  |«       |rt=        |«      dkD  r|j?                  «        |S )a  
        Create a complete trace from a LWPOLYLINE or a 2D POLYLINE entity, the
        trace consist of multiple sub-traces if :term:`bulge` values are
        present. Uses only the :ref:`OCS` coordinates!

        Args:
            polyline: :class:`~ezdxf.entities.LWPolyline` or 2D
                :class:`~ezdxf.entities.Polyline`
            segments: count of segments for bulge approximation, given count is
                for a full circle, partial arcs have proportional less segments,
                but at least 3

        Ú
LWPOLYLINEr   ÚPOLYLINEr   z2D POLYLINE requiredr#   r$   zInvalid DXF type r   r~   g        NT)Úis_counter_clockwiserˆ   ) r]   r   ÚdxfÚconst_widthÚlwpointsr   r€   ÚclosedÚis_2d_polylinerX   r¡   Údefault_start_widthÚdefault_end_widthr;   ÚlocationÚhasattrr#   r$   Úbulger:   r   r   r   r˜   ÚdegreesÚstart_pointr    rÝ   r|   r„   r7   r  )rÌ   Úpolyliner’   r]   r  Úpointsrð   rñ   r#   r$   r  r  r  r  r  r"   rë   Ústore_bulgeÚstore_start_widthÚstore_end_widthÚstore_pointÚlinear_tracer‚   rÚ   Ústart_angleÚ	end_anglerÕ   rÜ   ÚswÚews                                 r2   Úfrom_polylinezTraceBuilder.from_polylineø  s-  € ð ×"Ñ"Ó$ˆØ�lÒ"Ü˜L¨(Ó3ˆHØ"Ÿ,™,×2Ñ2ˆKØˆFØ7?×7HÔ7HÑ3��1�k 9¨eÜ  1›:�Ùð #.�KØ +�IØ—‘˜x¨°iÀÐGÕHð 8Ið —_‘_ŠFØ˜
Ó"Ü˜J¨Ó1ˆHØ×*Ò*ÜÐ 6Ó7Ð7Ø×'Ñ'ˆFØ"*§,¡,×"BÑ"BÐØ (§¡× >Ñ >ÐØˆFØ"×+Ô+�Ü §
¡
× 3Ñ 3Ó4�Ø—:‘:×%Ñ% mÔ4Ø"(§*¡*×"8Ñ"8‘Kà"5�KØ—:‘:×%Ñ% kÔ2Ø &§
¡
× 4Ñ 4‘Ià 1�IØŸ
™
×(Ñ(�Ø—‘˜x¨°iÀÐGÕHñ ,ô Ð/°¨yÐ9Ó:Ð:á˜& ™) A™,×.Ñ.¨v°b©z¸!©}Ô=à�M‰M˜& ™)Ô$á“ˆØˆØÐØˆØ#'ˆä"“}ˆÜ4:Ñ0ˆE�; 	¨5Ø˜cÒ!Ü9EØ ¨ó:Ñ6�˜ Y°ð ˜A’:Ü)ØØÜŸ™ [Ó1ÜŸ™ YÓ/Ø-1ô�Cð —‘×.Ñ.¨uÔ5Ø,˜Ø.™à,˜Ø.˜Ø—L‘L¤×!5Ñ!5°c¸2¸rÀ8Ó!LÔMØ!�à˜Š|Ø×*Ò*Ø ×,Ñ,¨U°KÀÔKØ—L‘L Ô.Ü#.£=�LØ#�Ø$/Ð!Ø"+�Ø#�Øà×$Ñ$ U¨K¸ÖCðC 5;ðD ×"Ò"Ø�L‰L˜Ô&á”c˜%“j 1’nð �K‰KŒMØˆr4   r³   )rë   r,   r?   r´   rd   )rú   r   rõ   r�   r?   zIterable[Sequence[Vec3]])r?   zIterable[Polygon]re   rf   rá   )r  r   r’   rž   r?   r   )rg   rh   ri   rµ   ro   rr   rx   r€   r3   rû   rý   r   rc   r  rã   r#  r/   r4   r2   r   r   �  sk   „ ñ	óò!ò"ó#ó%óTó"óð JNðHØ5FðHà	 óHò0	@ð ógó ñgr4   r   )
rº   r   r»   r   r#   r�   r$   r�   r?   r(   )3Ú
__future__r   Útypingr   r   r   r   r   r	   r
   Útyping_extensionsr   Úabcr   Úcollectionsr   r˜   ÚnumpyrÆ   Ú
ezdxf.mathr   r   r   r   r   r   r   r   r   Úezdxf.documentr   Úezdxf.entitiesr   r   r   r   r   r   Ú__all__r!   r%   r(   Ú__annotations__r)   r*   r,   r   rŸ   rß   r    r   r/   r4   r2   Ú<module>r/     s  ðö #÷÷ ñ õ (Ý Ý "Û Û ÷
÷ 
õ 
ñ Ý&ßU×Uâ
8€á˜?Ð,RÓS€ñ ˜.Ð*@ÓA€à˜˜d D¨$Ð.Ñ/€€iÓ /Ø˜d‘^€ˆÓ #Ø Ð!;Ñ<€ˆyÓ <÷Añ AôH`)�-ô `)ðFØðØðØ).ðØ;@ðà	óñ �‹L€	ôq�-ô qôhC�8õ Cr4   