
    'j                         d dl mZ d dlmZmZmZmZ d dlmZ d dl	m
Z
mZ d dlmZmZ d dlZerd dl	mZmZmZmZmZ dgZ ej        d	          ZddZddZdS )    )annotations)TYPE_CHECKINGcastSequenceAny)chain)factory
MLineStyle)Vec3OCSN)MLine
DXFGraphicHatchLineArcvirtual_entitiesezdxfreturndict[str, Any]c                <    |                                  }d|v r|d= |S )N
true_color)graphic_properties)mlineattribss     L/DATA/AppData/hermes/venv/lib/python3.11/site-packages/ezdxf/render/mline.py_dxfattribsr      s+    &&((GwL!N    r   r   list[DXFGraphic]c           	          d fd}dfd}dfd}d fdd! fdd" fd}fd}d" fdg } j         r j        t           j                  dk     r|S  j        |S  j        t           j        j                  t          j                  } j	        
                                d         d         g g g  j        D ]}|j        }	t          |	          |k    r?t                              dt                     dt                      d           |c S |j        }
|j        }g }|	D ]9}	 |d         }n# t"          $ r d}Y nw xY w|                    |
||z  z              :                    |                               |                                        |                    rQ                    d                                        d                                        d                    s|                     |                       |                     |                                           j                  r|                     |                       s|                     |                                           j                  r|                    d |                       |S )#zYields 'virtual' parts of MLINE as LINE, ARC and HATCH entities.

    These entities are located at the original positions, but are not stored
    in the entity database, have no handle and are not assigned to any
    layout.
    r   r   c            
     2   t                    } 
j        j        | d<   t          	                    d                                                 dd          | d<   j        j        | d<   t          dt          j	        d| 	                    }dgt                    d
z  z  }t          t          j        	                                        t          j        	                    t                                                  }sN
                    
j                  rd|t                    dz
  <   
                    
j                  rd|d<   d t%          ||          D             }|j                            |d           |S )Ncolorr   g        xy	elevation	extrusionr   HATCH
dxfattribsdoc   g      ?   c              3  :   K   | ]\  }}|j         |j        |fV  d S Nr"   ).0vbulges      r   	<genexpr>z4virtual_entities.<locals>.filling.<locals>.<genexpr>8   s1      JJ(!UQS!#u%JJJJJJr   T)	is_closed)r   dxf
fill_colorr   from_wcsreplacer&   r   r	   newlenr   generatepoints_from_wcsreversedget_flag_state	END_ROUNDSTART_ROUNDzippathsadd_polyline_path)r   hatchbulgespointslwpointsbottom_borderclosedr*   r   ocsstyle
top_borders        r   fillingz!virtual_entities.<locals>.filling&   s   e$$ 9/#CLLq1A$B$BCCKKS  L  
  
  %y2Wgk'g3OOOPP"es='9'9A'=>M#--m<<==M#--hz.B.BCCDD
 
  	!##EO44 514s=))A-.##E$566 ! r
JJc&&6I6IJJJ%%h$%???r   r   c                    g }                      j                  r$|                      d                                                   j                  r |                      d	                                          j                  rHt          j                  dk    r0d         }d         }|                      d||                     | S )Nr      r,   )r>   START_SQUAREextendr@   START_INNER_ARCr:   elements
entitiesstart_index	end_indexbottom_indexcreate_mitermiter_pointsordered_indices
round_capsrK   	top_indexs
      r   	start_capz#virtual_entities.<locals>.start_cap<   s    %' 233 	;OOLLa99::: 122 	DOOJJq)\BBCCC  !677	CEN##a'')"-K'*IOOJJq+yAABBBr   c                    g }                      j                  r$|                      d                                                   j                  r |                      d	                                          j                  rHt          j                  dk    r0d         }d         }|                      d||                     | S )Nr-   rO   r,   rP   )r>   
END_SQUARErR   r?   END_INNER_ARCr:   rT   rU   s
      r   end_capz!virtual_entities.<locals>.end_capK   s    %' 011 	<OOLLb)9::;;;00 	EOOJJr<CCDDD  !455	DEN##a'')!,K'+IOOJJr;	BBCCCr   miter_indexintrW   rX   c                    
