
    hJ                       S SK Jr  S SKJrJr  S SKJr  S SKrS SKJ	r	J
r
Jr  S SKJrJrJrJrJrJrJr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   S
S/r!S'S jr"S(S jr#\	* r$S)S jr%S)S jr&S*S jr'S+S jr(S,S jr)S-S jr*S-S jr+\S'S j5       r,\,R[                  \5      S.S j5       r.\,R[                  \5      S/S j5       r/\,R[                  \5      S0S j5       r0\,R[                  \5      S1S j5       r1\,R[                  \5      S2S j5       r2\,R[                  \5      S3S j5       r3S4S jr4\,R[                  \5      S5S j5       r5\,R[                  \5      S6S j5       r6\S7S j5       r7\7R[                  \5      S8S  j5       r8\7R[                  \5      S9S! j5       r9\S7S" j5       r:\:R[                  \5      S:S# j5       r;\:R[                  \5      S;S$ j5       r<\:R[                  \5      S<S% j5       r=\:R[                  \5      S=S& j5       r>g)>    )annotations)IterableSequence)singledispatchN)Z_AXISVec3Vec2)	
DXFGraphicDXFNamespaceCircleArcEllipseSolidInsert
LWPolylinePolyline)
DXFPolygon)PolylinePathEdgePathLineEdgeArcEdgeEllipseEdge
SplineEdge)constuprightupright_allc                8   [        U [        5      (       a1  U R                  (       a   U R                  R	                  S5      (       d  g[        U R                  R                  5      R                  5       nUR                  [        5      (       a  [        U 5        gg)aX  Flips an inverted :ref:`OCS` defined by extrusion vector (0, 0, -1) into
a :ref:`WCS` aligned :ref:`OCS` defined by extrusion vector (0, 0, 1).
DXF entities with other extrusion vectors and unsupported DXF entities will
be silently ignored. For more information about the limitations read the
documentation of the :mod:`ezdxf.upright` module.

	extrusionN)
isinstancer
   is_alivedxfhasattrr   r   	normalizeiscloseFLIPPED_Z_AXIS_flip_dxf_graphic)entityr   s     ?/var/www/html/env/lib/python3.13/site-packages/ezdxf/upright.pyr   r   0   sk     	6:&&OOJJ{++VZZ))*446I((&! )    c                ,    U  H  n[        U5        M     g)zpCall function :func:`upright` for all DXF entities in iterable
`entities`::

    upright_all(doc.modelspace())

N)r   )entitieses     r(   r   r   C   s     
 r)   c                "    U S:  a  SU -
  $ SU -
  $ )N        g     f@g     f angles    r(   _flip_deg_angler2   Q   s    c\E66v66r)   c                \    U S:  a  [         R                  U -
  $ [         R                  * U -
  $ )Nr.   )mathpir0   s    r(   _flip_rad_angler6   U   s'    |DGGU::$''U::r)   c                \    [        U R                  * U R                  U R                  * 5      $ N)r   xyzvertexs    r(   _flip_vertexr>   Y   s!    	688fhhY//r)   c                D    [        U R                  * U R                  5      $ r8   )r	   r9   r:   r<   s    r(   _flip_2d_vertexr@   ]   s    	688$$r)   c                    U R                  U5      (       a,  [        U R                  U5      5      nU R                  X5        g g r8   )r"   r>   getset)r!   namer=   s      r(   _flip_existing_vertexrE   a   s4    
{{4cggdm, r)   c                V    U R                  S5      (       a  U R                  * U l        g g )N	thickness)r"   rG   r!   s    r(   _flip_thicknessrI   g   s#    
{{;  r)   c                V    U R                  S5      (       a  U R                  * U l        g g )N	elevation)r"   rK   rH   s    r(   _flip_elevationrL   l   s#    
{{;  r)   c                    g r8   r/   )r'   s    r(   r&   r&   r   s    r)   c                l    U R                   n[        US5        [        U5        UR                  S5        g )Ncenterr   )r!   rE   rI   discard)circler!   s     r(   _flip_circlerR   w   s)    
**C#x(CKKr)   c                    [        U 5        U R                  nUR                  n[        UR                  5      Ul        [        U5      Ul        g r8   )rR   r!   	end_angler2   start_angle)arcr!   rT   s      r(   	_flip_arcrW      s8    
''CI#COO4CM%i0COr)   c                    U R                   n[        R                   H  n[        X5        M     [	        U5        UR                  S5        g Nr   )r!   r   VERTEXNAMESrE   rI   rP   )solidr!   rD   s      r(   _flip_solidr\      s7    
))C!!c( "CKKr)   c                    U R                   n[        US5        UR                  * Ul        UR                  * Ul        UR                  * Ul        UR                  S5        g )Ninsertr   )r!   rE   rotationxscalezscalerP   )r^   r!   s     r(   _flip_insertrb      sJ     **C#x(LL=CL**CJ**CJKKr)   c                    U R                   nUR                  * nUR                  * Ul        X!l        UR                  S5        g rY   )r!   	end_paramstart_paramrP   )ellipser!   rd   s      r(   _flip_ellipserg      s7     ++CI__$CMOKKr)   c                    / nU R                    HG  u  p#pEnU* n[        [        X#5      5      nUR                  UR                  UR
                  XEU45        MI     U R                  USS9  [        U R                  5        g )Nxyseb)format)	lwpointsr@   r	   appendr9   r:   
set_points_finalize_polyliner!   )polylineflipped_pointsr9   r:   start_width	end_widthbulgevs           r(   _flip_lwpolylineru      st    ,.N/7/@/@+keDJ'qssACCGH 0A w7x||$r)   c                R    [        U 5        [        U 5        U R                  S5        g rY   )rI   rL   rP   rH   s    r(   rn   rn      s    CCKKr)   c                    U R                   (       d  g U R                   HE  nUR                  n[        US5        UR	                  S5      (       d  M3  UR
                  * Ul        MG     [        U R                  5        g )Nlocationrs   )is_2d_polylineverticesr!   rE   r"   rs   rn   )ro   r=   r!   s      r(   _flip_polyline2dr{      s[    ""##jjc:.;;w
