Ë
    £èh7j  ã                  óN  — d dl mZ d dlmZ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mZ d dlmZ ee   Z eed¬	«      Zd
ddddddddddddœZddddddœZ G d„ d«      Ze	 	 d(	 	 	 	 	 	 	 d)d„«       Z G d „ d!«      Z	 d*	 	 	 	 	 	 	 d+d#„Zd,d-d$„Zd.d%„Z  e!d&«      Z"d'Z#y")/é    )Úannotations)ÚTextIOÚBinaryIOÚUnionÚSequenceÚIterableÚcastÚIteratorÚOptional)Úcontextmanager)Úpartial)ÚStringIO)ÚPath)ÚBinaryTagWriteré   )Úndigits©r   r   )é   r   )é   r   )r   r   )r   r   )r   r   )r   r   )r   r   )r   r   )r   é   )r   r   )r   r   )ÚLEFTÚCENTERÚRIGHTÚBOTTOM_LEFTÚBOTTOM_CENTERÚBOTTOM_RIGHTÚMIDDLE_LEFTÚMIDDLE_CENTERÚMIDDLE_RIGHTÚTOP_LEFTÚ
TOP_CENTERÚ	TOP_RIGHTé
   é   é(   é)   é*   )ÚxÚyÚsÚeÚbc                  ó   — e Zd Zdd„Zdd„Zy)ÚBinaryDXFWriterc                ó‚   — || _         t        | j                   ddd¬«      | _        | j                  j                  «        y )NÚAC1009FÚcp1252)Ú
dxfversionÚwrite_handlesÚencoding)Ú_streamr   Ú
_tagwriterÚwrite_signature)ÚselfÚstreams     ú6lib/python3.12/site-packages/ezdxf/addons/r12writer.pyÚ__init__zBinaryDXFWriter.__init__.   s7   € ØˆŒÜ)Ø�L‰LØØØô	
ˆŒð 	�‰×'Ñ'Õ)ó    c                ó:   — | j                   j                  |«       y ©N)r6   Ú	write_str)r8   r*   s     r:   ÚwritezBinaryDXFWriter.write8   s   € Ø�‰×!Ñ! !Õ$r<   N)r9   r   )r*   ÚstrÚreturnÚNone)Ú__name__Ú
__module__Ú__qualname__r;   r@   © r<   r:   r.   r.   -   s   „ ó*ô%r<   r.   c           	   #  ó\  K  — d}|j                  d«      r't        | t        t        f«      r•t	        | dd¬«      }|} n„|j                  d«      rdt        | t        t        f«      r&t	        | d«      }t        t        t        |«      «      } n7t        t        t        t        t        | «      «      «      } nt        d|› d	�«      ‚t        t        t        | «      |«      }	 |–— |j                  «        |r|j                  «        yy# |j                  «        |r|j                  «        w w xY w­w)
a=  Context manager for writing DXF entities to a stream/file. `stream` can
    be any file like object with a :func:`write` method or just a string for
    writing DXF entities to the file system. If `fixed_tables` is ``True``, a
    standard TABLES section is written in front of the ENTITIES
    section and some predefined text styles and line types can be used.

    Set argument `fmt` to "asc" to write ASCII DXF file (default) or "bin" to
    write Binary DXF files. ASCII DXF require a :class:`TextIO` stream and
    Binary DXF require a :class:`BinaryIO` stream.

    NÚascÚwtr1   )r4   ÚbinÚwbzUnknown format 'z'.)Ú
startswithÚ
isinstancerA   r   Úopenr	   r   r.   r   Ú
ValueErrorÚR12FastStreamWriterÚclose)r9   Úfixed_tablesÚfmtr5   Úwriters        r:   Ú	r12writerrV   <   sô   è ø€ ð" .2€Gà
‡~�~�eÔÜ�fœs¤D˜kÔ*Ü˜6 4°(Ô;ˆGØ‰FØ	�‰˜Ô	Ü�fœs¤D˜kÔ*Ü˜6 4Ó(ˆGÜœ&¤/°'Ó":Ó;‰Fäœ&¤/´$´xÀÓ2HÓ"IÓJ‰Fô Ð+¨C¨5°Ð3Ó4Ð4Ü ¤¤f¨fÓ!5°|ÓD€FðØŠà�‰ŒÙØ�M‰M�Oð øð 	�‰ŒÙØ�M‰M�Oð üs   ‚CD,ÃD Ã $D,Ä%D)Ä)D,c                  ó&  — e Zd ZdZddd„Zdd„Z	 	 	 d	 	 	 	 	 	 	 	 	 	 	 dd„Z	 	 	 d	 	 	 	 	 	 	 	 	 	 	 dd„Z	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd„Z	 	 	 d	 	 	 	 	 	 	 	 	 dd„Z		 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 dd	„Z
	 	 	 d	 	 	 	 	 	 	 	 	 dd
„Z	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd„Z	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 dd„Z	 	 	 	 	 	 	 d 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d!d„Z	 	 	 d	 	 	 	 	 	 	 	 	 	 	 d"d„Z	 	 	 	 d#	 	 	 	 	 	 	 	 	 	 	 d$d„Z	 	 	 	 	 	 	 	 	 d%	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d&d„Zy)'rQ   aU  Fast stream writer to create simple DXF R12 drawings.

    Args:
        stream: a file like object with a :func:`write` method.
        fixed_tables: if `fixed_tables` is ``True``, a standard TABLES section
            is written in front of the ENTITIES section and some predefined text
            styles and line types can be used.

    c                ób   — || _         |r|j                  t        «       |j                  d«       y )Nz0
SECTION
2
ENTITIES
)r9   r@   ÚPREFACE)r8   r9   rS   s      r:   r;   zR12FastStreamWriter.__init__p   s%   € ØˆŒÙØ�L‰LœÔ!Ø�‰Ð0Õ1r<   c                ó:   — | j                   j                  d«       y)zmWrites the DXF tail. Call is not necessary when using the context
        manager :func:`r12writer`.
        z0
