Ë
    £èh¬<  ã                  óò   — d dl mZ d dlmZmZmZmZmZmZ d dl	Z	d dl
Z
d dlZd dlmZmZmZ  edee«      Zg d¢Z G d„ dee   e	j&                  «      Z G d	„ d
ee   «      Z G d„ dee   «      Zdd„Zdd„Zy)é    )Úannotations)ÚIterableÚOptionalÚIteratorÚSequenceÚTypeVarÚGenericN)ÚVec3ÚVec2ÚUVecÚT)ÚBoundingBox2dÚBoundingBoxÚAbstractBoundingBoxc                  ó¼  — e Zd ZU ded<   ded<   ej
                  ddd„«       Zd„ Zdd„Zdd„Z	dd	„Z
ej
                  dd
„«       Zeej
                  dd„«       «       Zej
                  dd„«       Zej
                  d d„«       Zej
                  d d„«       Zej
                  d!d„«       Zd d„Zd"d„Zd"d„Zedd„«       Zed#d„«       Zed#d„«       Zd!d„Zd$d„Zd%d„Zy)&r   r   ÚextminÚextmaxNc                 ó   — y ©N© ©ÚselfÚverticess     ú/lib/python3.12/site-packages/ezdxf/math/bbox.pyÚ__init__zAbstractBoundingBox.__init__   ó   € àó    c                ój   — | j                  «       }| j                  |_        | j                  |_        |S r   )Ú	__class__r   r   )r   Úboxs     r   ÚcopyzAbstractBoundingBox.copy   s)   € Ø�n‰nÓˆØ—[‘[ˆŒ
