U
    i2e                     @  s   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 er`d dlmZmZmZmZmZ dddd	d
dZddddddZdddddZdddddZdS )    )annotations)TYPE_CHECKINGcastN)FillTypeLineType)	CodeArray
FillReturn
LineReturnLineReturn_SeparateOffsetArrayr   r   zlist[mpath.Path])filled	fill_typereturnc           
   
   C  sb  |t jt jfkr&dd t|  D }n8|t jt jfkrLdd t|  D }n|t jkrg }t|  D ]T\}}}|d krvqbt||dd }t||dd }|dd t||D 7 }qbn|t j	krNg }t|  D ]x\}}}|d krqt
t|d D ]R}||| ||d  d  }||d |d  }	|t|	t||d  g7 }qqntd| d	|S )
Nc                 S  s$   g | ]\}}|d k	rt ||qS NmpathPath.0pointscodes r   ;/tmp/pip-unpacked-wheel-_24pu9r8/contourpy/util/mpl_util.py
<listcomp>   s      z'filled_to_mpl_paths.<locals>.<listcomp>c                 S  s(   g | ] \}}|d k	rt |t|qS r   )r   r   offsets_to_mpl_codes)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   Z	OuterCodeChunkCombinedCodezipZOuterOffsetChunkCombinedOffsetZChunkCombinedCodeOffsetnpsplitZChunkCombinedOffsetOffsetrangelenr   r   r   RuntimeError)
r   r   pathsr   r   Zouter_offsetsr   iZoffsZptsr   r   r   filled_to_mpl_paths   s2    

$r+   r	   r   )lines	line_typer   c                 C  s$  |t jkr\trtt| } g }| D ]8}|d |d koB|d |d k}|tj||d q n|t jt j	fkrdd t
|  D }n|t jkrg }t
|  D ]t\}}|d krqtt|d D ]P}||| ||d   }|d |d ko|d |d k}|tj||d qqntd	| d
|S )N)r   r   )r   r   )r   r   )r   r   )closedc                 S  s$   g | ]\}}|d k	rt ||qS r   r   r   r   r   r   r   6   s      z&lines_to_mpl_paths.<locals>.<listcomp>r   zConversion of LineType r    )r   ZSeparater   r   r
   appendr   r   ZSeparateCoder!   r"   r#   r&   r'   r(   )r,   r-   r)   liner.   r   r   r*   r   r   r   lines_to_mpl_paths,   s(    

  r1   r   r   )r   r   c                 C  s.   t | dkd t j}t |t| }|S )Nr   r   )r$   ZnonzeroZastypeZuint32r/   r'   )r   r   r   r   r   mpl_codes_to_offsetsE   s    r2   )r   r   c                 C  sF   t j| d | d  dt jd}d|| d d < d|| dd  d < |S )Nr   r      )Zdtyper   O   )r$   fullZuint8)r   r   r   r   r   r   K   s    r   )
__future__r   typingr   r   Zmatplotlib.pathpathr   Znumpyr$   Z	contourpyr   r   Zcontourpy._contourpyr   r   r	   r
   r   r+   r1   r2   r   r   r   r   r   <module>   s   