a
    «cb  ć                   @   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u rt ddd} |du r,t ddt d}|du r@t ddd}t|| dddf   ” }t|| dddf   ” }tt|t| dg}d}|D ]P}|t| }||| }	||	dddf< ||	ddd	f< ||	dddf< |}q|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      š?ē       @é   r   é   g        é   é   )r   r   r   Śravelr   r   Ślen)
ŚrŚthetaŚzZx_planeZy_planeŚpointsŚstartZz_planeŚendZplane_points© r   śX/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/mayavi/tests/datasets.pyŚgenerate_annulus   s    r   c                  C   s   t g d¢g d¢g d¢g d¢g d¢g d¢g d¢g d¢g d¢g d¢g d	¢g d
¢gd} t g d¢g d¢g d¢g}t ” j}tj| d}| ||” |S )zhSimple example showing how to create an unstructured grid
    consisting of cells of a single type.
    ©r   r   r   ©r   r   r   ©r   r   r   ©r   r   r   ©r   r   r   )r   r   r   )r   r   r   ©r   r   r   ©r   r   r   ©r   r   r   Śf)r   r   r   r   )é   é   é   é   )é   é	   é
   r   ©r   )r   r   ŚTetraŚ	cell_typeŚUnstructuredGridŚ	set_cells)r   ZtetsZtet_typeŚugr   r   r   Śsingle_type_ugG   s    žż
r2   c                  C   sŌ   t g d¢g d¢g d¢g d¢g d¢g d¢g d¢g d¢g d	¢g d
¢g d¢g d¢gd} | dddf  d7  < t g d¢}t ddg}t ” j}t ” j}t ||g}t ” }| d|” tj| d}| |||” |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    r!   )r   r   r   r"   r#   )r   r   r   )r   r   r   )r   r   r   r$   Nr   r   )r%   r   r   r   r   r)   r%   r&   r'   r(   r)   r*   r+   r   r   r&   r   r,   )r   r   r-   r.   Z
HexahedronZ	CellArrayr0   r/   )r   ŚcellsŚoffsetZ
tetra_typeZhex_typeZ
cell_typesZ
cell_arrayr1   r   r   r   Śmixed_type_ugU   s"    žż

r5   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
_d	|j
j_|S )
zGenerates Structured Grid)é    r6   é   r   r   r   )Z
dimensionsr+   r&   NŚscalars)r   ZStructuredGridr   Śnumpyr   r   r   r   r   ŚcopyŚ
point_datar8   Śname)ŚdimsZsgridr   r   r   ZptsŚsr   r   r   ŚgenerateStructuredGrids   s    @
r?   c                  C   sH   t  } tdddd}t dd”}|| j_d| jj_|| j_d| jj_| S ©	zGenerates Untructured Gridr   éx   r+   Śdr7   r   ŚtemperatureŚvelocity)r2   r	   r
   Śrandnr;   r8   r<   Śvectors©r1   rC   rD   r   r   r   ŚgenerateUnstructuredGrid_single   s    

rH   c                  C   sH   t  } tdddd}t dd”}|| j_d| jj_|| j_d| jj_| S r@   )r5   r	   r
   rE   r;   r8   r<   rF   rG   r   r   r   ŚgenerateUnstructuredGrid_mixed   s    

rI   )NNN)r9   r   r   r   r   r   r   r   r	   r
   Ztvtk.apir   r   r2   r5   r?   rH   rI   r   r   r   r   Ś<module>   s   ,
8