
    Og#                       d dl mZ d dlmZmZmZmZ d dlZd dlZ	d dl
mZ d dlmZmZmZmZmZ d dlmZmZ d dlmZmZmZmZmZmZmZ d dlmZmZm Z  d	d
l!m"Z"m#Z# d	dl$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z* d	dl+m,Z, erd dl-m.Z. d dl/m0Z0 d dl-m1Z1m2Z2 dgZ3 ed edejh                  e       edd	       edd d       edd d       edejh                  edejj                  e      d      Z6 ee6      Z7 ee*e7      Z8e, G d de%             Z9y)    )annotations)TYPE_CHECKINGIterableOptionalIteratorN)	validator)Vec3Matrix44NULLVECZ_AXISarc_segment_count)OCSTransformNonUniformScalingError)DXFAttrDXFAttributesDefSubclassXTypeRETURN_DEFAULTgroup_code_mappingmerge_group_code_mappings)DXF12SUBCLASS_MARKERDXFValueError   )
base_classSubclassProcessor)
DXFGraphicacdb_entity
add_entityreplace_entityelevation_to_z_axisacdb_entity_group_codes)register_entity)DXFNamespace)AbstractTagWriter)EllipseSplineCircle
AcDbCircle
   )xtypedefault(   )r,   &   T)r,   optional'      )r+   r,   r/   r   fixer)centerradius	elevation	thickness	extrusionc                       e Zd ZdZdZ eeee      Z	e
Z	 d	 	 	 d fdZd fdZddZddZddZddZdd	Zddd
ZdddZ xZS )r(   zDXF CIRCLE entityCIRCLEc                    t         t        |   |      }|r4|j                  || j                         |j
                  rt        |d       |S )z!Loading interface. (internal API))r3   )superr   load_dxf_attribssimple_dxfattribs_loaderMERGED_GROUP_CODESr12r!   )self	processordxf	__class__s      Z/var/www/html/public_html/myphp/venv/lib/python3.12/site-packages/ezdxf/entities/circle.pyr<   zCircle.load_dxf_attribsQ   sE    
 J6yA..sD4K4KL}}#C5
    c                    t         |   |       |j                  t        kD  r$|j	                  t
        t        j                         | j                  j                  |g d       y)z(Export entity specific data as DXF tags.)r3   r4   r6   r7   N)
r;   export_entity
dxfversionr   
write_tag2r   acdb_circlenamerB   export_dxf_attribs)r@   	tagwriterrC   s     rD   rG   zCircle.export_entity^   sL    i(%'  +2B2BC##E	
rE   c              #  
  K   | j                         }t        | j                  j                        }t	        | j                  j
                        }|D ],  }|j                  t	        j                  ||      |z          . yw)aN  Yields the vertices of the circle of all given `angles` as
        :class:`~ezdxf.math.Vec3` instances in :ref:`WCS`.

        Args:
            angles: iterable of angles in :ref:`OCS` as degrees, angle goes
                counter-clockwise around the extrusion vector, and the OCS x-axis
                defines 0-degree.

        N)ocsabsrB   r4   r	   r3   to_wcsfrom_deg_angle)r@   anglesrO   r4   r3   angles         rD   verticeszCircle.verticesg   si      hhjDHHOO,dhhoo& 	JE**T00?&HII	Js   BBc              #     K   t        | j                  j                        }|dkD  rMt        |t        j
                  |      }| j                  t        j                  dd|dz               E d{    yy7 w)az  Approximate the circle by vertices in :ref:`WCS` as :class:`~ezdxf.math.Vec3`
        instances. The argument `sagitta`_ is the maximum distance from the center of an
        arc segment to the center of its chord. Yields a closed polygon where the start
        vertex is equal to the end  vertex!

        .. _sagitta: https://en.wikipedia.org/wiki/Sagitta_(geometry)
        g        g     v@r   N)	rP   rB   r4   r   mathtaurU   nplinspace)r@   sagittar4   counts       rD   