ENDSEC
0
EOF
N©r9   r@   )r8   s    r:   rR   zR12FastStreamWriter.closev   s   € ð 	�‰×ÑÐ/Õ0r<   Nc                ó  — dg}|j                  t        |||«      «       |j                  t        |d¬«      «       |j                  t        |d¬«      «       | j                  j	                  dj                  |«      «       y)aV  Add a LINE entity from `start` to `end`.

        Args:
            start: start vertex as ``(x, y[, z])`` tuple
            end: end vertex as  as ``(x, y[, z])`` tuple
            layer: layer name as string, without a layer definition the assigned
                color = ``7`` (black/white) and line type is ``'Continuous'``.
            color: color as :ref:`ACI` in the range from ``0`` to ``256``,
                ``0`` is `ByBlock` and ``256`` is `ByLayer`, default is `ByLayer`
                which is always color = ``7`` (black/white) without a layer
                definition.
            linetype: line type as string, if FIXED-TABLES are written some
                predefined line types are available, else line type is always
                `ByLayer`, which is always ``'Continuous'`` without a LAYERS
                table.

        z0
LINE
r#   ©Úcodeé   Ú N©ÚappendÚdxf_attribsÚ
dxf_vertexr9   r@   Újoin)r8   ÚstartÚendÚlayerÚcolorÚlinetypeÚdxfs          r:   Úadd_linezR12FastStreamWriter.add_line|   s`   € ð2 ˆmˆØ�
‰
”;˜u e¨XÓ6Ô7Ø�
‰
”:˜e¨"Ô-Ô.Ø�
‰
”:˜c¨Ô+Ô,Ø�‰×Ñ˜"Ÿ'™' #›,Õ'r<   c           
     ó$  — dg}|j                  t        |||«      «       |j                  t        |«      «       |j                  t        dt	        t        |«      «      «      «       | j                  j                  dj                  |«      «       y)aL  Add a CIRCLE entity.

        Args:
            center: circle center point as ``(x, y)`` tuple
            radius: circle radius as float
            layer: layer name as string see :meth:`add_line`
            color: color as :ref:`ACI` see :meth:`add_line`
            linetype: line type as string see :meth:`add_line`

        z	0
CIRCLE
r%   r`   N©	rb   rc   rd   Údxf_tagrA   Úrndr9   r@   re   )r8   ÚcenterÚradiusrh   ri   rj   rk   s          r:   Ú
add_circlezR12FastStreamWriter.add_circle›   sg   € ð$ ˆoˆØ�
‰
”;˜u e¨XÓ6Ô7Ø�
‰
”:˜fÓ%Ô&Ø�
‰
”7˜2œs¤3 v£;Ó/Ó0Ô1Ø�‰×Ñ˜"Ÿ'™' #›,Õ'r<   c           
     óØ  — dg}|j                  t        |||«      «       |j                  t        |«      «       |j                  t        dt	        t        |«      «      «      «       |j                  t        dt	        t        |«      «      «      «       |j                  t        dt	        t        |«      «      «      «       | j                  j                  dj                  |«      «       y)aø  Add an ARC entity. The arc goes counter-clockwise from `start` angle
        to `end` angle.

        Args:
            center: arc center point as ``(x, y)`` tuple
            radius: arc radius as float
            start: arc start angle in degrees as float
            end: arc end angle in degrees as float
            layer: layer name as string see :meth:`add_line`
            color: color as :ref:`ACI` see :meth:`add_line`
            linetype: line type as string see :meth:`add_line`

        z0
ARC
r%   é2   é3   r`   Nrn   )	r8   rq   rr   rf   rg   rh   ri   rj   rk   s	            r:   Úadd_arczR12FastStreamWriter.add_arc³   s�   € ð. ˆlˆØ�
‰
”;˜u e¨XÓ6Ô7Ø�
‰
”:˜fÓ%Ô&Ø�
‰
”7˜2œs¤3 v£;Ó/Ó0Ô1Ø�
‰
”7˜2œs¤3 u£:›Ó/Ô0Ø�
‰
”7˜2œs¤3 s£8›}Ó-Ô.Ø�‰×Ñ˜"Ÿ'™' #›,Õ'r<   c                óÊ   — dg}|j                  t        |||«      «       |j                  t        |«      «       | j                  j	                  dj                  |«      «       y)a+  
        Add a POINT entity.

        Args:
            location: point location as ``(x, y [,z])`` tuple
            layer: layer name as string see :meth:`add_line`
            color: color as :ref:`ACI` see :meth:`add_line`
            linetype: line type as string see :meth:`add_line`

        z0
POINT
r`   Nra   )r8   Úlocationrh   ri   rj   rk   s         r:   Ú	add_pointzR12FastStreamWriter.add_pointÒ   sK   € ð" ˆnˆØ�
‰
”;˜u e¨XÓ6Ô7Ø�
‰
”:˜hÓ'Ô(Ø�‰×Ñ˜"Ÿ'™' #›,Õ'r<   c                ó0   — | j                  d|||||«       y)a¿  Add a 3DFACE entity. 3DFACE is a spatial area with 3 or 4 vertices,
        all vertices have to be in the same plane.

        Args:
            vertices: iterable of 3 or 4 ``(x, y, z)`` vertices.
            invisible: bit coded flag to define the invisible edges,

                1. edge = 1
                2. edge = 2
                3. edge = 4
                4. edge = 8

                Add edge values to set multiple edges invisible,
                1. edge + 3. edge = 1 + 4 = 5, all edges = 15

            layer: layer name as string see :meth:`add_line`
            color: color as :ref:`ACI` see :meth:`add_line`
            linetype: line type as string see :meth:`add_line`

        Ú3DFACEN©Ú_add_quadrilateral)r8   ÚverticesÚ	invisiblerh   ri   rj   s         r:   Ú
