o
    h|                     @  s   d dl mZ 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 d dlmZ er8d dlmZmZmZ dddZdddZdS )    )annotations)pairwise)TYPE_CHECKINGcastN)FillTypeLineType)codes_from_offsets)
FillReturn
LineReturnLineReturn_Separatefilledr	   	fill_typer   returnlist[mpath.Path]c           
   
   C  s`  |t jt jfv rdd t|  D }|S |t jt jfv r&dd t|  D }|S |t jkr^g }t|  D ]*\}}}|d u r;q1t||dd }t||dd }|dd t||D 7 }q1|S |t j	krg }t|  D ]<\}}}|d u rsqit
t|d D ])}||| ||d  d  }||d |d  }	|t|	t||d  g7 }q{qi|S td| d	)
Nc                 S  $   g | ]\}}|d urt ||qS NmpathPath.0pointscodes r   k/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/contourpy/util/mpl_util.py
<listcomp>      $ z'filled_to_mpl_paths.<locals>.<listcomp>c                 S  s(   g | ]\}}|d urt |t|qS r   )r   r   r   )r   r   offsetsr   r   r   r      s       c                 S  s   g | ]
\}}t ||qS r   r   )r   pcr   r   r   r      s    r   zConversion of FillType   to MPL Paths is not implemented)r   	OuterCodeChunkCombinedCodezipOuterOffsetChunkCombinedOffsetChunkCombinedCodeOffsetnpsplitChunkCombinedOffsetOffsetrangelenr   r   r   RuntimeError)
r   r   pathsr   r   outer_offsetsr   ioffsptsr   r   r   filled_to_mpl_paths   s:   

 r4   linesr
   	line_typer   c                 C  s  |t jkr/trtt| } g }| D ]}|d |d ko!|d |d k}|tj||d q|S |t jt j	fv rBdd t
|  D }|S |t jkrg }t
|  D ]:\}}|d u rVqMtt|d D ](}||| ||d   }|d |d ko{|d |d k}|tj||d q^qM|S |t jkrg }| d	 D ]N}|d u rqtt|d d d	f d	 }td
g|t|gg}t|D ]&\}	}
||	d |
 }|d |d ko|d |d k}|tj||d qq|S td| d)N)r   r   )r   r   )r   r   )r   r   )closedc                 S  r   r   r   r   r   r   r   r   6   r   z&lines_to_mpl_paths.<locals>.<listcomp>r   r   r   zConversion of LineType r"   )r   Separater   r   r   appendr   r   SeparateCoder$   r%   r'   r,   r-   ChunkCombinedNanr)   nonzeroisnanconcatenater   r.   )r5   r6   r/   liner7   r   r   r1   nan_offsetsser   r   r   lines_to_mpl_paths,   sH   

 
 
  rC   )r   r	   r   r   r   r   )r5   r
   r6   r   r   r   )
__future__r   	itertoolsr   typingr   r   matplotlib.pathpathr   numpyr)   	contourpyr   r   contourpy.arrayr   contourpy._contourpyr	   r
   r   r4   rC   r   r   r   r   <module>   s    