Ø—[‘[ˆŒ
Øˆ
r   c                ó<   — d| j                   › d| j                  › d�S )NÚ[z, Ú]©r   r   ©r   s    r   Ú__str__zAbstractBoundingBox.__str__   s   € Ø�4—;‘;�-˜r $§+¡+ ¨aÐ0Ð0r   c                ó|   — | j                   j                  }| j                  r|› d| j                  «       › d�S |› d�S )NÚ(Ú)z())r   Ú__name__Úhas_datar'   )r   Únames     r   Ú__repr__zAbstractBoundingBox.__repr__!   s>   € Ø�~‰~×&Ñ&ˆØ�=Š=Ø�V˜1˜TŸ\™\›^Ð,¨AÐ.Ð.à�V˜2�;Ðr   c              #  ó^   K  — | j                   r| j                  –— | j                  –— y y ­wr   )r,   r   r   r&   s    r   Ú__iter__zAbstractBoundingBox.__iter__(   s&   è ø€ Ø�=Š=Ø—+‘+ÒØ—+‘+Óð ùs   ‚+-c                 ó   — y r   r   r   s     r   ÚextendzAbstractBoundingBox.extend-   r   r   c                 ó   — y r   r   r&   s    r   Úis_emptyzAbstractBoundingBox.is_empty1   s   € ð 	r   c                 ó   — y r   r   )r   Úvertexs     r   ÚinsidezAbstractBoundingBox.inside6   r   r   c                 ó   — y r   r   ©r   Úothers     r   Úhas_intersectionz$AbstractBoundingBox.has_intersection:   r   r   c                 ó   — y r   r   r9   s     r   Úhas_overlapzAbstractBoundingBox.has_overlap>   r   r   c                 ó   — y r   r   r9   s     r   Úintersectionz AbstractBoundingBox.intersectionB   r   r   c                ór   — | j                  |j                  «      xr | j                  |j                  «      S )zfReturns ``True`` if the `other` bounding box is completely inside
        this bounding box.

        )r7   r   r   r9   s     r   ÚcontainszAbstractBoundingBox.containsF   s)   € ð
 �{‰{˜5Ÿ<™<Ó(ÒF¨T¯[©[¸¿¹Ó-FÐFr   c                óF   ‡ — ‰ j                   rt        ˆ fd„|D «       «      S y)ztReturns ``True`` if any vertex is inside this bounding box.

        Vertices at the box border are inside!
        c              3  ó@   •K  — | ]  }‰j                  |«      –— Œ y ­wr   )r7   )Ú.0Úvr   s     €r   Ú	<genexpr>z1AbstractBoundingBox.any_inside.<locals>.<genexpr>S   s   øè ø€ Ð8©x¨!�t—{‘{ 1—~©xùs   ƒF)r,   Úanyr   s   ` r   Ú
any_insidezAbstractBoundingBox.any_insideM   s    ø€ ð
 �=Š=ÜÓ8©xÓ8Ó8Ð8Ør   c                ó\   — | j                   r d}|D ]  }d}| j                  |«      rŒ y |S y)zwReturns ``True`` if all vertices are inside this bounding box.

        Vertices at the box border are inside!
        FT)r,   r7   )r   r   Úhas_anyrE   s       r   Ú
all_insidezAbstractBoundingBox.all_insideV   s7   € ð
 �=Š=àˆGÛ�Ø�Ø—{‘{ 1•~Ù ð ð ˆNØr   c                óT   — t        j                  | j                  j                  «      S )z5Returns ``True`` if the bonding box has known limits.)ÚmathÚisfiniter   Úxr&   s    r   r,   zAbstractBoundingBox.has_datae   s   € ô �}‰}˜TŸ[™[Ÿ]™]Ó+Ð+r   c                ó4   — | j                   | j                  z
  S )zReturns size of bounding box.)r   r   r&   s    r   ÚsizezAbstractBoundingBox.sizej   s   € ð �{‰{˜TŸ[™[Ñ(Ð(r   c                óL   — | j                   j                  | j                  «      S )zReturns center of bounding box.)r   Úlerpr   r&   s    r   ÚcenterzAbstractBoundingBox.centero   s   € ð �{‰{×Ñ §¡Ó,Ð,r   c                óœ   — g }| j                   r|j                  | «       |j                   r|j                  |«       | j                  |«      S )zVReturns a new bounding box as union of this and `other` bounding
        box.
        )r,   r2   r   )r   r:   r   s      r   ÚunionzAbstractBoundingBox.uniont   s>   € ð ˆØ�=Š=Ø�O‰O˜DÔ!Ø�>Š>Ø�O‰O˜EÔ"Ø�~‰~˜hÓ'Ð'r   c                óÈ   — | j                   rL| j                  ^}}}| j                  ^}}}t        ||«      t        ||«      t        ||«      t        ||«      fS t	        d«      ‚)zbReturns the corners of the bounding box in the xy-plane as
        :class:`Vec2` objects.
        úempty bounding box)r,   r   r   r   Ú
ValueError)r   Úx0Úy0Ú_Úx1Úy1s         r   Úrect_verticesz!AbstractBoundingBox.rect_vertices   s\   € ð �=Š=ØŸ™ˆJˆB��QØŸ™ˆJˆB��QÜ˜˜B“<¤ b¨"£¬t°B¸«|¼TÀ"Àb»\ÐIÐIäÐ1Ó2Ð2r   c                ó   — | j                   rr|dk  r)t        | j                  «      }| |dz  k\  rt        d«      ‚| xj                  t        |||«      z  c_        | xj                  t        | | | «      z  c_        yy)züGrow or shrink the bounding box by an uniform value in x, y and
        z-axis. A negative value shrinks the bounding box.
        Raises :class:`ValueError` for shrinking the size of the bounding box to
        zero or below in any dimension.
        ç        g       @z%shrinking one or more dimensions <= 0N)r,   ÚminrQ   rY   r   r
   r   )r   ÚvalueÚmin_exts      r   ÚgrowzAbstractBoundingBox.growŠ   sr   € ð �=Š=Ø�sŠ{Ü˜dŸi™i›.�Ø�6˜W s™]Ò*Ü$Ð%LÓMÐMØ�KŠKœ4  u¨eÓ4Ñ4�KØ�KŠKœ4  ¨¨°°Ó7Ñ7ŽKð r   r   ©r   zOptional[Iterable[UVec]])ÚreturnÚstr)rg   zIterator[T]©r   úIterable[UVec]rg   ÚNone©rg   Úbool©r6   r   rg   rm   ©r:   úAbstractBoundingBox[T]rg   rm   )r:   rp   rg   rp   )r   rj   rg   rm   )rg   r   )rg   zSequence[Vec2])rc   Úfloatrg   rk   )r+   Ú
__module__Ú__qualname__Ú__annotations__ÚabcÚabstractmethodr   r!   r'   r.   r0   r2   Úpropertyr4   r7   r;   r=   r?   rA   rH   rK   r,   rQ   rT   rV   r_   re   r   r   r   r   r      s7  … ØƒIØƒIà×Ñóó ðòó1óóð
 	×Ñòó ðð Ø×Ñòó ó ðð 	×Ñòó ðð 	×Ñòó ðð 	×Ñòó ðð 	×Ñòó ðóGóóð ò,ó ð,ð ò)ó ð)ð ò-ó ð-ó	(ó	3ô8r   r   c                  ó`   — e Zd ZdZdZddd„Zedd„«       Zdd„Zdd„Z	dd„Z
dd	„Zdd
„Zdd„Zy)r   zm3D bounding box.

    Args:
        vertices: iterable of ``(x, y, z)`` tuples or :class:`Vec3` objects

    r%   Nc                óô   — t        t        j                  t        j                  t        j                  «      | _        | j                  | _        |�	 t        |«      \  | _        | _        y y # t        $ r Y y w xY wr   )r
   rM   Úinfr   r   Ú	extents3drY   r   s     r   r   zBoundingBox.__init__£   s`   € Üœ4Ÿ8™8¤T§X¡X¬t¯x©xÓ8ˆŒØ—k‘kˆŒØÐðÜ+4°XÓ+>Ñ(�”˜T�[ð  øô ò áðús   ÁA+ Á+	A7Á6A7c                óR   — | j                   r| j                  \  }}}||z  |z  dk(  S y)z�Returns ``True`` if the bounding box is empty or the bounding box
        has a size of 0 in any or all dimensions or is undefined.

        ra   T©r,   rQ   )r   ÚsxÚsyÚszs       r   r4   zBoundingBox.is_empty­   s0   € ð �=Š=ØŸ™‰JˆB��BØ˜‘7˜R‘< 3Ñ&Ð&Ør   c                ó¶   — t        |«      }|sy| j                  r'|j                  | j                  | j                  g«       t        |«      \  | _        | _        y©z`Extend bounds by `vertices`.

        Args:
            vertices: iterable of vertices

        N)Úlistr,   r2   r   r   r{   ©r   r   rE   s      r   r2   zBoundingBox.extend¸   óE   € ô �‹NˆÙØØ�=Š=Ø�H‰H�d—k‘k 4§;¡;Ð/Ô0Ü#,¨Q£<Ñ ˆŒ�T•[r   c                ó  — | j                   syt        |«      j                  \  }}}| j                  j                  \  }}}| j                  j                  \  }}	}
||cxk  xr |k  nc xr" ||cxk  xr |	k  nc xr ||cxk  xr |
k  S c S ©zrReturns ``True`` if `vertex` is inside this bounding box.

        Vertices at the box border are inside!
        F)r,   r
   Úxyzr   r   )r   r6   rO   ÚyÚzÚxminÚyminÚzminÚxmaxÚymaxÚzmaxs              r   r7   zBoundingBox.insideÆ   s   € ð
 �}Š}ØÜ�v“,×"Ñ"‰ˆˆ1ˆaØŸ;™;Ÿ?™?Ñˆˆd�DØŸ;™;Ÿ?™?Ñˆˆd�DØ˜Ö!˜TÔ!ÒR¨°Ö(9°TÔ(9ÒRÀÈÖ@QÈTÑ@QÐRÑ@QÐRr   c                ó:  — | j                   r|j                   syt        |j                  «      }t        |j                  «      }| j                  j                  |j                  k\  ry| j                  j                  |j                  k  ry| j                  j
                  |j
                  k\  ry| j                  j
                  |j
                  k  ry| j                  j                  |j                  k\  ry| j                  j                  |j                  k  ryy)aG  Returns ``True`` if this bounding box intersects with `other` but does
        not include touching bounding boxes, see also :meth:`has_overlap`::

            bbox1 = BoundingBox([(0, 0, 0), (1, 1, 1)])
            bbox2 = BoundingBox([(1, 1, 1), (2, 2, 2)])
            assert bbox1.has_intersection(bbox2) is False

        FT©r,   r
   r   r   rO   r‰   rŠ   ©r   r:   Úo_minÚo_maxs       r   r;   zBoundingBox.has_intersectionÒ   s¿   € ð �}Š} E§N¢NØÜ�U—\‘\Ó"ˆÜ�U—\‘\Ó"ˆð �;‰;�=‰=˜EŸG™GÒ#ØØ�;‰;�=‰=˜EŸG™GÒ#ØØ�;‰;�=‰=˜EŸG™GÒ#ØØ�;‰;�=‰=˜EŸG™GÒ#ØØ�;‰;�=‰=˜EŸG™GÒ#ØØ�;‰;�=‰=˜EŸG™GÒ#ØØr   c                ó:  — | j                   r|j                   syt        |j                  «      }t        |j                  «      }| j                  j                  |j                  kD  ry| j                  j                  |j                  k  ry| j                  j
                  |j
                  kD  ry| j                  j
                  |j
                  k  ry| j                  j                  |j                  kD  ry| j                  j                  |j                  k  ryy)aG  Returns ``True`` if this bounding box intersects with `other` but
        in contrast to :meth:`has_intersection` includes touching bounding boxes too::

            bbox1 = BoundingBox([(0, 0, 0), (1, 1, 1)])
            bbox2 = BoundingBox([(1, 1, 1), (2, 2, 2)])
            assert bbox1.has_overlap(bbox2) is True

        FTr’   r“   s       r   r=   zBoundingBox.has_overlapñ   s½   € ð �}Š} E§N¢NØÜ�U—\‘\Ó"ˆÜ�U—\‘\Ó"ˆà�;‰;�=‰=˜5Ÿ7™7Ò"ØØ�;‰;�=‰=˜5Ÿ7™7Ò"ØØ�;‰;�=‰=˜5Ÿ7™7Ò"ØØ�;‰;�=‰=˜5Ÿ7™7Ò"ØØ�;‰;�=‰=˜5Ÿ7™7Ò"ØØ�;‰;�=‰=˜5Ÿ7™7Ò"ØØr   c                ó4  — | j                   r‚| j                  \  }}}| j                  \  }}}t        |||«      t        |||«      t        |||«      t        |||«      t        |||«      t        |||«      t        |||«      t        |||«      fS t	        d«      ‚)zDReturns the 3D corners of the bounding box as :class:`Vec3` objects.rX   )r,   r   r   r
   rY   )r   rZ   r[   Úz0r]   r^   Úz1s          r   Úcube_verticeszBoundingBox.cube_vertices  sŸ   € à�=Š=ØŸ™‰JˆB��BØŸ™‰JˆB��Bä�R˜˜RÓ Ü�R˜˜RÓ Ü�R˜˜RÓ Ü�R˜˜RÓ Ü�R˜˜RÓ Ü�R˜˜RÓ Ü�R˜˜RÓ Ü�R˜˜RÓ ð	ð 	ô Ð1Ó2Ð2r   c           	     ó¾  — | j                  «       }| j                  |«      s|S t        | j                  «      \  }}}t        |j                  «      \  }}}t        | j                  «      \  }	}
}t        |j                  «      \  }}}|j                  t        ||«      t        ||«      t        ||«      ft        |	|«      t        |
|«      t        ||«      fg«       |S )z¥Returns the bounding box of the intersection cube of both
        3D bounding boxes. Returns an empty bounding box if the intersection
        volume is 0.

        )r   r;   r
   r   r   r2   Úmaxrb   )r   r:   Únew_bboxÚs_min_xÚs_min_yÚs_min_zÚo_min_xÚo_min_yÚo_min_zÚs_max_xÚs_max_yÚs_max_zÚo_max_xÚo_max_yÚo_max_zs                  r   r?   zBoundingBox.intersection!  sÙ   € ð —>‘>Ó#ˆØ×$Ñ$ UÔ+ØˆOÜ$(¨¯©Ó$5Ñ!ˆ�˜'Ü$(¨¯©Ó$6Ñ!ˆ�˜'Ü$(¨¯©Ó$5Ñ!ˆ�˜'Ü$(¨¯©Ó$6Ñ!ˆ�˜'Ø�‰ô ˜ Ó)Ü˜ Ó)Ü˜ Ó)ðô ˜ Ó)Ü˜ Ó)Ü˜ Ó)ððô	