add_3dfacezR12FastStreamWriter.add_3dfaceè   s   € ð8 	×ÑØ�h 	¨5°%¸õ	
r<   c                ó0   — | j                  d|d|||«       y)až  Add a SOLID entity. SOLID is a solid filled area with 3 or 4 edges
        and SOLID is a 2D entity.

        Args:
            vertices: iterable of 3 or 4 ``(x, y[, z])`` tuples, z-axis will be
                ignored.
            layer: layer name as string see :meth:`add_line`
            color: color as :ref:`ACI` see :meth:`add_line`
            linetype: line type as string see :meth:`add_line`

        ÚSOLIDr   Nr}   )r8   r   rh   ri   rj   s        r:   Ú	add_solidzR12FastStreamWriter.add_solid  s   € ð$ 	×Ñ ¨°1°e¸UÀHÕMr<   c                óÀ  — d|z  g}|j                  t        |||«      «       t        |«      }t        |«      dk  rt	        d|z  «      ‚t        |«      dk(  r|j                  |d   «       |j                  d„ t        |d¬«      D «       «       |r$|j                  t        dt        |«      «      «       | j                  j                  d	j                  |«      «       y )
Nz0
%s
r   z%s needs 3 or 4 vertices.éÿÿÿÿc              3  ó:   K  — | ]  \  }}t        ||«      –— Œ y ­wr>   )rd   )Ú.0r^   Úvertexs      r:   Ú	<genexpr>z9R12FastStreamWriter._add_quadrilateral.<locals>.<genexpr>,  s#   è ø€ ð 
á =‘��fô �v˜t×$Ù =ùs   ‚r#   )rf   éF   r`   )rb   rc   ÚlistÚlenrP   ÚextendÚ	enumeratero   rA   r9   r@   re   )r8   Údxftyper   Úflagsrh   ri   rj   rk   s           r:   r~   z&R12FastStreamWriter._add_quadrilateral  s¾   € ð ˜7Ñ"Ð#ˆØ�
‰
”;˜u e¨XÓ6Ô7Ü˜“>ˆÜˆx‹=˜1ÒÜÐ8¸7ÑBÓCÐCÜ�‹]˜aÒØ�O‰O˜H R™LÔ)Ø�
‰
ñ 
ä )¨(¸"Õ =ó
ô 	
ñ Ø�J‰J”w˜r¤3 u£:Ó.Ô/Ø�‰×Ñ˜"Ÿ'™' #›,Õ'r<   c           	     ó„  — dg}|j                  t        |||«      «       |j                  t        dd«      «       |j                  t        ddt        |«      z   «      «       | j                  j                  dj                  |«      «       dt        |«      z   t        dd«      z   }|D ]z  }| j                  j                  |«       t        |«      }t        |«      }	|	d	k  rt        d
«      ‚|	d	k(  r|d   |d   df}| j                  j                  t        |dd «      «       Œ| | j                  j                  d«       y)a†  Add a 3D POLYLINE entity.

        Args:
            vertices: iterable of ``(x, y[, z])`` tuples, z-axis is ``0`` by
                default
            closed: ``True`` creates a closed polyline
            layer: layer name as string see :meth:`add_line`
            color: color as :ref:`ACI` see :meth:`add_line`
            linetype: line type as string see :meth:`add_line`

        ú0
