3
ÌœŸW   ã               @   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jƒ  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 ƒ }|jƒ  |jƒ }tƒ }|j|ƒ tƒ }|j|ƒ tƒ }|j|ƒ 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 invokedgš™™™™™©?é   gš™™™™™¹?N)r   ÚstartZ	new_scener   Z
add_sourcer   Z
add_moduler   Údata_sourceÚshaft_radiusÚshaft_resolutionÚ
tip_radiusÚeÚcurrent_sceneÚscene)Úselfr   ÚsÚ	poly_dataÚoutlineZsurface© r   úd/home/yuhw/wc/wire-cell-python/venv/lib/python3.6/site-packages/mayavi/tests/test_builtin_surface.pyÚsetUp   s    


zTestBuiltinSurfaceSource.setUpc             C   s   | j 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|jdƒ | j|jjdƒ | j|jjdƒ | j|jjdƒ dS )zDo the basic testingr   Zarrowgš™™™™™©?r	   gš™™™™™¹?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 }|jƒ  | jtj|jjjddd�dƒ | jtj|j	j
ddd�dƒ | jtj|j	jdƒdƒ | j|j	jdƒ | j|j	jdƒ | jtj|j	jdƒdƒ | j|j	jd
ƒ d|j	_d|j	_
|j	jƒ  | jtj|j	jddd�dƒ dS )zDo the actual testing.r   ç      à?çffffffÞ?gÎp>?ŒP?)ÚatolTgq=
×£�:@ç      ð?ç        é
   g      ø?é   gƒÀÊ¡E¶ë?Nç      à¿ç      à¿çffffffÞ¿)r'   r    r(   r    r)   r!   )r#   r$   r$   )r$   r$   r$   )r   r   Úrenderr   ÚnumpyÚallcloseZoutline_filterÚoutputÚboundsr   ÚangleÚ	directionÚradiusÚheightÚcenterÚ
resolutionÚmodified)r   r   r   Úotr   r   r   ÚcheckB   s$    

zTestBuiltinSurfaceSource.checkc             C   sH   | j }|jd }|jd jd }d|_d|j_| j|jdƒ | jƒ  dS )z,Test if it works fine on changing the sourcer   Úconer%   N)r   r   r   r   r4   r   r7   )r   r   r   r6   r   r   r   Útest_change\   s    
z$TestBuiltinSurfaceSource.test_changec             C   sp   | j }| j}|jd }d|_d|j_tƒ }tdƒ|_|j	|ƒ |j
dƒ |j|ƒ |j|ƒ |j| _| jƒ  dS )z6Test if saving a visualization and restoring it works.r   r8   r%   ztest.mv2N)r   r   r   r   r   r4   r   r   ÚnameZsave_visualizationÚseekZclose_sceneZload_visualizationr   r7   )r   Úenginer   r   Úfr   r   r   Útest_save_and_restorei   s    





z.TestBuiltinSurfaceSource.test_save_and_restoreN)	Ú__name__Ú
__module__Ú__qualname__r   r   r   r7   r9   r>   r   r   r   r   r      s   r   Ú__main__)Úos.pathr   Úior   r+   ÚunittestÚmayavi.core.null_enginer   Zmayavi.sources.builtin_surfacer   Zmayavi.modules.surfacer   Zmayavi.modules.outliner   ÚTestCaser   r?   Úmainr   r   r   r   Ú<module>   s   m