3
îÈ‘[¤  ã               @   sT   d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 dd„ Zd	d
„ ZdS )z*Common code used by different components.
é    )Útvtk)Úconfigure_input)Ú	Component)Úerror)Úget_new_outputc             C   s"   | }xt |tƒr|jd }qW |S )z…Given an object (either a component or a module), return the
    ModuleManager managing the module that contains this component.
    r   )Ú
isinstancer   Úinputs)ÚobjÚo© r   ú[/home/yuhw/wc/wire-cell-python/venv/lib/python3.6/site-packages/mayavi/components/common.pyÚget_module_source   s    r   c             C   sœ   t | ƒ}| jdƒs|jdƒr | S tjtjtjtjtjtjdœ}d}x&|jƒ D ]\}}|j|ƒrL|ƒ }P qLW |dk	rˆt	|| ƒ |j
ƒ  |S td|jj ƒ dS )z¨Given a VTK dataset object, this returns the data as PolyData.
    This is primarily used to convert the data suitably for filters
    that only work for PolyData.
    ÚvtkPolyData)ÚvtkStructuredPointsÚvtkImageDataÚvtkRectilinearGridÚvtkStructuredGridÚvtkUnstructuredGridÚvtkCompositeDataSetNz%Given object is not a VTK dataset: %s)r   Úis_ar   ZImageDataGeometryFilterZRectilinearGridGeometryFilterZStructuredGridGeometryFilterZGeometryFilterZCompositeDataGeometryFilterÚitemsr   Úupdater   Ú	__class__Ú__name__)r	   ÚdataÚconvZfilÚnameZ	fil_classr   r   r   Úconvert_to_poly_data   s&    


r   N)Ú__doc__Útvtk.apir   Ztvtk.commonr   Zmayavi.core.componentr   Úmayavi.core.commonr   Zmayavi.core.utilsr   r   r   r   r   r   r   Ú<module>   s   