CI	 $
 x||$r)   c                    U R                    H  n[        U5        M     [        U R                  5        U R                  R	                  S5        g rY   )paths_flip_boundary_pathrL   r!   rP   )polygonps     r(   _flip_polygonr      s6    ]]A GKK KK$r)   c                     [        SU < 35      e)Nzunsupported path type: 	TypeError)paths    r(   r~   r~          
-dX6
77r)   c                    / nU R                    HE  u  p#nU* n[        [        X#5      5      nUR                  UR                  UR
                  U45        MG     Xl         g r8   )rz   r@   r	   rl   r9   r:   )ro   flipped_verticesr9   r:   rs   rt   s         r(   _flip_polyline_pathr      sV    9;((eDJ'acc5 12 ) )r)   c                ,    U  H  n[        U5        M     g r8   )
_flip_edge)edgesedges     r(   _flip_edge_pathr      s     4 r)   c                     [        SU < 35      e)Nzunsupported edge type: r   r   s    r(   r   r      r   r)   c                l    [        U R                  5      U l        [        U R                  5      U l        g r8   )r@   startendr   s    r(   _flip_line_edger      s"     ,DJtxx(DHr)   c                    [        U R                  5      U l        U R                  n[        U R                  5      U l        [        U5      U l        U R
                  (       + U l        g r8   )r@   rO   rT   r2   rU   ccw)r   rT   s     r(   _flip_arc_edger      sG    !$++.DKI$T%5%56DN&y1D88|DHr)   c                    [        U R                  5      U l        [        U R                  5      U l        [        U R                  5      U l        [        U R
                  5      U l        U R                  (       + U l        g r8   )r@   rO   
major_axisr2   rU   rT   r   r   s    r(   _flip_ellipse_edger      sT    !$++.DK%doo6DO 't'7'78D$T^^4DN88|DHr)   c                P   [         nU R                  b  U" U R                  5      U l        U R                  b  U" U R                  5      U l        U R                   Vs/ s H
  o!" U5      PM     snU l        U R                   Vs/ s H
  o!" U5      PM     snU l        g s  snf s  snf r8   )r@   start_tangentend_tangentcontrol_points
fit_points)r   flip_2d_vertexrt   s      r(   _flip_spline_edger     s    $N%+D,>,>?#)$*:*:;6:6I6IJ6I>!,6IJD26//B/Q~a(/BDO KBs   BB#)r'   r
   returnNone)r+   zIterable[DXFGraphic]r   r   )r1   floatr   r   )r=   r   r   r   )r=   r	   r   r	   )r!   r   rD   strr   r   )r!   r   r   r   )rQ   r   r   r   )rV   r   r   r   )r[   r   r   r   )r^   r   r   r   )rf   r   r   r   )ro   r   r   r   )r!   r   )ro   r   r   r   )r   r   r   r   )r   r   )ro   r   r   r   )r   r   r   r   )r   r   r   r   )r   r   r   r   )r   r   r   r   )r   r   r   r   )?
__future__r   typingr   r   	functoolsr   r4   
ezdxf.mathr   r   r	   ezdxf.entitiesr
   r   r   r   r   r   r   r   r   ezdxf.entities.polygonr   ezdxf.entities.boundary_pathsr   r   r   r   r   r   ezdxf.lldxfr   __all__r   r   r%   r2   r6   r>   r@   rE   rI   rL   r&   registerrR   rW   r\   rb   rg   ru   rn   r{   r   r~   r   r   r   r   r   r   r   r/   r)   r(   <module>r      sq  $ # % $  ) )
 
 
 .  m
$"& 7;0%'
' 	 	 F# $ C 1 !1 E" # F# $ G$ % J'% (% H%% &% J'% (% 8 8 l+) ,) h' ( 8 8 X) )
 W  [! " Z C !Cr)   