
    'j#                    0   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j4        e           edd	           edd d           edd d           edej4        edej5        e          d          Z6 ee6          Z7 ee*e7          Z8e, G d de%                      Z9dS )    )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CIRCLEN	processorOptional[SubclassProcessor]returnr$   c                    t          t          |                               |          }|r2|                    || j                   |j        rt          |d           |S )z!Loading interface. (internal API))r3   )superr   load_dxf_attribssimple_dxfattribs_loaderMERGED_GROUP_CODESr12r!   )selfr:   dxf	__class__s      O/DATA/AppData/hermes/venv/lib/python3.11/site-packages/ezdxf/entities/circle.pyr?   zCircle.load_dxf_attribsQ   sb    
 J%%66yAA 	6..sD4KLLL} 6#C555
    	tagwriterr%   Nonec                    t                                          |           |j        t          k    r%|                    t
          t          j                   | j        	                    |g d           dS )z(Export entity specific data as DXF tags.)r3   r4   r6   r7   N)
r>   export_entity
dxfversionr   
write_tag2r   acdb_circlenamerD   export_dxf_attribs)rC   rH   rE   s     rF   rK   zCircle.export_entity^   sr    i(((%''  +2BCCC##EEE	
 	
 	
 	
 	
rG   anglesIterable[float]Iterator[Vec3]c              #     K   |                                  }t          | j        j                  }t	          | j        j                  }|D ]/}|                    t	          j        ||          |z             V  0dS )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absrD   r4   r	   r3   to_wcsfrom_deg_angle)rC   rQ   rU   r4   r3   angles         rF   verticeszCircle.verticesg   s       hhjjDHO,,dho&& 	J 	JE**T0??&HIIIIII	J 	JrG   sagittafloatc              #     K   t          | j        j                  }|dk    rOt          |t          j        |          }|                     t          j        dd|dz                       E d{V  dS dS )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)	rV   rD   r4   r   mathtaurZ   nplinspace)rC   r[   r4   counts       rF   
flatteningzCircle.flatteningw   sx       TX_%%C<<%fdh@@E}}R[eUQY%G%GHHHHHHHHHHH <rG   mr
   c                    |                      t          | j        j        |                    }|                     |           |S )zTransform the CIRCLE entity by transformation matrix `m` inplace.
        Raises ``NonUniformScalingError()`` for non-uniform scaling.
        )
_transformr   rD   r7   post_transform)rC   rd   circles      rF   	transformzCircle.transform   s=     dh.@!!D!DEEArG   rU   r   c                D   | j         }|j        r|j        |_        |                    |j                  |_        |                    |j        ddf          |_        |                    d          r|	                    |j
                  |_
        nt          d          | S )Nr   r6   z/CIRCLE/ARC does not support non uniform scaling)rD   scale_uniformnew_extrusionr7   transform_vertexr3   transform_lengthr4   hasattrtransform_thicknessr6   r   )rC   rU   rD   s      rF   rf   zCircle._transform   s    h 	-CM--cj99CJ --sz1a.@AACJ{{;'' G !$ 7 7 F F )A   rG   dxdydzc                *   |                                  }|                    t          |||          |                    | j        j                  z             | j        _        | j        r)|                     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).
        )
rU   from_wcsr	   rW   rD   r3   is_post_transform_requiredrg   r
   	translate)rC   rq   rr   rs   rU   s        rF   rw   zCircle.translate   s{     hhjj,,tBB'7'7#**TX_:U:U'UVV* 	@ 22r2 > >???rG   Tr&   c                    ddl m} |                                 }|t          d           |j        |           }|rt          | ||           n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&   Nvalid layout required)ezdxf.entitiesr&   
get_layoutr   from_arcr    r   )rC   replacer&   layoutellipses        rF   
to_ellipsezCircle.to_ellipse   s}     	+*****""> 7888"'"4(( 	(4&1111w'''rG   r'   c                    ddl m} |                                 }|t          d           |j        |           }|rt          | ||           n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'   Nry   )rz   r'   r{   r   r|   r    r   )rC   r}   r'   r~   splines        rF   	to_splinezCircle.to_spline   s|     	*)))))""> 7888 && 	'40000vv&&&rG   )N)r:   r;   r<   r$   )rH   r%   r<   rI   )rQ   rR   r<   rS   )r[   r\   r<   rS   )rd   r
   r<   r(   )rU   r   r<   r(   )rq   r\   rr   r\   rs   r\   r<   r(   )T)r<   r&   )r<   r'   )__name__
__module____qualname____doc__DXFTYPEr   r   r   rN   
DXFATTRIBSmerged_circle_group_codesrA   r?   rK   rZ   rc   ri   rf   rw   r   r   __classcell__)rE   s   @rF   r(   r(   I   s'       Gz;DDJ2 8<      
 
 
 
 
 
J J J J I I I I      *	 	 	 	    ,        rG   ):
__future__r   typingr   r   r   r   r^   numpyr`   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#   rz   r$   ezdxf.lldxf.tagwriterr%   r&   r'   __all__point3dis_not_null_vectorrN   acdb_circle_group_codesr   r(    rG   rF   <module>r      s   # " " " " " > > > > > > > > > > > >      ! ! ! ! ! !              K J J J J J J J                  D C C C C C C C C C 4 4 4 4 4 4 4 4                % $ $ $ $ $ /++++++777777........*k'"EM7CCC'"a((( WRT:::WRT:::W-2 
 
 
  , -,[99 554  
 L L L L LZ L L L L LrG   