
    OgJ                       d dl mZ d dlmZmZ d dlmZ d dlZd dlm	Z	m
Z
mZ d dlmZ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mZmZmZmZmZ d d	lm Z  d
dgZ!d'dZ"d(dZ#e	 Z$d)dZ%d)dZ&d*dZ'd+dZ(d,dZ)d-dZ*d-dZ+ed'd       Z,e,j[                  e      d.d       Z.e,j[                  e      d/d       Z/e,j[                  e      d0d       Z0e,j[                  e      d1d       Z1e,j[                  e      d2d       Z2e,j[                  e      d3d       Z3d4dZ4e,j[                  e      d5d       Z5e,j[                  e      d6d       Z6ed7d       Z7e7j[                  e      d8d        Z8e7j[                  e      d9d!       Z9ed7d"       Z:e:j[                  e      d:d#       Z;e:j[                  e      d;d$       Z<e:j[                  e      d<d%       Z=e:j[                  e      d=d&       Z>y)>    )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                   t        | t              r'| j                  r| j                  j	                  d      syt        | j                  j                        j                         }|j                  t              rt        |        yy)al  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     R/var/www/html/public_html/myphp/venv/lib/python3.12/site-packages/ezdxf/upright.pyr   r   0   sb     	6:&OOJJ{+VZZ))*446I(&! )    c                (    | D ]  }t        |        y)z|Call 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                     | dk\  rd| z
  S d| z
  S )N        g     f@g     f angles    r(   _flip_deg_angler2   Q   s    c\E66v66r)   c                Z    | dk\  rt         j                  | z
  S t         j                   | z
  S )Nr.   )mathpir0   s    r(   _flip_rad_angler6   U   s'    |DGGU::$''U::r)   c                \    t        | j                   | j                  | j                         S N)r   xyzvertexs    r(   _flip_vertexr>   Y   s!    	688fhhY//r)   c                D    t        | j                   | j                        S r8   )r	   r9   r:   r<   s    r(   _flip_2d_vertexr@   ]   s    	688$$r)   c                    | j                  |      r-t        | j                  |            }| j                  ||       y y r8   )r"   r>   getset)r!   namer=   s      r(   _flip_existing_vertexrE   a   s3    
{{4cggdm,f r)   c                L    | j                  d      r| j                   | _        y y )N	thickness)r"   rG   r!   s    r(   _flip_thicknessrI   g   s     
{{;  r)   c                L    | j                  d      r| j                   | _        y y )N	elevation)r"   rK   rH   s    r(   _flip_elevationrL   l   s     
{{;  r)   c                     y r8   r/   )r'   s    r(   r&   r&   r   s    r)   c                l    | j                   }t        |d       t        |       |j                  d       y )Ncenterr   )r!   rE   rI   discard)circler!   s     r(   _flip_circlerR   w   s)    
**C#x(CKKr)   c                    t        |        | j                  }|j                  }t        |j                        |_        t        |      |_        y r8   )rR   r!   	end_angler2   start_angle)arcr!   rT   s      r(   	_flip_arcrW      s8    
''CI#COO4CM%i0COr)   c                    | j                   }t        j                  D ]  }t        ||        t	        |       |j                  d       y Nr   )r!   r   VERTEXNAMESrE   rI   rP   )solidr!   rD   s      r(   _flip_solidr\      s>    
))C!! )c4()CKKr)   c                    | j                   }t        |d       |j                   |_        |j                   |_        |j                   |_        |j                  d       y )Ninsertr   )r!   rE   rotationxscalezscalerP   )r^   r!   s     r(   _flip_insertrb      sJ     **C#x(LL=CL**CJ**CJKKr)   c                    | j                   }|j                   }|j                   |_        ||_        |j                  d       y rY   )r!   	end_paramstart_paramrP   )ellipser!   rd   s      r(   _flip_ellipserg      s9     ++CI__$CMCOKKr)   c                
   g }| j                   D ]J  \  }}}}}| }t        t        ||            }|j                  |j                  |j
                  |||f       L | j                  |d       t        | j                         y )Nxyseb)format)	lwpointsr@   r	   appendr9   r:   
set_points_finalize_polyliner!   )polylineflipped_pointsr9   r:   start_width	end_widthbulgevs           r(   _flip_lwpolylineru      s    ,.N/7/@/@ I+1k9eDAJ'qssACCiGHI w7x||$r)   c                R    t        |        t        |        | j                  d       y rY   )rI   rL   rP   rH   s    r(   rn   rn      s    CCKKr)   c                    | j                   sy | j                  D ]>  }|j                  }t        |d       |j	                  d      s-|j
                   |_        @ t        | j                         y )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                    | j                   D ]  }t        |        t        | j                         | j                  j	                  d       y rY   )paths_flip_boundary_pathrL   r!   rP   )polygonps     r(   _flip_polygonr      s;    ]] AGKK KK$r)   c                    t        d|       )Nzunsupported path type: 	TypeError)paths    r(   r~   r~          
-dX6
77r)   c                    g }| j                   D ]F  \  }}}| }t        t        ||            }|j                  |j                  |j
                  |f       H || _         y r8   )rz   r@   r	   rl   r9   r:   )ro   flipped_verticesr9   r:   rs   rt   s         r(   _flip_polyline_pathr      sa    9;(( 31eDAJ'acc5 123 )Hr)   c                (    | D ]  }t        |        y r8   )
_flip_edge)edgesedges     r(   _flip_edge_pathr      s      4r)   c                    t        d|       )Nzunsupported edge type: r   r   s    r(   r   r      r   r)   c                l    t        | j                        | _        t        | j                        | _        y r8   )r@   startendr   s    r(   _flip_line_edger      s"     ,DJtxx(DHr)   c                    t        | j                        | _        | j                  }t        | j                        | _        t        |      | _        | j
                   | _        y 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                    t        | j                        | _        t        | j                        | _        t        | j                        | _        t        | j
                        | _        | j                   | _        y 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                D   t         }| j                   || j                        | _        | j                   || j                        | _        | j                  D cg c]
  } ||       c}| _        | j                  D cg c]
  } ||       c}| _        y c c}w c c}w r8   )r@   start_tangentend_tangentcontrol_points
fit_points)r   flip_2d_vertexrt   s      r(   _flip_spline_edger     s    $N%+D,>,>?#)$*:*:;6:6I6IJ>!,JD26//BQ~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)   