j         |         j        }
j         |         j        }	                    |          |                   }	                    |          |                   } ||||          S r/   )rT   r!   r7   )rd   rW   rX   color1color2startend	_arc_capsr[   rJ   rK   s          r   r]   z$virtual_entities.<locals>.round_capsZ   sm    ,2	*0\+6{CDDll<4Y?@@yVV444r   ri   r   rj   rg   rh   Sequence[Arc]c                   t                    }|                     |          }|| z
  j        dz  }| |z
  j        }||d<   ||d<   ||d<   ||d<   |||k    rdndz   |d<   t	          d	t          j        d
|
                    }||k    r|fS |dz   |d<   |dz   |d<   ||d<   t	          d	t          j        d
|
                    }	||	fS )Ng       @centerradiusr!   start_angle   Z   	end_angler   ARCr(   )r   lerp	magnitude	angle_degr   r	   r9   )ri   rj   rg   rh   r   rn   ro   anglearc1arc2r*   r   s             r   rk   z#virtual_entities.<locals>._arc_capsa   s    e$$C+(3.*""!!&$v/?/?RHE7;ucJJJKKV7N!&$s{!E7;ucJJJKKTzr   
list[Line]c                 8   d } g }t                    }D ]}| |t          	j                  D ]g\  }}| |         |d<   ||         |d<   |j        |d<   |j        |d<   |                    t          dt          j        d|                               h|} |S Nri   rj   r!   linetyper   LINEr(   )	r   	enumeraterT   r!   r~   appendr   r	   r9   )
prev_linesr   miterindexelementr*   r[   r   rK   s
         r   lineszvirtual_entities.<locals>.linesv   s    e$$! 	 	E&/&?&? 
 
NE7'+E{GG$%*5\GEN'.}GG$*1*:GJ'MM"#K7LLL     DDr   c                    g } t                      }|                    t                    dz
             s|                    d           t                    D ]'\  }}||vr|                      |                     (| S )Nr,   r   )setaddr:   r   rR   )r   skipr   r   rI   rZ   r[   s       r   display_miterz'virtual_entities.<locals>.display_miter   s    uu\""Q&''' 	HHQKKK%l33 	3 	3LE5D  ll511222r   c           
         g }t          	          }|          }|          }|                    |          }
j                 }||d<   ||d<   |j        |d<   |j        |d<   |                    t          dt          j        d|                               
j                 }||d<   ||d<   |j        |d<   |j        |d<   |                    t          dt          j        d|                               |S r}   )	r   ru   rT   r!   r~   r   r   r	   r9   )r   r   r   topbottomzeror   rY   r*   r   rK   r^   s          r   rZ   z&virtual_entities.<locals>.create_miter   s   e$$I|${{3.+"=%.
VSIIIJJ	
 	
 	
 ..!"=%.
VSIIIJJ	
 	
 	
 r   Nr+   r   r-   z(Invalid line parametrization for vertex z in .)r   r   )r   r   )rd   re   rW   re   rX   re   )
ri   r   rj   r   rg   re   rh   re   r   rl   )r   r{   )is_aliver*   r:   verticesrK   r   r5   r&   rT   r4   r\   line_paramsloggerdebugstrlocationmiter_direction
IndexErrorr   rR   r>   MITERFILLinsert)r   rM   r_   rc   r   r   rV   element_countvertexoffsetsr   r   r   offsetlengthrk   rH   rY   rI   rZ   r*   r[   rJ   r\   r]   rK   rL   r^   s   `              @@@@@@@@@@@@@r   r   r      s              ,                      5 5 5 5 5 5 5 5 5      *        *	 	 	 	 	 	 	         0 "$H> UY.#en2E2E2I2IE}
)C
ei!
"
"C''M_F++--O"1%L#I "MJ%'L. 2 2$w<<=((LL$3|;L;L $ $%jj$ $ $   OOO? 0 	> 	>F   LLOf$<<====E"""%	*+++U<01111 /LO,,,*Q-(((]1-... %		$$$OOEEGGEK(( )((( #		"""EJ'' &7799%%%Os   .E77FF)r   r   )r   r   r   r   )
__future__r   typingr   r   r   r   	itertoolsr   ezdxf.entitiesr	   r
   
ezdxf.mathr   r   loggingr   r   r   r   r   __all__	getLoggerr   r   r    r   r   <module>r      s   # " " " " " 5 5 5 5 5 5 5 5 5 5 5 5       . . . . . . . .                  CBBBBBBBBBBBBBB
		7	#	#   K K K K K Kr   