POLYLINE
éB   r   r‹   é   r`   ú	0
VERTEX
é    r   z,Vertices require at least a x- and a y-axis.r   Nr   ú	0
SEQEND
)rb   rc   ro   Úintr9   r@   re   Útupler�   rP   rd   )
r8   r   Úclosedrh   ri   rj   rk   Úvertex_templater‰   Ú
len_vertexs
             r:   Úadd_polylinez R12FastStreamWriter.add_polyline4  s  € ð& ÐˆØ�
‰
”;˜u e¨XÓ6Ô7Ø�
‰
”7˜2˜q“>Ô"Ø�
‰
”7˜2˜q¤3 v£;™Ó/Ô0Ø�‰×Ñ˜"Ÿ'™' #›,Ô'à'¬+°eÓ*<Ñ<¼wÀrÈ2»ÑNˆÛˆFØ�K‰K×Ñ˜oÔ.Ü˜6“]ˆFÜ˜V›ˆJØ˜AŠ~Ü Ð!OÓPÐPØ˜q’Ø  ™) V¨A¡Y°Ð2�Ø�K‰K×Ñœj¨°°¨Ó4Õ5ð ð 	�‰×Ñ˜-Õ(r<   c	                óô  ‡— dˆfd„}	dg}
|
j                  t        |||«      «       |
j                  t        dd«      «       |
j                  t        dt        |«      «      «       |r|
j                  t        d|«      «       |r|
j                  t        d|«      «       | j                  j                  dj                  |
«      «       d	t        |«      z   t        dd
«      z   }|D ]t  }| j                  j                  |«        |	|«      }‰D ]J  }|j                  |d
«      }|d
k(  r|dv rŒ| j                  j                  t        t        |   |«      «       ŒL Œv | j                  j                  d«       y)aî  Add a 2D POLYLINE entity with start width, end width and bulge value
        support.

        Format codes:

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

        Args:
            points: iterable of (x, y, [start_width, [end_width, [bulge]]])
                tuple, value order according to the `format` string, unset
                values default to ``0``
            format: format: format string, default is ``'xy'``
            closed: ``True`` creates a closed polyline
            start_width: default start width, default is ``0``
            end_width: default end width, default is ``0``
            layer: layer name as string see :meth:`add_line`
            color: color as :ref:`ACI` see :meth:`add_line`
            linetype: line type as string see :meth:`add_line`

        c                ó�   •— t        «       }t        ‰| «      D ]+  \  }}|dk(  rt        |«      }|d   |d<   |d   |d<   Œ'|||<   Œ- |S )NÚvr   r(   r   r)   )ÚdictÚziprš   )ÚdataÚattribsr^   Úvaluery   Úformats        €r:   Úvertex_attribsz;R12FastStreamWriter.add_polyline_2d.<locals>.vertex_attribs€  sY   ø€ Ü“fˆGÜ" 6¨4Ö0‘��eØ˜3’;Ü$ U›|�HØ#+¨A¡;�G˜C‘LØ#+¨A¡;�G˜C’Là$)�G˜D’Mð  1ð ˆNr<   r“   r”   r   r‹   r%   r&   r`   r–   r   Úsebr˜   N)r¤   r   rB   r¢   )	rb   rc   ro   r™   r9   r@   re   ÚgetÚVERTEX_GROUP_CODES)r8   Úpointsr§   r›   Ústart_widthÚ	end_widthrh   ri   rj   r¨   rk   rœ   Úpointr¥   Úformat_coder¦   s     `             r:   Úadd_polyline_2dz#R12FastStreamWriter.add_polyline_2dY  s8  ø€ õN		ð ÐˆØ�
‰
”;˜u e¨XÓ6Ô7Ø�
‰
”7˜2˜q“>Ô"Ø�
‰
”7˜2œs 6›{Ó+Ô,ÙØ�J‰J”w˜r ;Ó/Ô0ÙØ�J‰J”w˜r 9Ó-Ô.Ø�‰×Ñ˜"Ÿ'™' #›,Ô'à'¬+°eÓ*<Ñ<¼wÀrÈ1»~ÑMˆÛˆEØ�K‰K×Ñ˜oÔ.Ù$ UÓ+ˆGÛ%�ØŸ™ K°Ó3�Ø˜A’: +°Ñ"6ØØ—‘×!Ñ!ÜÔ.¨{Ñ;¸UÓCõñ	  &ð ð 	�‰×Ñ˜-Õ(r<   c                ó&  ‡ ‡‡‡‡‡‡‡— ddˆˆˆˆˆ ˆfd„}dd	ˆˆfd„}d
d	ˆˆˆfd„} |«       \  Š}	 |«       \  Š}
 |«        ‰ j                   j                  |	«       ‰ j                   j                  |
«       ‰ j                   j                  d«       y)aÍ  Add a POLYFACE entity. The POLYFACE entity supports only faces of
        maximum 4 vertices, more indices will be ignored. A simple square would
        be::

            v0 = (0, 0, 0)
            v1 = (1, 0, 0)
            v2 = (1, 1, 0)
            v3 = (0, 1, 0)
            dxf.add_polyface(vertices=[v0, v1, v2, v3], faces=[(0, 1, 2, 3)])

        All 3D form functions of the :mod:`ezdxf.render.forms` module return
        :class:`~ezdxf.render.MeshBuilder` objects, which provide the required
        vertex and face lists.

        See sphere example: https://github.com/mozman/ezdxf/blob/master/examples/r12writer.py

        Args:
            vertices: iterable of ``(x, y, z)`` tuples
            faces: iterable of 3 or 4 vertex indices, indices have to be 0-based
            layer: layer name as string see :meth:`add_line`
            color: color as :ref:`ACI` see :meth:`add_line`
            linetype: line type as string see :meth:`add_line`

        c                óp  •— dg}|j                  t        ‰‰‰«      «       |j                  t        dd«      «       |j                  t        d| «      «       |j                  t        d‰«      «       |j                  t        d‰«      «       ‰j                  j	                  dj                  |«      «       y )Nr“   r”   r   r‹   éG   éH   r`   ©rb   rc   ro   r9   r@   re   )r‘   rk   ri   Ú
