3
ÌœŸW%  ã               @   s<   d Z ddlZddlmZ ddlmZ ddljZ	d
dd	„Z
dS )zT
A helper function to retrieve the data from Mayavi structures on
arbitrary points.
é    N)Útvtké   )ÚtoolsÚscalarsÚpointsc             C   s‚  t j| ƒd }|dks"td| ƒ‚tj|ƒ}tj|ƒ}tj|ƒ}|j}|j|j  ko\|kn  sjtdƒ‚tjtj|j	ƒ |j	ƒ |j	ƒ f d� }}	t
|ƒ}tjƒ }
tj|
|ƒ tj|
|ƒ |
jƒ  |dkrÔ|
jj}n|dkræ|
jj}ntd	| ƒ‚t||ƒ}|d
k�rtd||f ƒ‚|jƒ }|dk�r6tj||ƒ}nH|dk�r`tj||dg ƒ}tj|dƒ}ntj||dg ƒ}tj|dƒ}|S )a«   Retrieve the data from a described by Mayavi visualization object
        at points x, y, z.

        **Parameters**

        :viz_obj: A Mayavi visualization object, or a VTK dataset
                  The object describing the data you are interested in.
        :x: float or ndarray.
            The x position where you want to retrieve the data.
        :y: float or ndarray.
            The y position where you want to retrieve the data.
        :z: float or ndarray
            The z position where you want to retrieve the data.
        :type: 'scalars', 'vectors' or 'tensors', optional
            The type of the data to retrieve.
        :location: 'points' or 'cells', optional
            The location of the data to retrieve.

        **Returns**

        The values of the data at the given point, as an ndarray
        (or multiple arrays, in the case of vectors or tensors) of the
        same shape as x, y, and z.
    r   r   ÚvectorsÚcellszSInvalid value for type: must be 'scalars', 'vectors' or 'cells', but '%s' was givenz1The x, y and z arguments must have the same shape)r   r   zQInvalid value for data location, must be 'points' or 'cells', but '%s' was given.Nz*The object given has no %s data of type %sé   r   )r   r   r   éÿÿÿÿr
   r
   )r   Zget_vtk_srcÚAssertionErrorÚnpÚ
atleast_1dÚshaper   ÚPolyDataÚc_ÚravelÚlistZProbeFilterÚtvtk_commonÚconfigure_input_dataÚconfigure_source_dataÚupdateÚoutputZ
point_dataZ	cell_dataÚ
ValueErrorÚgetattrZto_arrayÚreshapeÚrollaxis)Zmayavi_objectÚxÚyÚzÚtypeÚlocationÚdatasetr   Ú
probe_dataÚmeshZprobeÚdataÚvalues© r&   úZ/home/yuhw/wc/wire-cell-python/venv/lib/python3.6/site-packages/mayavi/tools/probe_data.pyr"      sJ    









r"   )r   r   )Ú__doc__Únumpyr   Útvtk.apir   Ú r   Ztvtk.commonÚcommonr   r"   r&   r&   r&   r'   Ú<module>   s
   