ð ˆr   r   rf   rl   ri   rn   ro   )rg   zSequence[Vec3])r:   rp   rg   r   )r+   rr   rs   Ú__doc__Ú	__slots__r   rw   r4   r2   r7   r;   r=   rš   r?   r   r   r   r   r   ™   sF   „ ñð %€Iôð òó ðó0ó
Sóó>ó<3ô$r   r   c                  óX   — e Zd ZdZdZddd„Zedd„«       Zdd„Zdd„Z	dd„Z
dd	„Zdd
„Zy)r   zo2D bounding box.

    Args:
        vertices: iterable of ``(x, y[, z])`` tuples or :class:`Vec3` objects

    r%   Nc                óÖ   — t        t        j                  t        j                  «      | _        | j                  | _        |�	 t        |«      \  | _        | _        y y # t        $ r Y y w xY wr   )r   rM   rz   r   r   Ú	extents2drY   r   s     r   r   zBoundingBox2d.__init__I  sZ   € Üœ4Ÿ8™8¤T§X¡XÓ.ˆŒØ—k‘kˆŒØÐðÜ+4°XÓ+>Ñ(�”˜T�[ð  øô ò áðús   ÁA Á	A(Á'A(c                óJ   — | j                   r| j                  \  }}||z  dk(  S y)zŠReturns ``True`` if the bounding box is empty. The bounding box has a
        size of 0 in any or all dimensions or is undefined.
        ra   Tr}   )r   r~   r   s      r   r4   zBoundingBox2d.is_emptyS  s)   € ð
 �=Š=Ø—Y‘Y‰FˆB�Ø˜‘7˜c‘>Ð!Ør   c                ó¶   — t        |«      }|sy| j                  r'|j                  | j                  | j                  g«       t        |«      \  | _        | _        yr‚   )rƒ   r,   r2   r   r   r®   r„   s      r   r2   zBoundingBox2d.extend]  r…   r   c                ó  — | j                   syt        |«      }| j                  }| j                  }|j                  |j                  cxk  xr |j                  k  nc xr. |j
                  |j
                  cxk  xr |j
                  k  S c S r‡   )r,   r   r   r   rO   r‰   )r   r6   rE   Úmin_Úmax_s        r   r7   zBoundingBox2d.insidek  sf   € ð
 �}Š}ØÜ�‹LˆØ�{‰{ˆØ�{‰{ˆØ—‘˜!Ÿ#™#Ö' §¡Ô'ÒF¨d¯f©f¸¿¹Ö.E¸t¿v¹vÑ.EÐFÑ.EÐFr   c                ó¦  — | j                   r|j                   sy| j                  j                  |j                  j                  k\  ry| j                  j                  |j                  j                  k  ry| j                  j                  |j                  j                  k\  ry| j                  j                  |j                  j                  k  ryy)a?  Returns ``True`` if this bounding box intersects with `other` but does
        not include touching bounding boxes, see also :meth:`has_overlap`::

            bbox1 = BoundingBox2d([(0, 0), (1, 1)])
            bbox2 = BoundingBox2d([(1, 1), (2, 2)])
            assert bbox1.has_intersection(bbox2) is False

        FT©r,   r   rO   r   r‰   r9   s     r   r;   zBoundingBox2d.has_intersectionw  sƒ   € ð �}Š} E§N¢NØà�;‰;�=‰=˜EŸL™LŸN™NÒ*ØØ�;‰;�=‰=˜EŸL™LŸN™NÒ*ØØ�;‰;�=‰=˜EŸL™LŸN™NÒ*ØØ�;‰;�=‰=˜EŸL™LŸN™NÒ*ØØr   c                óŠ  — | j                  «       }| j                  |«      s|S t        | j                  «      \  }}t        |j                  «      \  }}t        | j                  «      \  }}t        |j                  «      \  }	}