face_countrh   rj   r8   Úvertex_counts     €€€€€€r:   Úwrite_polylinez8R12FastStreamWriter.add_polyface.<locals>.write_polylineÃ  s…   ø€ Ø"Ð#ˆCØ�J‰J”{ 5¨%°Ó:Ô;Ø�J‰J”w˜r 1“~Ô&Ø�J‰J”w˜r 5Ó)Ô*Ø�J‰J”w˜r <Ó0Ô1Ø�J‰J”w˜r :Ó.Ô/Ø�K‰K×Ñ˜bŸg™g c›lÕ+r<   c                ó  •— t        «       }d}dt        ‰«      z   t        d| «      z   }‰D ]2  }|dz  }|j                  |«       |j                  t	        |«      «       Œ4 |j                  «       }|j                  «        ||fS ©Nr   r–   r‹   r   )r   rc   ro   r@   rd   ÚgetvaluerR   )r‘   ÚbufÚcountr*   r‰   rh   r   s        €€r:   Úwrite_verticesz8R12FastStreamWriter.add_polyface.<locals>.write_verticesÌ  sx   ø€ Ü“*ˆCØˆEØ¤¨EÓ 2Ñ2´W¸RÀÓ5GÑGˆAÛ"�Ø˜‘
�Ø—	‘	˜!”Ø—	‘	œ* VÓ,Õ-ð #ð —‘“ˆAØ�I‰IŒKØ˜!�8ˆOr<   c           	     óR  •— t        «       }d}dt        ‰	‰«      z   t        d| «      z   t        d«      z   }‰D ]J  }|dz  }|j	                  |«       t        d|«      D ]#  \  }}|j	                  t        ||dz   «      «       Œ% ŒL |j                  «       }|j                  «        ||fS )Nr   r–   r‹   )r   r   r   r   )r´   rµ   éI   éJ   )r   rc   ro   rd   r@   r£   r¼   rR   )
r‘   r½   r¾   r*   Úfacer^   Úindexri   Úfacesrh   s
          €€€r:   Úwrite_facesz5R12FastStreamWriter.add_polyface.<locals>.write_facesØ  s°   ø€ Ü“*ˆCØˆEàÜ˜e UÓ+ñ,ä˜"˜eÓ$ñ%ô ˜YÓ'ñ(ð ó �Ø˜‘
�Ø—	‘	˜!”Ü#&Ð'7¸Ö#>‘K�D˜%Ø—I‘Iœg d¨E°A©IÓ6Õ7ñ $?ð ð
 —‘“ˆAØ�I‰IŒKØ˜!�8ˆOr<   r˜   N©é@   ©r‘   r™   rB   rC   )éÀ   )r‘   r™   )é€   r[   )r8   r   rÅ   rh   ri   rj   r¹   r¿   rÆ   Ú
vertex_strÚface_strr·   r¸   s   ``````     @@r:   Úadd_polyfacez R12FastStreamWriter.add_polyface¢  st   ÿ€ ÷B	,ó 	,÷
	÷	ð 	ñ$ $2Ó#3Ñ ˆ�jÙ*›}Ñˆ
�HÙÔØ�‰×Ñ˜*Ô%Ø�‰×Ñ˜(Ô#Ø�‰×Ñ˜-Õ(r<   c           
     óÐ   ‡ ‡‡‡‡‡
‡‡‡— |\  Š
Š|\  ŠŠddˆˆˆˆ
ˆˆˆˆ fd„}dd	ˆˆ ˆfd„} |«         |«       }	‰
‰z  |	k7  rt        d«      ‚‰ j                  j                  d«       y)
ao  Add a POLYMESH entity. A POLYMESH is a mesh of m rows and n columns,
        each mesh vertex has its own x-, y- and z coordinates. The mesh can be
        closed in m- and/or n-direction. The vertices have to be in column
        order:  (m0, n0), (m0, n1), (m0, n2), (m1, n0), (m1, n1), (m1, n2), ...

        See example: https://github.com/mozman/ezdxf/blob/master/examples/r12writer.py

        Args:
            vertices: iterable of ``(x, y, z)`` tuples, in column order
            size: mesh dimension as (m, n)-tuple, requirement:
                ``len(vertices) == m*n``
            closed: (m_closed, n_closed) tuple, for closed mesh in m and/or n
                direction
            layer: layer name as string see :meth:`add_line`
            color: color as :ref:`ACI` see :meth:`add_line`
            linetype: line type as string see :meth:`add_line`

        c                óŒ  •— ‰r| dz  } ‰r| dz  } dg}|j                  t        ‰‰‰«      «       |j                  t        dd«      «       |j                  t        d| «      «       |j                  t        d‰«      «       |j                  t        d‰«      «       ‰	j                  j	                  dj                  |«      «       y )	Nr   r—   r“   r”   r‹   r´   rµ   r`   r¶   )
r‘   rk   ri   rh   rj   ÚmÚm_closedÚnÚn_closedr8   s
     €€€€€€€€r:   r¹   z8R12FastStreamWriter.add_polymesh.<locals>.write_polyline  s›   ø€ ÙØ˜‘
�ÙØ˜‘�à"Ð#ˆCØ�J‰J”{ 5¨%°Ó:Ô;Ø�J‰J”w˜r 1“~Ô&Ø�J‰J”w˜r 5Ó)Ô*Ø�J‰J”w˜r 1“~Ô&Ø�J‰J”w˜r 1“~Ô&Ø�K‰K×Ñ˜bŸg™g c›lÕ+r<   c                óØ   •— d}dt        ‰«      z   t        d| «      z   }‰D ]F  }|dz  }‰j                  j                  |«       ‰j                  j                  t	        |«      «       ŒH |S r»   )rc   ro   r9   r@   rd   )r‘   r¾   r*   r‰   rh   r8   r   s       €€€r:   r¿   z8R12FastStreamWriter.add_polymesh.<locals>.write_vertices  sf   ø€ ØˆEØ¤¨EÓ 2Ñ2´W¸RÀÓ5GÑGˆAÛ"�Ø˜‘
�Ø—‘×!Ñ! !Ô$Ø—‘×!Ñ!¤*¨VÓ"4Õ5ð #ð ˆLr<   zInvalid mesh dimensions.r˜   N)é   rÉ   rÇ   )r‘   r™   rB   r™   )rP   r9   r@   )r8   r   Úsizer›   rh   ri   rj   r¹   r¿   r¾   rÑ   rÒ   rÓ   rÔ   s   ``  ```   @@@@r:   Úadd_polymeshz R12FastStreamWriter.add_polymeshñ  sf   ÿø€ ð6 ‰ˆˆ1Ø#Ñˆ�(÷	,õ 	,÷	ð 	ñ 	ÔÙÓ ˆØˆq‰5�EŠ>ÜÐ7Ó8Ð8à�‰×Ñ˜-Õ(r<   c           
     óè  — dg}|j                  t        |	|
