a
    «ˆc   ã                   @   s~   d dl mZ d dlmZ d dlZd dl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	ejƒZed
krze ¡  dS )é    )Úabspath)ÚBytesION)Ú
NullEngine)ÚBuiltinSurface)ÚSurface)ÚOutlinec                   @   s<   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ ZdS )ÚTestBuiltinSurfaceSourcec                 C   sp   t ƒ }| ¡  | ¡ }tƒ }| |¡ tƒ }| |¡ tƒ }| |¡ d|j_	d|j_
d|j_|| _|j| _dS )ztInitial setting up of test fixture, automatically called by
        TestCase before any other test method is invokedçš™™™™™©?é   çš™™™™™¹?N)r   ÚstartZ	new_scener   Z
add_sourcer   Z
add_moduler   Údata_sourceÚshaft_radiusÚshaft_resolutionÚ
tip_radiusÚeÚcurrent_sceneÚscene)Úselfr   ÚsZ	poly_dataÚoutlineZsurface© r   úd/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/mayavi/tests/test_builtin_surface.pyÚsetUp   s    


zTestBuiltinSurfaceSource.setUpc                 C   s   | j  ¡  dS )ziFor necessary clean up, automatically called by TestCase
        after the test methods have been invokedN)r   Ústop)r   r   r   r   ÚtearDown1   s    
z!TestBuiltinSurfaceSource.tearDownc                 C   sR   | j }|jd }|  |jd¡ |  |jjd¡ |  |jjd¡ |  |jjd¡ dS )zDo the basic testingr   Zarrowr	   r
   r   N)r   ÚchildrenÚassertEqualÚsourcer   r   r   r   )r   r   Úsrcr   r   r   Útest_poly_data_source7   s    
z.TestBuiltinSurfaceSource.test_poly_data_sourcec                 C   sü   | j }|jd }|jd jd }| ¡  |  tj|jjjddd�d¡ |  tj|j	j
ddd�d¡ |  t |j	jd¡d¡ |  |j	jd¡ |  |j	jd	¡ |  t |j	jd
¡d¡ |  |j	jd¡ d|j	_d|j	_
|j	 ¡  |  tj|j	jddd�d¡ dS )zDo the actual testing.r   )ç      à¿ç      à?r!   r"   gffffffÞ¿gffffffÞ?gÎp>?ŒP?)ZatolTgq=
×£�:@)ç      ð?ç        r$   r"   r#   )r$   r$   r$   é
   g      ø?é   gƒÀÊ¡E¶ë?N)r   r   Úrenderr   ÚnumpyZallcloseZoutline_filterÚoutputZboundsr   ZangleÚ	directionZradiusÚheightÚcenterÚ
resolutionÚmodified©r   r   r   Zotr   r   r   ÚcheckB   s0    
þþÿÿ
zTestBuiltinSurfaceSource.checkc                 C   sH   | j }|jd }|jd jd }d|_d|j_|  |jd¡ |  ¡  dS )z,Test if it works fine on changing the sourcer   Úconer%   N)r   r   r   r   r-   r   r0   r/   r   r   r   Útest_change\   s    
z$TestBuiltinSurfaceSource.test_changec                 C   sp   | j }| j}|jd }d|_d|j_tƒ }tdƒ|_| 	|¡ | 
d¡ | |¡ | |¡ |j| _|  ¡  dS )z6Test if saving a visualization and restoring it works.r   r1   r%   ztest.mv2N)r   r   r   r   r   r-   r   r   ÚnameZsave_visualizationÚseekZclose_sceneZload_visualizationr   r0   )r   Zenginer   r   Úfr   r   r   Útest_save_and_restorei   s    





z.TestBuiltinSurfaceSource.test_save_and_restoreN)	Ú__name__Ú
__module__Ú__qualname__r   r   r    r0   r2   r6   r   r   r   r   r      s   r   Ú__main__)Úos.pathr   Úior   r(   ZunittestZmayavi.core.null_enginer   Zmayavi.sources.builtin_surfacer   Zmayavi.modules.surfacer   Zmayavi.modules.outliner   ZTestCaser   r7   Úmainr   r   r   r   Ú<module>   s   m