|j                  t        ||«      t        ||«      ft        ||	«      t        ||
«      fg«       |S )z§Returns the bounding box of the intersection rectangle of both
        2D bounding boxes. Returns an empty bounding box if the intersection
        area is 0.
        )r   r;   r   r   r   r2   rœ   rb   )r   r:   r�   rž   rŸ   r¡   r¢   r¤   r¥   r§   r¨   s              r   r?   zBoundingBox2d.intersectionŽ  s³   € ð
 —>‘>Ó#ˆØ×$Ñ$ UÔ+ØˆOÜ §¡Ó,Ñˆ�Ü §¡Ó-Ñˆ�Ü §¡Ó,Ñˆ�Ü §¡Ó-Ñˆ�Ø�‰ä�W˜gÓ&¬¨G°WÓ(=Ð>Ü�W˜gÓ&¬¨G°WÓ(=Ð>ðô	
ð ˆr   c                ó¦  — | j                   r|j                   sy| j                  j                  |j                  j                  kD  ry| j                  j                  |j                  j                  k  ry| j                  j                  |j                  j                  kD  ry| j                  j                  |j                  j                  k  ryy)a?  Returns ``True`` if this bounding box intersects with `other` but
        in contrast to :meth:`has_intersection` includes touching bounding boxes too::

            bbox1 = BoundingBox2d([(0, 0), (1, 1)])
            bbox2 = BoundingBox2d([(1, 1), (2, 2)])
            assert bbox1.has_overlap(bbox2) is True

        FTrµ   r9   s     r   r=   zBoundingBox2d.has_overlap¢  sƒ   € ð �}Š} E§N¢NØà�;‰;�=‰=˜5Ÿ<™<Ÿ>™>Ò)ØØ�;‰;�=‰=˜5Ÿ<™<Ÿ>™>Ò)ØØ�;‰;�=‰=˜5Ÿ<™<Ÿ>™>Ò)ØØ�;‰;�=‰=˜5Ÿ<™<Ÿ>™>Ò)ØØr   r   rf   rl   ri   rn   ro   )r:   rp   rg   r   )r+   rr   rs   rª   r«   r   rw   r4   r2   r7   r;   r?   r=   r   r   r   r   r   ?  sA   „ ñð %€Iôð òó ðó0ó
