3
5Ad]b  ã               @   sv   d dl Z d dl mZmZmZmZmZmZmZmZm	Z	 d dl
mZ ddd„Zdd„ Zdd	„ Zd
d„ Zdd„ Zdd„ ZdS )é    N)	ÚlinspaceÚcosÚsinÚpiÚemptyÚsqrtÚarrayÚarangeÚrandom)Útvtkc       
      C   sò   | dkrt dddƒ} |dkr,t ddt dƒ}|dkr@t dddƒ}t|ƒ| dd…df  jƒ }t|ƒ| dd…df  jƒ }tt|ƒt|ƒ dgƒ}d}xX|D ]P}|t|ƒ }|||… }	||	dd…df< ||	dd…d	f< ||	dd…df< |}qšW |S )
a·   Generate points for structured grid for a cylindrical annular
        volume.  This method is useful for generating a unstructured
        cylindrical mesh for VTK (and perhaps other tools).

        Parameters
        ----------
        r : array : The radial values of the grid points.
                    It defaults to linspace(1.0, 2.0, 11).

        theta : array : The angular values of the x axis for the grid
                        points. It defaults to linspace(0,2*pi,11).

        z: array : The values along the z axis of the grid points.
                   It defaults to linspace(0,0,1.0, 11).

        Return
        ------
        points : array
            Nx3 array of points that make up the volume of the annulus.
            They are organized in planes starting with the first value
            of z and with the inside "ring" of the plane as the first
            set of points.  The default point array will be 1331x3.
    Ng      ð?g       @é   r   é   g        é   é   )r   r   r   Úravelr   r   Úlen)
ÚrÚthetaÚzZx_planeZy_planeÚpointsÚstartZz_planeÚendZplane_points© r   ú|/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.6/site-packages/mayavi-4.7.1-py3.6-linux-x86_64.egg/mayavi/tests/datasets.pyÚgenerate_annulus   s$       
r   c              C   s¶   t dddgdddgdddgdddgdddgdddgdddgdddgdddgdddgdddgdddggdƒ} t ddddgdddd	gd
dddggƒ}tjƒ j}tj| d�}|j||ƒ |S )zhSimple example showing how to create an unstructured grid
    consisting of cells of a single type.
    r   r   r   r   Úfé   é   é   é   é   é	   é
   r   )r   )r   r   ÚTetraÚ	cell_typeÚUnstructuredGridÚ	set_cells)r   ZtetsZtet_typeÚugr   r   r   Úsingle_type_ugG   s    " "&
r(   c              C   s  t dddgdddgdddgdddgdddgdddgdddgdddgdddgdddgdddgdddggdƒ} | dd…df  d7  < t dddddd	dd
ddd	dddgƒ}t dd
gƒ}tjƒ j}tjƒ j}t ||gƒ}tjƒ }|jd|ƒ tj| d�}|j|||ƒ |S )z•A slightly more complex example of how to generate an
    unstructured grid with different cell types.  Returns a created
    unstructured grid.
    r   r   r   r   r   Ng       @r   r    r   r   r   r!   r"   r   )r   )r   r   r#   r$   Z
HexahedronZ	CellArrayr&   r%   )r   ÚcellsÚoffsetZ
tetra_typeZhex_typeZ
cell_typesZ
cell_arrayr'   r   r   r   Úmixed_type_ugU   s     " "

r+   c              C   sÊ   d} t j| d | d | d fd�}tdd| d ƒ}tddtj | d ƒ}tdd| d ƒ}t|||ƒ}||_t|d	d	…df d |d	d	…df d  |d	d	…df d  ƒ}tj|j	ƒ ƒ|j
_d
|j
j_|S )zGenerates Structured Gridé    é   r   r   r   )Ú
dimensionsr"   r   NÚscalars)r,   r,   r-   )r   ZStructuredGridr   Únumpyr   r   r   r   r   ÚcopyÚ
point_datar/   Úname)ÚdimsZsgridr   r   r   ZptsÚsr   r   r   ÚgenerateStructuredGrids   s    @
r6   c              C   sH   t ƒ } tddddƒ}tjddƒ}|| j_d| jj_|| j_d| jj_| S )	zGenerates Untructured Gridr   éx   r"   Údr-   r   ÚtemperatureÚvelocity)r(   r	   r
   Úrandnr2   r/   r3   Úvectors)r'   r9   r:   r   r   r   ÚgenerateUnstructuredGrid_single‚   s    

r=   c              C   sH   t ƒ } tddddƒ}tjddƒ}|| j_d| jj_|| j_d| jj_| S )	zGenerates Untructured Gridr   r7   r"   r8   r-   r   r9   r:   )r+   r	   r
   r;   r2   r/   r3   r<   )r'   r9   r:   r   r   r   ÚgenerateUnstructuredGrid_mixedŽ   s    

r>   )NNN)r0   r   r   r   r   r   r   r   r	   r
   Ztvtk.apir   r   r(   r+   r6   r=   r>   r   r   r   r   Ú<module>   s   ,
8