a
    «ˆc¤  ã                   @   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   | }t |tƒr|jd }q|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/wcpy/lib/python3.9/site-packages/mayavi/components/common.pyÚget_module_source   s    
r   c                 C   sš   t | ƒ}|  d¡s| d¡r | S tjtjtjtjtjtjdœ}d}| ¡ D ]\}}| |¡rJ|ƒ } qhqJ|dur†t	|| ƒ | 
¡  |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.
    ZvtkPolyData)ZvtkStructuredPointsZvtkImageDataZvtkRectilinearGridZvtkStructuredGridZvtkUnstructuredGridZvtkCompositeDataSetNz%Given object is not a VTK dataset: %s)r   Z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__Ztvtk.apir   Ztvtk.commonr   Zmayavi.core.componentr   Zmayavi.core.commonr   Zmayavi.core.utilsr   r   r   r   r   r   r   Ú<module>   s   