«      «       |j                  t        |d¬«      «       |j                  t        dt	        |«      «      «       |j                  t        dt	        t        |«      «      «      «       |dk7  r-|j                  t        dt	        t        |«      «      «      «       |dk7  r-|j                  t        d	t	        t        |«      «      «      «       |dk7  r-|j                  t        d
t	        t        |«      «      «      «       |dk7  r$|j                  t        dt	        |«      «      «       t        |j                  «          \  }}|j                  t        dt	        |«      «      «       |j                  t        dt	        |«      «      «       |j                  t        |d¬«      «       | j                  j                  dj                  |«      «       y)aA  Add a one line TEXT entity.

        Args:
            text: the text as string
            insert: insert location as ``(x, y)`` tuple
            height: text height in drawing units
            width: text width as factor
            align: text alignment, see table below
            rotation: text rotation in degrees as float
            oblique: oblique in degrees as float, vertical = ``0`` (default)
            style: text style name as string, if FIXED-TABLES are written some
                predefined text styles are available, else text style is
                always ``'STANDARD'``.
            layer: layer name as string see :meth:`add_line`
            color: color as :ref:`ACI` see :meth:`add_line`

        ============   =============== ================= =====
        Vert/Horiz     Left            Center            Right
        ============   =============== ================= =====
        Top            ``TOP_LEFT``    ``TOP_CENTER``    ``TOP_RIGHT``
        Middle         ``MIDDLE_LEFT`` ``MIDDLE_CENTER`` ``MIDDLE_RIGHT``
        Bottom         ``BOTTOM_LEFT`` ``BOTTOM_CENTER`` ``BOTTOM_RIGHT``
        Baseline       ``LEFT``        ``CENTER``         ``RIGHT``
        ============   =============== ================= =====

        The special alignments ``ALIGNED`` and ``FIT`` are not available.

        z0