flatteningzCircle.flatteningw   s^      TXX__%C<%fdhh@E}}R[[eUQY%GHHH Hs   A,A7.A5/A7c                    | j                  t        | j                  j                  |            }| j	                  |       |S )zTransform the CIRCLE entity by transformation matrix `m` inplace.
        Raises ``NonUniformScalingError()`` for non-uniform scaling.
        )
_transformr   rB   r7   post_transform)r@   mcircles      rD   	transformzCircle.transform   s6     dhh.@.@!!DEArE   c                V   | j                   }|j                  r|j                  |_        |j	                  |j
                        |_        |j                  |j                  ddf      |_        |j                  d      r |j                  |j                        |_
        | S t        d      )Nr   r6   z/CIRCLE/ARC does not support non uniform scaling)rB   scale_uniformnew_extrusionr7   transform_vertexr3   transform_lengthr4   hasattrtransform_thicknessr6   r   )r@   rO   rB   s      rD   r_   zCircle._transform   s    hh--CM--cjj9CJ --szz1a.@ACJ{{;' !$ 7 7 F 	 )A rE   c                ,   | j                         }|j                  t        |||      |j                  | j                  j
                        z         | j                  _        | j                  r&| j                  t        j                  |||             | S )zOptimized CIRCLE/ARC translation about `dx` in x-axis, `dy` in
        y-axis and `dz` in z-axis, returns `self` (floating interface).
        )
rO   from_wcsr	   rQ   rB   r3   is_post_transform_requiredr`   r
   	translate)r@   dxdydzrO   s        rD   rn   zCircle.translate   sm     hhj,,tBB'7#**TXX__:U'UV** 2 22r2 >?rE   c                    ddl m} | j                         }|t        d       |j                  |       }|rt        | ||       |S t        ||       |S )a(  Convert the CIRCLE/ARC entity to an :class:`~ezdxf.entities.Ellipse` entity.

        Adds the new ELLIPSE entity to the entity database and to the same layout as
        the source entity.

        Args:
            replace: replace (delete) source entity by ELLIPSE entity if ``True``

        r   )r&   valid layout required)ezdxf.entitiesr&   
get_layoutr   from_arcr    r   )r@   replacer&   layoutellipses        rD   
to_ellipsezCircle.to_ellipse   s]     	+"> 788"'""4(4&1  w'rE   c                    ddl m} | j                         }|t        d       |j                  |       }|rt        | ||       |S t        ||       |S )a$  Convert the CIRCLE/ARC entity to a :class:`~ezdxf.entities.Spline` entity.

        Adds the new SPLINE entity to the entity database and to the same layout as the
        source entity.

        Args:
            replace: replace (delete) source entity by SPLINE entity if ``True``

        r   )r'   rs   )rt   r'   ru   r   rv   r    r   )r@   rw   r'   rx   splines        rD   	to_splinezCircle.to_spline   s[     	*"> 788 &40  vv&rE   )N)rA   zOptional[SubclassProcessor]returnr$   )rM   r%   r~   None)rS   zIterable[float]r~   Iterator[Vec3])r[   floatr~   r   )ra   r
   r~   r(   )rO   r   r~   r(   )ro   r   rp   r   rq   r   r~   r(   )T)r~   r&   )r~   r'   )__name__
__module____qualname____doc__DXFTYPEr   r   r   rJ   
DXFATTRIBSmerged_circle_group_codesr>   r<   rG   rU   r]   rc   r_   rn   rz   r}   __classcell__)rC   s   @rD   r(   r(   I   sh    Gz;DJ2 8<4	
J I*	, rE   ):
__future__r   typingr   r   r   r   rW   numpyrY   ezdxf.lldxfr   
ezdxf.mathr	   r
   r   r   r   ezdxf.math.transformtoolsr   r   ezdxf.lldxf.attributesr   r   r   r   r   r   r   ezdxf.lldxf.constr   r   r   	dxfentityr   r   dxfgfxr   r   r   r    r!   r"   factoryr#   rt   r$   ezdxf.lldxf.tagwriterr%   r&   r'   __all__point3dis_not_null_vectorrJ   acdb_circle_group_codesr   r(    rE   rD   <module>r      s   # > >   !  K   D C 4  %+7.*"EMM7C"a( RT:RT:--22 
, -[9 54 
 LZ L LrE   