
    h                        S SK Jr  S SKJrJrJr  S SKrS SKJr  S SKJ	r	  \(       a  S SK
Jr  \R                  R                  r " S S5      rS	SS
.     SS jjrS	SS
.     SS jjrS	SS
.     SS jjrg)    )annotations)TYPE_CHECKINGIterableOptionalN)disassemble)BoundingBox)	DXFEntityc                  h    \ rS rSrSrSSS jjr\SS j5       rS rSS jr	SS jr
SS jrSS	 jrS
rg)Cache   zmCaching object for :class:`ezdxf.math.BoundingBox` objects.

Args:
    uuid: use UUIDs for virtual entities

c                ^    [        5       U l        [        U5      U l        SU l        SU l        g )Nr   )dict_boxesbool	_use_uuidhitsmisses)selfuuids     </var/www/html/env/lib/python3.13/site-packages/ezdxf/bbox.py__init__Cache.__init__   s$    .2fd	    c                ,    [        U R                  5      $ N)r   r   r   s    r   has_dataCache.has_data   s    DKK  r   c                h    S[        U R                  5       SU R                   SU R                   S3$ )NzCache(n=z, hits=z	, misses=))lenr   r   r   r   s    r   __str__Cache.__str__"   s;    s4;;'( )II; kk]!%	
r   c                    Uc   eU R                  U5      nUc  U =R                  S-  sl        g U R                  R                  U5      nUc  U =R                  S-  sl        U$ U =R                  S-  sl        U$ )N   )_get_keyr   r   getr   )r   entitykeyboxs       r   r'   	Cache.get)   sr    !!!mmF#;KK1Kkkooc";KK1K 
 IINI
r   c                T    Uc   eU R                  U5      nUc  g X R                  U'   g r   )r&   r   )r   r(   r*   r)   s       r   storeCache.store6   s0    !!!mmF#;Cr   c                r    U H   n U R                   U R                  U5      	 M"     g! [         a     M2  f = f)a  Invalidate cache entries for the given DXF `entities`.

If entities are changed by the user, it is possible to invalidate
individual entities. Use with care - discarding the whole cache is
the safer workflow.

Ignores entities which are not stored in cache.

N)r   r&   KeyError)r   entitiesr(   s      r   
invalidateCache.invalidate=   s<     FKKf 56   s   (
66c                    UR                  5       S:X  a  g UR                  R                  nUb  US:X  a(  U R                  (       a  [	        UR
                  5      $ S $ U$ )NHATCH0)dxftypedxfhandler   strr   )r   r(   r)   s      r   r&   Cache._get_keyM   sO    >>w&
 jj;#*'+~~3v{{#?4?Jr   )r   r   r   r   N)F)returnNone)r<   r   )r(   r	   r<   zOptional[BoundingBox])r(   r	   r*   r   r<   r=   )r1   Iterable[DXFEntity]r<   r=   )r(   r	   r<   zOptional[str])__name__
__module____qualname____firstlineno____doc__r   propertyr   r"   r'   r-   r2   r&   __static_attributes__ r   r   r   r      s9     ! !
 r   r   Ffastcachec             #    #    [         R                  " U 5      n[         R                  " U5      nU H  nUR                  (       a  M  UR                  nUbF  UR                  U5      nUc1  UR                  US9nUR                  (       a  UR                  Xg5        OUR                  US9nUR                  (       d  M  Uv   M     g7f)u  Yields all bounding boxes for the given `entities` **or** all bounding
boxes for their sub entities. If an entity (INSERT) has sub entities, only
the bounding boxes of these sub entities will be yielded, **not** the
bounding box of the entity (INSERT) itself.

If argument `fast` is ``True`` the calculation of Bézier curves is based on
their control points, this may return a slightly larger bounding box.

N)rH   )	r   recursive_decomposeto_primitivesis_emptyr(   r'   bboxr   r-   )r1   rH   rI   flat_entities
primitives	primitiver(   r*   s           r   multi_recursiverR   \   s       33H=M**=9J	!!))F#C{nn$n/<<KK,..d.+C<<<I  s   B8C>	Cc               ^    [        5       n[        XUS9 H  nUR                  U5        M     U$ )u   Returns a single bounding box for all given `entities`.

If argument `fast` is ``True`` the calculation of Bézier curves is based on
their control points, this may return a slightly larger bounding box.

rG   )r   
multi_flatextend)r1   rH   rI   _extendsr*   s        r   extentsrW      s-     }H(U; <Or   c             #     ^^#    SUU4S jjnU  HX  nSnT(       a  TR                  U5      nUc!  U" U/5      nT(       a  TR                  XE5        UR                  (       d  MT  Uv   MZ     g7f)u   Yields a bounding box for each of the given `entities`.

If argument `fast` is ``True`` the calculation of Bézier curves is based on
their control points, this may return a slightly larger bounding box.

c                b   > [        5       n[        U TTS9 H  nUR                  U5        M     U$ )NrG   )r   rR   rU   )	entities_rV   _boxrI   rH   s      r   extends_multi_flat.<locals>.extends_   s/    =#IDFDOOD! Gr   N)rZ   r>   r<   r   )r'   r-   r   )r1   rH   rI   r\   r(   r*   s    ``   r   rT   rT      s`       ))F#C;F8$CF(<<<I s   AA-$	A-)r1   r>   rI   Optional[Cache]r<   zIterable[BoundingBox])r1   r>   rI   r^   r<   r   )
__future__r   typingr   r   r   ezdxfr   
ezdxf.mathr   ezdxf.entitiesr	   	Primitivemax_flattening_distanceMAX_FLATTENING_DISTANCEr   rR   rW   rT   rF   r   r   <module>rg      s    # 4 4   "(%//GG I I^ 
!	 !  	 
  L 
!	! 	
 * 
!	! 	
 r   