TEXT
r#   r]   r   r%   ç      ð?r&   ç        ru   rv   ÚSTANDARDé   rµ   rÁ   r_   r`   N)rb   rc   rd   ro   rA   rp   ÚTEXT_ALIGN_FLAGSÚupperr9   r@   re   )r8   ÚtextÚinsertÚheightÚwidthÚalignÚrotationÚobliqueÚstylerh   ri   rk   ÚhalignÚvaligns                 r:   Úadd_textzR12FastStreamWriter.add_text-  s[  € ðT ˆmˆØ�
‰
”;˜u eÓ,Ô-Ø�
‰
”:˜f¨2Ô.Ô/Ø�
‰
”7˜1œc $›iÓ(Ô)Ø�
‰
”7˜2œs¤3 v£;Ó/Ó0Ô1Ø�CŠ<Ø�J‰J”w˜r¤3¤s¨5£z£?Ó3Ô4Ø�sŠ?Ø�J‰J”w˜r¤3¤s¨8£}Ó#5Ó6Ô7Ø�cŠ>Ø�J‰J”w˜r¤3¤s¨7£|Ó#4Ó5Ô6Ø�JÒØ�J‰J”w˜q¤# e£*Ó-Ô.Ü)¨%¯+©+«-Ñ8‰ˆ�Ø�
‰
”7˜2œs 6›{Ó+Ô,Ø�
‰
”7˜2œs 6›{Ó+Ô,Ø�
‰
”:˜f¨2Ô.Ô/Ø�‰×Ñ˜"Ÿ'™' #›,Õ'r<   )F)r9   r   )rB   rC   )Ú0NN)rf   ÚVertexrg   rì   rh   rA   ri   úOptional[int]rj   úOptional[str]rB   rC   )rq   rì   rr   Úfloatrh   rA   ri   rí   rj   rî   rB   rC   )r   ih  rë   NN)rq   rì   rr   rï   rf   rï   rg   rï   rh   rA   ri   rí   rj   rî   rB   rC   )
ry   rì   rh   rA   ri   rí   rj   rî   rB   rC   )r   rë   NN)r   úIterable[Vertex]r€   r™   rh   rA   ri   rí   rj   rî   rB   rC   )
r   rð   rh   rA   ri   rí   rj   rî   rB   rC   )r�   rA   r   rð   r‘   r™   rh   rA   ri   rí   rj   rî   rB   rC   )Frë   NN)r   rð   r›   Úboolrh   rA   ri   rí   rj   rî   rB   rC   )ÚxyFr   r   rë   NN)r¬   zIterable[Sequence]r§   rA   r›   rñ   r­   rï   r®   rï   rh   rA   ri   rí   rj   rî   rB   rC   )r   rð   rÅ   zIterable[Sequence[int]]rh   rA   ri   rí   rj   rî   rB   rC   ))FFrë   NN)r   rð   r×   ztuple[int, int]rh   rA   ri   rí   rj   rî   rB   rC   )	r   rÚ   rÚ   r   rÛ   rÛ   rÜ   rë   N)rà   rA   rá   rì   râ   rï   rã   rï   rä   rA   rå   rï   ræ   rï   rç   rA   rh   rA   ri   rí   rB   rC   )rD   rE   rF   Ú__doc__r;   rR   rl   rs   rw   rz   r�   r„   r~   rž   r±   rÎ   rØ   rê   rG   r<   r:   rQ   rQ   e   s#  „ ñô2ó1ð Ø#Ø"&ð(àð(ð ð(ð ð	(ð
 ð(ð  ð(ð 
ó(ðF Ø#Ø"&ð(àð(ð ð(ð ð	(ð
 ð(ð  ð(ð 
ó(ð8 ØØØ#Ø"&ð(àð(ð ð(ð ð	(ð
 ð(ð ð(ð ð(ð  ð(ð 
ó(ðD Ø#Ø"&ð(àð(ð ð(ð ð	(ð
  ð(ð 
ó(ð2 ØØ#Ø"&ð
à"ð
ð ð
ð ð	
ð
 ð
ð  ð
ð 
ó
ðF Ø#Ø"&ðNà"ðNð ðNð ð	Nð
  ðNð 
óNð((àð(ð #ð(ð ð	(ð
 ð(ð ð(ð  ð(ð 
ó(ð6 ØØ#Ø"&ð#)à"ð#)ð ð#)ð ð	#)ð
 ð#)ð  ð#)ð 
ó#)ðP ØØØØØ#Ø"&ðG)à"ðG)ð ðG)ð ð	G)ð
 ðG)ð ðG)ð ðG)ð ðG)ð  ðG)ð 
óG)ðZ Ø#Ø"&ðM)à"ðM)ð 'ðM)ð ð	M)ð
 ðM)ð  ðM)ð 
óM)ðf ØØ#Ø"&ð:)à"ð:)ð ð:)ð
 ð:)ð ð:)ð  ð:)ð 
ó:)ð~  ØØØØØØØØ#ð;(àð;(ð ð;(ð ð	;(ð
 ð;(ð ð;(ð ð;(ð ð;(ð ð;(ð ð;(ð ð;(ð 
ô;(r<   rQ   Nc                óâ   — d| z  g}|�|j                  d|z  «       |�Adt        |«      cxk  rdk  r"n t        d«      ‚|j                  d|z  «       nt        d«      ‚dj                  |«      S )Nz8
%s
z6
%s
r   i  z62
%d
z6color has to be an integer in the range from 0 to 256.r`   )rb   r™   rP   re   )rh   ri   rj   rk   s       r:   rc   rc   k  s„   € ð �uÑÐ
€CØÐØ�
‰
�9˜xÑ'Ô(ØÐØ”�E“
Ô ˜SÔ ô ØHóð ð �J‰J�z EÑ)Õ*äØHóð ð �7‰7�3‹<Ðr<   c           
     ó�   — g }| D ]/  }|j                  d|t        t        |«      «      fz  «       |dz  }Œ1 dj                  |«      S )Nú%d
%s
r#   r`   )rb   rA   rp   re   )r‰   r^   rk   Úcs       r:   rd   rd   {  sH   € Ø
€CÛˆØ�
‰
�: ¤s¬3¨q«6£{Ð 3Ñ3Ô4Ø�‰
‰ð ð �7‰7�3‹<Ðr<   c                ó   — d| |fz  S )Nrö   rG   )r^   r¦   s     r:   ro   ro   ƒ  s   € Ø˜˜u˜Ñ%Ð%r<   Úxysebva9    0
SECTION
  2
HEADER
  9
$ACADVER
  1
AC1009
  9
$DWGCODEPAGE
  3
ANSI_1252
  0
ENDSEC
  0
SECTION
  2
TABLES
  0
TABLE
  2
LTYPE
  5
431
 70
20
  0
LTYPE
  5
40F
  2
CONTINUOUS
 70
0
  3
Solid line
 72
65
 73
0
 40
0.0
  0
LTYPE
  5
410
  2
CENTER
 70
0
  3
Center ____ _ ____ _ ____ _ ____ _ ____ _ ____
 72
65
 73
4
 40
2.0
 49
1.25
 49
-0.25
 49
0.25
 49
-0.25
  0
LTYPE
  5
411
  2
DASHED
 70
0
  3
Dashed __ __ __ __ __ __ __ __ __ __ __ __ __ _
 72
65
 73
2
 40
0.75
 49
0.5
 49
-0.25
  0
LTYPE
  5
412
  2
PHANTOM
 70
0
  3
Phantom ______  __  __  ______  __  __  ______
 72
65
 73
6
 40
2.5
 49
1.25
 49
-0.25
 49
0.25
 49
-0.25
 49
0.25
 49
-0.25
  0
LTYPE
  5
413
  2
HIDDEN
 70
0
  3
Hidden __ __ __ __ __ __ __ __ __ __ __ __ __ __
 72
65
 73
2
 40
9.525
 49
6.345
 49
-3.175
  0
LTYPE
  5
43B
  2
CENTERX2
 70
0
  3
Center (2x) ________  __  ________  __  ________
 72
65
 73
4
 40
3.5
 49
2.5
 49
-0.25
 49
0.5
 49
-0.25
  0
LTYPE
  5
43C
  2
CENTER2
 70
0
  3
Center (.5x) ____ _ ____ _ ____ _ ____ _ ____
 72
65
 73
4
 40
1.0
 49
0.625
 49
-0.125
 49
0.125
 49
-0.125
  0
LTYPE
  5
43D
  2
DASHEDX2
 70
0
  3
Dashed (2x) ____  ____  ____  ____  ____  ____
 72
65
 73
2
 40
1.2
 49
1.0
 49
-0.2
  0
LTYPE
  5
43E
  2
DASHED2
 70
0
  3
Dashed (.5x) _ _ _ _ _ _ _ _ _ _ _ _ _ _
 72
65
 73
2
 40
0.3
 49
0.25
 49
-0.05
  0
LTYPE
  5
43F
  2
PHANTOMX2
 70
0
  3
Phantom (2x)____________    ____    ____    ____________
 72
65
 73
6
 40
4.25
 49
2.5
 49
-0.25
 49
0.5
 49
-0.25
 49
0.5
 49
-0.25
  0
LTYPE
  5
440
  2
PHANTOM2
 70
0
  3
Phantom (.5x) ___ _ _ ___ _ _ ___ _ _ ___ _ _ ___
 72
65
 73
6
 40
1.25
 49
0.625
 49
-0.125
 49
0.125
 49
-0.125
 49
0.125
 49
-0.125
  0
LTYPE
  5
441
  2
DASHDOT
 70
0
  3
Dash dot __ . __ . __ . __ . __ . __ . __ . __
 72
65
 73
4
 40
1.4
 49
1.0
 49
-0.2
 49
0.0
 49
-0.2
  0
LTYPE
  5
442
  2
DASHDOTX2
 70
0
  3
Dash dot (2x) ____  .  ____  .  ____  .  ____
 72
65
 73
4
 40
2.4
 49
2.0
 49
-0.2
 49
0.0
 49
-0.2
  0
LTYPE
  5
443
  2
DASHDOT2
 70
0
  3
Dash dot (.5x) _ . _ . _ . _ . _ . _ . _ . _
 72
65
 73
4
 40
0.7
 49
0.5
 49
-0.1
 49
0.0
 49
-0.1
  0
LTYPE
  5
444
  2
DOT
 70
0
  3
Dot .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .
 72
65
 73
2
 40
0.2
 49
0.0
 49
-0.2
  0
LTYPE
  5
445
  2
DOTX2
 70
0
  3
Dot (2x) .    .    .    .    .    .    .    .
 72
65
 73
2
 40
0.4
 49
0.0
 49
-0.4
  0
LTYPE
  5
446
  2
DOT2
 70
0
  3
Dot (.5) . . . . . . . . . . . . . . . . . . .
 72
65
 73
2
 40
0.1
 49
0.0
 49
-0.1
  0
LTYPE
  5
447
  2
DIVIDE
 70
0
  3
Divide __ . . __ . . __ . . __ . . __ . . __
 72
65
 73
6
 40
1.6
 49
1.0
 49
-0.2
 49
0.0
 49
-0.2
 49
0.0
 49
-0.2
  0
LTYPE
  5
448
  2
DIVIDEX2
 70
0
  3
Divide (2x) ____  . .  ____  . .  ____  . .  ____
 72
65
 73
6
 40
2.6
 49
2.0
 49
-0.2
 49
0.0
 49
-0.2
 49
0.0
 49
-0.2
  0
LTYPE
  5
449
  2
DIVIDE2
 70
0
  3
Divide(.5x) _ . _ . _ . _ . _ . _ . _ . _
 72
65
 73
6
 40
0.8
 49
0.5
 49
-0.1
 49
0.0
 49
-0.1
 49
0.0
 49
-0.1
  0
ENDTAB
  0
TABLE
  2
STYLE
  5
433
 70
18
  0
STYLE
  5
417
  2
STANDARD
 70
0
 40
0.0
 41
1.0
 50
0.0
 71
0
 42
0.2
  3
txt
  4

  0
STYLE
  5
44A
  2
OpenSans
 70
0
 40
0.0
 41
1.0
 50
0.0
 71
0
 42
1.0
  3
OpenSans-Regular.ttf
  4

  0
STYLE
  5
44F
  2
OpenSansCondensed-Light
 70
0
 40
0.0
 41
1.0
 50
0.0
 71
0
 42
1.0
  3
OpenSansCondensed-Light.ttf
  4

  0
ENDTAB
  0
TABLE
  2
VIEW
  5
434
 70
0
  0
ENDTAB
  0
ENDSEC
)FrI   )r9   z"Union[TextIO, BinaryIO, str, Path]rS   rñ   rT   rA   rB   zIterator[R12FastStreamWriter])NN)rh   rA   ri   rí   rj   rî   rB   rA   )r#   )r‰   rì   rB   rA   )r^   r™   rB   rA   )$Ú
__future__r   Útypingr   r   r   r   r   r	   r
   r   Ú
contextlibr   Ú	functoolsr   Úior   Úpathlibr   Úezdxf.lldxf.tagwriterr   rï   rì   Úroundrp   rÞ   r«   r.   rV   rQ   rc   rd   ro   Ú	frozensetÚFORMAT_CODESrY   rG   r<   r:   Ú<module>r     s"  ðõ #÷	÷ 	ó 	õ &Ý Ý Ý Ý 1à	�%‰€Ùˆe˜QÔ€ð ØØØØØØØØØØØñÐ ð  B¨R°b¸rÑBÐ ÷%ñ %ð ð Øð%Ø.ð%àð%ð 
ð%ð #ò	%ó ð%÷PC(ñ C(ðN HLðØðØ$ðØ7Dðàóô ó&ñ ˜Ó"€ðH	�r<   