a
    «ˆc5  ã                   @   sš   d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	 dd	lm
Z
 dd
lmZ ddlmZ ddlmZ G dd„ dƒZdS )aø  
vtkImageImportFromArray: a NumPy front-end to vtkImageImport

Load a python array into a vtk image.
To use this class, you must have NumPy installed (http://numpy.scipy.org/)

Methods:

  SetArray()  -- set the numpy array to load
  Update()    -- generate the output
  GetOutput() -- get the image as vtkImageData
  GetOutputPort() -- connect to VTK pipeline

Methods from vtkImageImport:
(if you don't set these, sensible defaults will be used)

  SetDataExtent()
  SetDataSpacing()
  SetDataOrigin()
é    )ÚvtkImageImport)ÚVTK_SIGNED_CHAR)ÚVTK_UNSIGNED_CHAR)Ú	VTK_SHORT)ÚVTK_UNSIGNED_SHORT)ÚVTK_INT)ÚVTK_UNSIGNED_INT)ÚVTK_LONG)ÚVTK_UNSIGNED_LONG)Ú	VTK_FLOAT)Ú
VTK_DOUBLEc                   @   sÊ   e Zd Zdd„ Zeeeeee	e
ee
edœ
Zededededede	de
dediZdd	„ Zd
d„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zd d!„ Zd"d#„ Zd$d%„ Zd&S )'ÚvtkImageImportFromArrayc                 C   s   t ƒ | _d| _d | _d S ©NF)r   Ú _vtkImageImportFromArray__importÚ3_vtkImageImportFromArray__ConvertIntToUnsignedShortÚ_vtkImageImportFromArray__Array©Úself© r   új/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/vtkmodules/util/vtkImageImportFromArray.pyÚ__init__#   s    z vtkImageImportFromArray.__init__)
ÚbÚBÚhÚHÚiÚIÚfÚdÚFÚDé   é   é   é   c                 C   s
   || _ d S ©N©r   )r   Zyesnor   r   r   ÚSetConvertIntToUnsignedShort@   s    z4vtkImageImportFromArray.SetConvertIntToUnsignedShortc                 C   s   | j S r%   r&   r   r   r   r   ÚGetConvertIntToUnsignedShortC   s    z4vtkImageImportFromArray.GetConvertIntToUnsignedShortc                 C   s
   d| _ d S )NTr&   r   r   r   r   ÚConvertIntToUnsignedShortOnF   s    z3vtkImageImportFromArray.ConvertIntToUnsignedShortOnc                 C   s
   d| _ d S r   r&   r   r   r   r   ÚConvertIntToUnsignedShortOffI   s    z4vtkImageImportFromArray.ConvertIntToUnsignedShortOffc                 C   s   | j  ¡  d S r%   )r   ÚUpdater   r   r   r   r+   L   s    zvtkImageImportFromArray.Updatec                 C   s
   | j  ¡ S r%   )r   ÚGetOutputPortr   r   r   r   r,   P   s    z%vtkImageImportFromArray.GetOutputPortc                 C   s
   | j  ¡ S r%   )r   Ú	GetOutputr   r   r   r   r-   T   s    z!vtkImageImportFromArray.GetOutputc           	   
   C   sÆ  || _ d}|j}t|ƒdkr"d}nft|ƒdkr>dd|d f}nJt|ƒdkr^d|d |d f}n*t|ƒdkrˆ|d }|d |d |d f}|jj}| j| }d}|dks®|dkrº|d }d}| jrÖ|d	krÖ| d
¡}t}t|j	ƒ| j
|  | }| j ||¡ | j |¡ | j |¡ | j ¡ }| j |d |d |d  d |d |d |d  d |d |d |d  d ¡ | j |d |d |d  d |d |d |d  d |d |d |d  d ¡ d S )Nr!   r   )r!   r!   r!   r"   r#   é   r   r    r   r   )r   ÚshapeÚlenZdtypeÚcharÚ"_vtkImageImportFromArray__typeDictr   Zastyper   ZflatÚ"_vtkImageImportFromArray__sizeDictr   ZCopyImportVoidPointerZSetDataScalarTypeZSetNumberOfScalarComponentsÚGetDataExtentÚSetDataExtentZSetWholeExtent)	r   ZimArrayZnumComponentsZdimÚtypecodeZar_typeZcomplexComponentsÚsizeÚextentr   r   r   ÚSetArrayX   sD    


þþz vtkImageImportFromArray.SetArrayc                 C   s   | j S r%   )r   r   r   r   r   ÚGetArray   s    z vtkImageImportFromArray.GetArrayc                 C   s   | j  |¡ d S r%   )r   r5   )r   r8   r   r   r   r5   „   s    z%vtkImageImportFromArray.SetDataExtentc                 C   s
   | j  ¡ S r%   )r   r4   r   r   r   r   r4   ‡   s    z%vtkImageImportFromArray.GetDataExtentc                 C   s   | j  |¡ d S r%   )r   ÚSetDataSpacing)r   Úspacingr   r   r   r;   Š   s    z&vtkImageImportFromArray.SetDataSpacingc                 C   s
   | j  ¡ S r%   )r   ÚGetDataSpacingr   r   r   r   r=   �   s    z&vtkImageImportFromArray.GetDataSpacingc                 C   s   | j  |¡ d S r%   )r   ÚSetDataOrigin)r   Úoriginr   r   r   r>   �   s    z%vtkImageImportFromArray.SetDataOriginc                 C   s
   | j  ¡ S r%   )r   ÚGetDataOriginr   r   r   r   r@   “   s    z%vtkImageImportFromArray.GetDataOriginN)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r   r   r   r   r2   r3   r'   r(   r)   r*   r+   r,   r-   r9   r:   r5   r4   r;   r=   r>   r@   r   r   r   r   r   "   sH   ÷ù
'r   N)Ú__doc__Zvtkmodules.vtkIOImager   Zvtkmodules.vtkCommonCorer   r   r   r   r   r   r	   r
   r   r   r   r   r   r   r   Ú<module>   s   