Góó.ô(r   r   c                ó,  — t        j                  | D �cg c]  }t        |«      j                  ‘Œ c}t         j                  ¬«      } t        | «      r4t        | j                  d«      «      t        | j                  d«      «      fS t        d«      ‚c c}w ©zBReturns the extents of the bounding box as tuple (extmin, extmax).)Údtyper   zno vertices given)	ÚnpÚarrayr
   rˆ   Úfloat64Úlenrb   rœ   rY   )r   rE   s     r   r{   r{   º  sj   € ä�x‰x©hÓ7©h¨œ˜a›Ÿ›¨hÑ7¼r¿z¹zÔJ€HÜ
ˆ8„}Ü�H—L‘L “OÓ$¤d¨8¯<©<¸«?Ó&;Ð;Ð;äÐ,Ó-Ð-ùò	 8s   ”Bc           
     ó  — t        j                  | D ���cg c]	  ^}}}||f‘Œ c}}}t         j                  ¬«      } t        | «      r4t	        | j                  d«      «      t	        | j                  d«      «      fS t        d«      ‚c c}}}w r¹   )r»   r¼   r½   r¾   r   rb   rœ   rY   )r   rO   r‰   r\   s       r   r®   r®   Ã  sl   € ä�x‰x±Õ9± H A q¨1˜!˜Qš°Ó9ÄÇÁÔL€HÜ
ˆ8„}Ü�H—L‘L “OÓ$¤d¨8¯<©<¸«?Ó&;Ð;Ð;äÐ,Ó-Ð-ùô	 :s   –B)r   rj   rg   ztuple[Vec3, Vec3])r   rj   rg   ztuple[Vec2, Vec2])Ú
__future__r   Útypingr   r   r   r   r   r	   ru   rM   Únumpyr»   Ú
ezdxf.mathr
   r   r   r   Ú__all__ÚABCr   r   r   r{   r®   r   r   r   Ú<module>rÆ      s   ðõ #ß K× KÛ 
Û Û ç 'Ñ 'áˆC��tÓ€â
A€ôF8˜' !™* c§g¡gô F8ôRcÐ% dÑ+ô côLxÐ'¨Ñ-ô xóv.ô.r   