
    +jɺ                        d Z 	 ddlZn# e$ r  ed          w xY w eej                            d          d                   ZddlZddl	Z	ddl
Z
ddlmZ ddlmZ ddlmZ dd	lmZ ddlZd
 Z G d d          Z G d de          Zd=dZd>dZd Zd Z G d de          Z ee           G d dej                              Z G d de          Z ee           G d de                      Z  e             Z! G d de          Z" ee"           G d de                      Z# G d  d!e          Z$ G d" d#          Z% G d$ d%e          Z& G d& d'e&          Z' G d( d)e          Z( G d* d+e(          Z) G d, d-e(          Z* G d. d/e(          Z+ G d0 d1e(          Z, G d2 d3e,          Z- G d4 d5e-          Z. G d6 d7e-          Z/ G d8 d9e(          Z0 G d: d;e(          Z1d< Z2dS )?aV  This module provides classes that allow Numpy-type access
to VTK datasets and arrays. This is best described with some examples.

To normalize a VTK array:

from vtkmodules.vtkImagingCore vtkRTAnalyticSource
import vtkmodules.numpy_interface.dataset_adapter as dsa
import vtkmodules.numpy_interface.algorithms as algs

rt = vtkRTAnalyticSource()
rt.Update()
image = dsa.WrapDataObject(rt.GetOutput())
rtdata = image.PointData['RTData']
rtmin = algs.min(rtdata)
rtmax = algs.max(rtdata)
rtnorm = (rtdata - rtmin) / (rtmax - rtmin)
image.PointData.append(rtnorm, 'RTData - normalized')
print image.GetPointData().GetArray('RTData - normalized').GetRange()

To calculate gradient:

grad= algs.gradient(rtnorm)

To access subsets:

>>> grad[0:10]
VTKArray([[ 0.10729134,  0.03763443,  0.03136338],
       [ 0.02754352,  0.03886006,  0.032589  ],
       [ 0.02248248,  0.04127144,  0.03500038],
       [ 0.02678365,  0.04357527,  0.03730421],
       [ 0.01765099,  0.04571581,  0.03944477],
       [ 0.02344007,  0.04763837,  0.04136734],
       [ 0.01089381,  0.04929155,  0.04302051],
       [ 0.01769151,  0.05062952,  0.04435848],
       [ 0.002764  ,  0.05161414,  0.04534309],
       [ 0.01010841,  0.05221677,  0.04594573]])

>>> grad[:, 0]
VTKArray([ 0.10729134,  0.02754352,  0.02248248, ..., -0.02748174,
       -0.02410045,  0.05509736])

All of this functionality is also supported for composite datasets
even though their data arrays may be spread across multiple datasets.
We have implemented a VTKCompositeDataArray class that handles many
Numpy style operators and is supported by all algorithms in the
algorithms module.

This module also provides an API to access composite datasets.
For example:

from vtkmodules.vtkCommonDataModel import vtkMultiBlockDataSet
mb = vtkMultiBlockDataSet()
mb.SetBlock(0, image.VTKObject)
mb.SetBlock(1e, image.VTKObject)
cds = dsa.WrapDataObject(mb)
for block in cds:
    print block

Note that this module implements only the wrappers for datasets
and arrays. The classes implement many useful operators. However,
to make best use of these classes, take a look at the algorithms
module.
    NzWThis module depends on the numpy module. Please makesure that it is installed properly..   )buffer_shared)numpy_support)vtkDataObject)vtkWeakReferencec                    | |g}t          | t          j                  rt          |t          j                  rt          | j                  }t          |j                  }||k    s(|dk    s"|dk    s| j        d         |j        d         k    r|S ||k     r|}|}d}n|}|}d}||k     r)t          j        ||         |          ||<   |dz   }||k     )|S )ae  Returns a list with the two arguments, any of them may be
    processed.  If the arguments are numpy.ndarrays, append 1s to the
    shape of the array with the smallest number of dimensions until
    the arrays have the same number of dimensions. Does nothing if the
    arguments are not ndarrays or the arrays have the same number of
    dimensions.

    r      )
isinstancenumpyndarraylenshapeexpand_dims)a1a2llen1len2d	maxLengthis           d/DATA/AppData/hermes/venv/lib/python3.11/site-packages/vtkmodules/numpy_interface/dataset_adapter.pyreshape_append_onesr   R   s     
RA2u}%% *R*G*G 28}}28}}DLLDAIIHQK28A;&&HTkkAIAAAIA9}}$QqT1--AaDAA 9}} H    c                   J    e Zd ZdZej        Zej        Zej        Zej        ZdS )ArrayAssociationz+Easy access to vtkDataObject.AttributeTypesN)	__name__
__module____qualname____doc__r   POINTCELLFIELDROW r   r   r   r   o   s4        55EDE

CCCr   r   c                       e Zd ZdZd Zd ZdS )VTKObjectWrapperzSuperclass for classes that wrap VTK objects with Python objects.
    This class holds a reference to the wrapped VTK object. It also
    forwards unresolved methods to the underlying object by overloading
    __get__attr.c                     || _         d S N)	VTKObjectself	vtkobjects     r   __init__zVTKObjectWrapper.__init__{   s    "r   c                 ,    t          | j        |          S )z2Forwards unknown attribute requests to VTK object.)getattrr+   r-   names     r   __getattr__zVTKObjectWrapper.__getattr__~   s    t~t,,,r   N)r   r   r    r!   r/   r4   r&   r   r   r(   r(   v   s<         # # #- - - - -r   r(   c                     t          j        |           }|j        }t          |          dk    r?|d         dk    r3|                    |d         ddf                              ddd          }t          || |          S )zAGiven a vtkDataArray and a dataset owning it, returns a VTKArray.r   r
   	   r      )arraydataset)r   vtk_to_numpyr   r   reshape	transposeVTKArray)r8   r9   narrayr   s       r   vtkDataArrayToVTKArrayr?      sy    '..F LE
5zzQ58q==q1a 011;;Aq!DDF%9999r   numpy_arrayc                 \    t          j        | |          }|                    |           |S )zGiven a numpy array or a VTKArray and a name, returns a vtkDataArray.
    The resulting vtkDataArray will store a reference to the numpy array:
    the numpy array is released only when the vtkDataArray is destroyed.
array_type)r   numpy_to_vtkSetName)r8   r3   rC   vtkarrays       r   numpyTovtkDataArrayrG      s2     )%JGGGHTOr   c                    | d S | j         j        r| S t          j        |           } | j        j        }| j        }t          |          dk    r5|d         |z  dk    r&|d         |z  dk    r|                     ddd          S | S )Nr7   r
   r   r   )	flags
contiguousr   asarraydtypeitemsizestridesr   r<   )r8   sizerN   s      r   _make_tensor_array_contiguousrP      s    }t{ M%  E;DmG
7||qWQZ_11gajo6J6Jq!Q'''Lr   c                       fd}|S )z0For compatibility between python 2 and python 3.c                     t          |                                           }|                    dd            |                    dd             | j        | j        |          S )N__dict____weakref__)varscopypopr   	__bases__)clsbodymcss     r   	decoratorz_metaclass.<locals>.decorator   sX    Cyy~~T"""%%%s3<555r   r&   )r[   r\   s   ` r   
_metaclassr]      s$    6 6 6 6 6
 r   c                       e Zd Zd ZdS )VTKArrayMetaClassc                    fdfdfdfdfd} |d            |d            |d            |d	            |d
            |d            |d            |d            |d            d            |d            d            d            d            d            d            d            d           t                               | ||          S )a  We overwrite numerical/comparison operators because we might need
        to reshape one of the arrays to perform the operation without
        broadcast errors. For instance:

        An array G of shape (n,3) resulted from computing the
        gradient on a scalar array S of shape (n,) cannot be added together without
        reshaping.
        G + expand_dims(S,1) works,
        G + S gives an error:
        ValueError: operands could not be broadcast together with shapes (n,3) (n,)

        This metaclass overwrites operators such that it computes this
        reshape operation automatically by appending 1s to the
        dimensions of the array with fewer dimensions.

        c                 ,      fd} |_         | <   dS )XCreate an attribute named attr_name that calls
            _numeric_op(self, other, op).c                 <    t                               | |          S r*   )r=   _numeric_opr-   other	attr_names     r   closurezBVTKArrayMetaClass.__new__.<locals>.add_numeric_op.<locals>.closure   s    ++D%CCCr   Nr   rg   rh   attrs   ` r   add_numeric_opz1VTKArrayMetaClass.__new__.<locals>.add_numeric_op   s7    D D D D D(G%DOOOr   c                 $     d| z             dS z;Adds '__[op_name]__' attribute that uses operator.[op_name]z__%s__Nr&   op_namerl   s    r   add_default_numeric_opz9VTKArrayMetaClass.__new__.<locals>.add_default_numeric_op   s    N8G+,,,,,r   c                 ,      fd} |_         | <   dS )`Create an attribute named attr_name that calls
            _reverse_numeric_op(self, other, op).c                 <    t                               | |          S r*   )r=   _reverse_numeric_opre   s     r   rh   zJVTKArrayMetaClass.__new__.<locals>.add_reverse_numeric_op.<locals>.closure   s    33D%KKKr   Nri   rj   s   ` r   add_reverse_numeric_opz9VTKArrayMetaClass.__new__.<locals>.add_reverse_numeric_op   s7    L L L L L(G%DOOOr   c                 $     d| z             dS z<Adds '__r[op_name]__' attribute that uses operator.[op_name]z__r%s__Nr&   rp   rv   s    r   add_default_reverse_numeric_opzAVTKArrayMetaClass.__new__.<locals>.add_default_reverse_numeric_op   s    ""9W#455555r   c                 4     |             |            dS zDCall both add_default_numeric_op and add_default_reverse_numeric_op.Nr&   rp   rq   rz   s    r   add_default_numeric_opsz:VTKArrayMetaClass.__new__.<locals>.add_default_numeric_ops   +    ""7+++**733333r   addsubmultruedivfloordivmodpowlshiftrshiftandxororltleeqnegegt)type__new__	r[   r3   parentrk   r~   rq   rz   rl   rv   s	      ` @@@@r   r   zVTKArrayMetaClass.__new__   s   "	& 	& 	& 	& 	&	- 	- 	- 	- 	-	& 	& 	& 	& 	&	6 	6 	6 	6 	6	4 	4 	4 	4 	4 	4
 	 &&&&&&&&&	***
+++&&&&&&))))))u&&&tt$$$t$$$t$$$t$$$t$$$t$$$||Cvt444r   Nr   r   r    r   r&   r   r   r_   r_      s(        A5 A5 A5 A5 A5r   r_   c                   p    e Zd ZdZd Zd ZddZd Zd Zdd	Z	e
d
             Zej        d             ZdS )r=   zThis is a sub-class of numpy ndarray that stores a
    reference to a vtk array as well as the owning dataset.
    The numpy array and vtk array should point to the same
    memory location.c                     t          | |          } t          t          j        |          |d         |d                   S YUsed to implement numpy-style numerical operations such as __add__,
        __mul__, etc.r   r
   r   r1   r   r   r-   rf   rg   r   s       r   rd   zVTKArray._numeric_op   9      e,,0wu}i001qt<<<r   c                     t          | |          } t          t          j        |          |d         |d                   S r   r   r   s       r   ru   zVTKArray._reverse_numeric_op   r   r   Nc                     t          j        |                              |           }t          j        |_        ||_        |r2t                      |_        |j        	                    |j                   |S r*   )
r   rK   viewr   r$   Associationr+   r   _datasetSet)rY   input_arrayr8   r9   objs        r   r   zVTKArray.__new__  se     mK((--c22*0 	0+--CLLW.///
r   c                    t          |           }t          |          }d | _        	 t          ||          rt          |dd           | _        n# t          $ r Y nw xY wt          |dd           | _        t          |dd           | _        d S )Nr+   r   DataSet)rP   r+   r   r1   	TypeErrorr   r   )r-   r   slfobj2s       r   __array_finalize__zVTKArray.__array_finalize__  s    +D11,S11	 S$'' A!(k4!@!@ 	 	 	D	 #3t<<sIt44s   &A 
AAc                     	 | j         d         }n# t          $ r d}Y nw xY w| t          d| j        j        d|d          t          ||          S )z1Forwards unknown attribute requests to VTK array.r+   N'z' object has no attribute ')rS   KeyErrorAttributeError	__class__r   r1   )r-   r3   os      r   r4   zVTKArray.__getattr__   s    	k*AA 	 	 	AAA	9 ."&."9"9"9444"A B B Bq$s    Fc                     |st           dk     r|j        dk    r|d         S t          j                            | ||          S )Nr   r&   )NUMPY_MAJOR_VERSIONr   r   r   __array_wrap__)r-   out_arrcontextreturn_scalars       r   r   zVTKArray.__array_wrap__+  sF     	H0144"9L9L2;=//gwGGGr   c                     t          | d          rF| j        r?| j                                        r&t          | j                                                  S dS )z
        Get the dataset this array is associated with. The reference to the
        dataset is held through a vtkWeakReference to ensure it doesn't prevent
        the dataset from being collected if necessary.
        r   N)hasattrr   GetWrapDataObjectr-   s    r   r   zVTKArray.DataSet2  sU     4$$ 	7 	74=;L;L;N;N 	7!$-"3"3"5"5666r   c                     |rR|j         rKt          | d          r| j        t                      | _        | j                            |j                    dS d| _        dS )zz
        Set the dataset this array is associated with. The reference is held
        through a vtkWeakReference.
        r   N)r+   r   r   r   r   )r-   r9   s     r   r   zVTKArray.DataSet>  sf      	!w( 	!4,, 30E 0 2 2Mg/00000 DMMMr   )NN)NF)r   r   r    r!   rd   ru   r   r   r4   r   propertyr   setterr&   r   r   r=   r=      s         
= = == = =   5 5 5"	  	  	 H H H H 	 	 X	 ^! ! ^! ! !r   r=   c                       e Zd Zd ZdS )VTKNoneArrayMetaClassc                 ~   fdfdfdfd} |d            |d            |d            |d            |d	            |d
            |d            |d            |d            dt           j                    dt           j                    |d            dt           j                    dt           j                    d            d            d            d            d            d           t                              | ||          S )@Simplify the implementation of the numeric/logical sequence API.c                 ,    fd}| |_         || <   dS )rb   c                 <    t                               | |          S r*   )VTKNoneArray_opr-   rf   ops     r   rh   z?VTKNoneArrayMetaClass.__new__.<locals>._add_op.<locals>.closureT  s    #''eR888r   Nri   rg   r   rh   rk   s    ` r   _add_opz.VTKNoneArrayMetaClass.__new__.<locals>._add_opQ  s2    9 9 9 9 9(G%DOOOr   c                 L     d| z  t          t          |                      dS rx   r1   operatorrp   r   s    r   _add_default_reverse_opz>VTKNoneArrayMetaClass.__new__.<locals>._add_default_reverse_opY  s*    GIg%wx'A'ABBBBBr   c                 L     d| z  t          t          |                      dS rn   r   r   s    r   _add_default_opz6VTKNoneArrayMetaClass.__new__.<locals>._add_default_op]  s*    GHW$gh&@&@AAAAAr   c                 4     |             |            dS r|   r&   )rp   r   r   s    r   _add_default_opsz7VTKNoneArrayMetaClass.__new__.<locals>._add_default_opsa  s*    OG$$$##G,,,,,r   r   r   r   r   r   r   r   r   r   __and____rand__r   __or____ror__r   r   r   r   r   r   r   and_or_r   r   )r[   r3   r   rk   r   r   r   r   s      ` @@@r   r   zVTKNoneArrayMetaClass.__new__O  s   	& 	& 	& 	& 	&	C 	C 	C 	C 	C	B 	B 	B 	B 	B	- 	- 	- 	- 	- 	-
 	###$$$""""""	8=)))
HM***(,'''	8<(((||Cvt444r   Nr   r&   r   r   r   r   N  s#        ,5 ,5 ,5 ,5 ,5r   r   c                   $    e Zd ZdZd Zd Zd ZdS )r   a  VTKNoneArray is used to represent a "void" array. An instance
    of this class (NoneArray) is returned instead of None when an
    array that doesn't exist in a DataSetAttributes is requested.
    All operations on the NoneArray return NoneArray. The main reason
    for this is to support operations in parallel where one of the
    processes may be working on an empty dataset. In such cases,
    the process is still expected to evaluate a whole expression because
    some of the functions may perform bulk MPI communication. None
    cannot be used in these instances because it cannot properly override
    operators such as __add__, __sub__ etc. This is the main raison
    d'etre for VTKNoneArray.c                     t           S r*   	NoneArray)r-   indexs     r   __getitem__zVTKNoneArray.__getitem__  s    r   c                     t           S )r   r   r   s      r   r   zVTKNoneArray._op  s
     r   c                     t           S )z'Implements numpy array's astype method.r   )r-   rL   s     r   astypezVTKNoneArray.astype  s    r   N)r   r   r    r!   r   r   r   r&   r   r   r   r   }  sK        
  
     
    r   r   c                       e Zd Zd ZdS )VTKCompositeDataArrayMetaClassc                    fdfdfdfdfd} |d            |d            |d            |d	            |d
            |d            |d            |d            |d            dt           j                    dt           j                    |d            dt           j                    dt           j                    d            d            d            d            d            d           t                              | ||          S )r   c                 ,    fd}| |_         || <   dS )rb   c                 <    t                               | |          S r*   )VTKCompositeDataArrayrd   r   s     r   rh   zOVTKCompositeDataArrayMetaClass.__new__.<locals>.add_numeric_op.<locals>.closure  s    ,88ubIIIr   Nri   r   s    ` r   rl   z>VTKCompositeDataArrayMetaClass.__new__.<locals>.add_numeric_op  s7    J J J J J(G%DOOOr   c                 ,    fd}| |_         || <   dS )rs   c                 <    t                               | |          S r*   )r   ru   r   s     r   rh   zWVTKCompositeDataArrayMetaClass.__new__.<locals>.add_reverse_numeric_op.<locals>.closure  s    ,@@ubQQQr   Nri   r   s    ` r   rv   zFVTKCompositeDataArrayMetaClass.__new__.<locals>.add_reverse_numeric_op  s7    R R R R R(G%DOOOr   c                 L     d| z  t          t          |                      dS rx   r   ry   s    r   rz   zNVTKCompositeDataArrayMetaClass.__new__.<locals>.add_default_reverse_numeric_op  s+    ""9W#4gh6P6PQQQQQr   c                 L     d| z  t          t          |                      dS rn   r   ro   s    r   rq   zFVTKCompositeDataArrayMetaClass.__new__.<locals>.add_default_numeric_op  s*    N8G+WXw-G-GHHHHHr   c                 4     |             |            dS r|   r&   r}   s    r   r~   zGVTKCompositeDataArrayMetaClass.__new__.<locals>.add_default_numeric_ops  r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   s	      ` @@@@r   r   z&VTKCompositeDataArrayMetaClass.__new__  s   	& 	& 	& 	& 	&	& 	& 	& 	& 	&	R 	R 	R 	R 	R	I 	I 	I 	I 	I	4 	4 	4 	4 	4 	4
 	 &&&&&&&&&	***
+++&&&&&&))))))y(-000z8=999&&&x...y(,777t$$$t$$$t$$$t$$$t$$$t$$$||Cvt444r   Nr   r&   r   r   r   r     s#        45 45 45 45 45r   r   c                   ~    e Zd ZdZg dddfdZd Zd Z ee          Zd Z	 ee	          Z
d Zd Zd	 Zd
 Zd ZdS )r   ad  This class manages a set of arrays of the same name contained
    within a composite dataset. Its main purpose is to provide a
    Numpy-type interface to composite data arrays which are naturally
    nothing but a collection of vtkDataArrays. A VTKCompositeDataArray
    makes such a collection appear as a single Numpy array and support
    all array operations that this module and the associated algorithm
    module support. Note that this is not a subclass of a Numpy array
    and as such cannot be passed to native Numpy functions. Instead
    VTK modules should be used to process composite arrays.
    Nc                     || _         || _        || _        d}|dk    r>| j         D ]6}t          |d          r$|dk    r|j        } |j        r||j        k    rd} n7|r|| _        nt
          j        | _        d| _        dS )a  Construct a composite array given a container of
        arrays, a dataset, name and association. It is sufficient
        to define a container of arrays to define a composite array.
        It is also possible to initialize an array by defining
        the dataset, name and array association. In that case,
        the underlying arrays will be created lazily when they
        are needed. It is recommended to use the latter method
        when initializing from an existing composite dataset.TNr   F)_Arraysr   Namer   r   r   r$   Initialized)r-   arraysr9   r3   associationvalidAssociationr8   s          r   r/   zVTKCompositeDataArray.__init__  s     	$  5-00 "d**&+&7* {e>O/O/O+0( 	6*D/5D r   c                     | j         rd S d| _         | j        | j        d S g | _        | j        D ]?}| j                            |                    | j                  | j                            @d S )NT)r   r   r   r   appendGetAttributesr   )r-   dss     r   __init_from_compositez+VTKCompositeDataArray.__init_from_composite  s     	F<49#4F, 	O 	OBL 0 01A B B49 MNNNN	O 	Or   c                     |                                   t          j        d          }| j        D ]}	 ||j        z  }# t
          $ r Y w xY w|S )z,Returns the number of elements in the array.r   )+_VTKCompositeDataArray__init_from_compositer   int64r   rO   r   )r-   rO   as      r   GetSizezVTKCompositeDataArray.GetSize  si    ""$$${1~~ 	 	A!   s   
>
A
Ac                 8    |                                   | j        S )z~Returns the internal container of VTKArrays. If necessary,
        this will populate the array list from a composite dataset.)r   r   r   s    r   	GetArrayszVTKCompositeDataArray.GetArrays  s     	""$$$|r   c                    |                                   g }t          |          t          k    rmt          | j        |j                  D ]Q\  }}|t          ur)|                    |                    |                     7|                    t                     RnV| j        D ]N}|t          ur)|                    |                    |                     4|                    t                     Ot          || j	                  S )aC  Overwritten to refer indexing to underlying VTKArrays.
        For the most part, this will behave like Numpy. Note
        that indexing is done per array - arrays are never treated
        as forming a bigger array. If the index is another composite
        array, a one-to-one mapping between arrays is assumed.
        r9   )
r   r   r   zipr   Arraysr   r   r   r   )r-   r   resr   idxs        r   r   z!VTKCompositeDataArray.__getitem__  s     	""$$$;;///dlEL99 * *3I%%JJq}}S112222JJy))))	* \ * *I%%JJq}}U334444JJy))))$S$,????r   c                 z   |                                   g }t          |          t          k    rt          | j        |j                  D ]m\  }}|t          urE|t          ur<t          ||          }|                     ||d         |d                              S|                    t                     nni| j        D ]a}|t          ur<t          ||          }|                     ||d         |d                              G|                    t                     bt          || j	        | j
                  S r   r   r
   r9   r   )r   r   r   r  r   r  r   r   r   r   r   r-   rf   r   r  r   r   r   r   s           r   rd   z!VTKCompositeDataArray._numeric_op2  sC    	""$$$;;///dlEL99 * *BY&&2Y+>+>+B33AJJrr!A$qt}}----JJy))))* \ * *I%%+Au55AJJrr!A$!~~....JJy))))$43CE E E 	Er   c                 z   |                                   g }t          |          t          k    rt          | j        |j                  D ]m\  }}|t          urE|t          u r<t          ||          }|	                     ||d         |d                              S|	                    t                     nni| j        D ]a}|t          ur<t          ||          }|	                     ||d         |d                              G|	                    t                     bt          || j
        | j                  S r  )r   r   r   r  r   r  r   notNoneArrayr   r   r   r   r  s           r   ru   z)VTKCompositeDataArray._reverse_numeric_opH  sC    	""$$$;;///dlEL99 * *BY&&2+=+=+Br22AJJrr!A$qt}}----JJy))))* \ * *I%%+E155AJJrr!A$!~~....JJy))))$T5EG G G 	Gr   c                 4    | j                                         S r*   )r  __str__r   s    r   r  zVTKCompositeDataArray.__str__^  s    {""$$$r   c                     g }| t           urV| j        D ]N}|t           u r|                    t                      &|                    |                    |                     Ot	          || j        | j                  S )z)Implements numpy array's as array method.r  )r   r  r   r   r   r   r   )r-   rL   r  r   s       r   r   zVTKCompositeDataArray.astypea  s    y  [ 0 0	>>JJy))))JJqxx////$4<t7GI I I 	Ir   )r   r   r    r!   r/   r   r  r   rO   r  r  r   rd   ru   r  r   r&   r   r   r   r     s        	 	 !#d4#! ! ! !8O O O	 	 	 8GD   Xi  F@ @ @.E E E,G G G,% % %
I 
I 
I 
I 
Ir   r   c                   F     e Zd ZdZ fdZd Zd Zd Zd Zd Z	d Z
 xZS )	DataSetAttributesa4  This is a python friendly wrapper of vtkDataSetAttributes. It
    returns VTKArrays. It also provides the dictionary interface.
    Note that the stored array should have a shape that matches the number
    of elements. E.g. for a PointData, narray.shape[0] should be equal
    to dataset.GetNumberOfPoints()c                 t    t          t          |                               |           || _        || _        d S r*   )superr  r/   r   r   )r-   r.   r9   r   r   s       r   r/   zDataSetAttributes.__init__u  s9    &&//	::: &r   c                 ,    |                      |          S )z;Implements the [] operator. Accepts an array name or index.GetArrayr-   r	  s     r   r   zDataSetAttributes.__getitem__|      }}S!!!r   c                 L   t          |t                    r,|| j                                        k    rt	          d          | j                            |          }|s%| j                            |          }|r|S t          S t          || j	                  }| j
        |_
        |S )z+Given an index or name, returns a VTKArray.zarray index out of range)r   intr+   GetNumberOfArrays
IndexErrorr  GetAbstractArrayr   r?   r   r   )r-   r	  rF   r8   s       r   r  zDataSetAttributes.GetArray  s    c3 	9C4>+K+K+M+M$M$M7888>**3// 	~66s;;H  &x>> ,r   c                     g }| j                                         }t          |          D ]E}| j                             |                                          }|r|                    |           F|S z*Returns the names of the arrays as a list.r+   r  ranger   GetNamer   )r-   kysnarraysr   r3   s        r   keyszDataSetAttributes.keys  sp    .2244w 	! 	!A>22155==??D !

4   
r   c                     g }| j                                         }t          |          D ]E}| j                             |          }|                                r|                    |           F|S )zReturns the arrays as a list.r#  )r-   valsr'  r   r   s        r   valueszDataSetAttributes.values  si    .2244w 	 	A//22Ayy{{ Ar   c                     	 | j                             |           dS # t          $ r# | j                             |j                    Y dS w xY w)z"A wrapper for vtkDataSet.PassData.N)r+   PassDatar   )r-   rf   s     r   r-  zDataSetAttributes.PassData  s_    	5N##E***** 	5 	5 	5N##EO444444	5s    )A
Ac                    |t           u rdS | j        t          j        k    r| j                                        }n| j        t          j        k    r| j                                        }nv| j        t          j        k    r7| j        	                                dk    r| j        
                                }n*t          |t          j                  sd}n|j        d         }t          |t          j                  rt          j        |          dk    r_t          |t          j                  r|j        nt#          |          }t          j        ||          }|                    |           |}n
|j        d         |k    rd}|j        D ]}||z  }	 t          j        ||f|j                  }n# t          j        j        j        $ r}t.          j                            d           t.          j                            t5          t#          |                    dz              t.          j                            t5          |                     Y d}~dS d}~ww xY w|                                |dd<   |}|j        }	t9          |	          dk    r|j        j        }
|j        d         |
z  dk    r|j        d         |
z  dk    s4|j        d         |
z  dk    r7|j        d         |
z  dk    r#|j        j         s|!                    ddd          }|j        j         st          j"        |          }t9          |	          dk    r+|#                    |	d         |	d         |	d         z            }tI          |          }	 |j%        |_%        n# tL          $ r Y nw xY wtO          ||          }| j%        (                    |           dS )	a  Appends narray to the dataset attributes.

        If narray is a scalar, create an array with this scalar for each element.
        If narray is an array with a size not matching the array association
        (e.g. size should be equal to GetNumberOfPoints() for PointData),
        copy the input narray for each element. This is intended to ease
        initialization, typically using same 3d vector for each element.
        In any case, be careful about memory explosion.Nr   r
   )rL   a]  Fail to copy input array for each dataset element: array is too big to be duplicated.
Input should either be small enough to be duplicated for each element, or shape[0] should match number of element.
Example of correct usage: to add a point PointData array, it is common to have
array.shape[0] == 3 or array.shape[0] == dataset.GetNumberOfPoints()

r7   r   ))r   r   r   r"   r   GetNumberOfPointsr#   GetNumberOfCellsr%   GetNumberOfColumnsGetNumberOfRowsr   r   r   r   ndimrL   r   emptyfillcore_exceptions_ArrayMemoryErrorsysstderrwritestrflattenr   rM   rN   rI   rJ   r<   ascontiguousarrayr;   r=   r+   r   rG   AddArray)r-   r>   r3   	arrLengthrL   tmparray
componentsr   npErrr   rO   rV   arrs                r   r   zDataSetAttributes.append  s    YF/5556688II!1!6665577II!1!555l--//!334466IIfem44 ,		"LO	 &%-00 	EJv4F4F!4K4K$.vu}$E$EWFLL4PV<<E{9E:::HMM&!!!FF\!_	))J\    a

 ;	:'>flSSS:); 	 	 	
   "Y    
  T%[[!1!1D!8999
  U,,,	 !..**HQQQKFu::?? <(Dq!$&!++q0A$0F!0K0K"4'1,,1B41G11L1L\, 2M **1a33 |& 	5,V44F u::??^^E!HeAhuQx.?@@F
 	$#-DNN###tt#!$--$$$$$s+   F2 2IBIIN 
NN)r   r   r    r!   r/   r   r  r(  r+  r-  r   __classcell__)r   s   @r   r  r  n  s        & &' ' ' ' '" " "      5 5 5S% S% S% S% S% S% S%r   r  c                   <    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	S )
CompositeDataSetAttributesan  This is a python friendly wrapper for vtkDataSetAttributes for composite
    datasets. Since composite datasets themselves don't have attribute data,
    but the attribute data is associated with the leaf nodes in the composite
    dataset, this class simulates a DataSetAttributes interface by taking a
    union of DataSetAttributes associated with all leaf nodes.c                 f    || _         || _        g | _        i | _        |                                  d S r*   )r   r   
ArrayNamesr  1_CompositeDataSetAttributes__determine_arraynames)r-   r9   r   s      r   r/   z#CompositeDataSetAttributes.__init__  s;     &
 	##%%%%%r   c                    t                      }g }| j        D ]a}|                    | j                  }|                                D ]0}||vr*|                    |           |                    |           1b|| _        d S r*   )setr   r   r   r(  r   r   rJ  )r-   	array_set
array_listr9   dsa
array_names         r   __determine_arraynamesz1CompositeDataSetAttributes.__determine_arraynames  s    EE	
| 	2 	2G''(899C!hhjj 2 2
Y..MM*---%%j1112 %r   c                     | j         S r"  )rJ  r   s    r   r(  zCompositeDataSetAttributes.keys  s
    r   c                 ,    |                      |          S )z2Implements the [] operator. Accepts an array name.r  r  s     r   r   z&CompositeDataSetAttributes.__getitem__"  r  r   c                    |t           u rdS d}t          |t                    sZ| j        D ]2}|                    | j                                      ||           d}3|r| j                            |           dS dS t          | j        |j	                  D ]7\  }}|0|                    | j                                      ||           d}8|r8| j                            |           t          j        |          | j	        |<   dS dS )z8Appends a new array to the composite dataset attributes.NFT)r   r   r   r   r   r   r   rJ  r  r  weakrefref)r-   r>   r3   addedr   r8   s         r   r   z!CompositeDataSetAttributes.append&  s1   YF&"788 	8l    !12299&$GGG -&&t,,,,,- -
 !v}== ! !	E$$$T%566==eTJJJ E 8&&t,,,$+K$7$7D!!!8 8r   c                    |}|| j         vrt          S || j        vs | j        |                     9t          | j        || j                  }t          j        |          | j        |<   n | j        |                     }|S )z*Given a name, returns a VTKCompositeArray.N)r9   r3   r   )rJ  r   r  r   r   r   rV  rW  )r-   r	  	arraynamer8   s       r   r  z#CompositeDataSetAttributes.GetArray>  s    	DO++DK''+A4;y+A+C+C+K),yHXZ Z ZE%,[%7%7DK	""*DK	*,,Er   c                 \   t          | j        |j                  D ]\  }}t          j        t          j        t          j        fD ]g}|                    |          rP|                    |          r;|                    |                              |                    |                     hdS )z(Emulate PassData for composite datasets.N)	r  r   r   r"   r#   r%   HasAttributesr   r-  )r-   rf   thisthatassocs        r   r-  z#CompositeDataSetAttributes.PassDataK  s    T\5=99 	R 	RID*02B2GIYI]^ R R%%e,, R1C1CE1J1J R&&u--66t7I7I%7P7PQQQR	R 	Rr   N)r   r   r    r!   r/   rK  r(  r   r   r  r-  r&   r   r   rH  rH    s        B B& & &	% 	% 	%  " " "8 8 80  R R R R Rr   rH  c                   0    e Zd ZdZd Zd Zd Zd Zd ZdS )CompositeDataIteratorzWrapper for a vtkCompositeDataIterator class to satisfy
       the python iterator protocol. This iterator iterates
       over non-empty leaf nodes. To iterate over empty or
       non-leaf nodes, use the vtkCompositeDataIterator directly.
       c                     |                                 | _        | j        r5| j                            d            | j                                         d S d S r*   )NewIteratorIterator
UnRegisterGoToFirstItemr-   cdss     r   r/   zCompositeDataIterator.__init__Y  sW    ))= 	*M$$T***M'')))))	* 	*r   c                     | S r*   r&   r   s    r   __iter__zCompositeDataIterator.__iter___  s    r   c                     | j         st          | j                                         rt          | j                                         }| j                                          t          |          S r*   )rd  StopIterationIsDoneWithTraversalGetCurrentDataObjectGoToNextItemr   )r-   retVals     r   __next__zCompositeDataIterator.__next__b  sc    } 	 =,,.. 	 3355""$$$f%%%r   c                 *    |                                  S r*   rq  r   s    r   nextzCompositeDataIterator.nextl      }}r   c                 ,    t          | j        |          S )z5Returns attributes from the vtkCompositeDataIterator.)r1   rd  r2   s     r   r4   z!CompositeDataIterator.__getattr__o  s    t}d+++r   N)	r   r   r    r!   r/   rj  rq  rt  r4   r&   r   r   ra  ra  R  si         * * *  & & &  , , , , ,r   ra  c                   $    e Zd ZdZd Zd Zd ZdS )MultiCompositeDataIteratorad  Iterator that can be used to iterate over multiple
    composite datasets together. This iterator works only
    with arrays that were copied from an original using
    CopyStructured. The most common use case is to use
    CopyStructure, then iterate over input and output together
    while creating output datasets from corresponding input
    datasets.c                 V    t                               | |d                    || _        d S )Nr   )ra  r/   Datasetsrg  s     r   r/   z#MultiCompositeDataIterator.__init__{  s'    &&tSV444r   c                    | j         st          | j                                         rt          g }|                    t	          | j                                                              t          | j                  dk    rL| j        dd          D ]<}|                    t	          |                    | j                                        =| j         	                                 |S )Nr
   )
rd  rl  rm  r   r   rn  r   rz  
GetDataSetro  )r-   rp  cds      r   rq  z#MultiCompositeDataIterator.__next__  s    } 	 =,,.. 	 nT]%G%G%I%IJJKKKt}!!mABB' L LnR]]4=-I-IJJKKKK""$$$r   c                 *    |                                  S r*   rs  r   s    r   rt  zMultiCompositeDataIterator.next  ru  r   N)r   r   r    r!   r/   rq  rt  r&   r   r   rx  rx  s  sK                 r   rx  c                   @    e Zd ZdZd Zd Zd Z eeddd          ZdS )
DataObjectz`A wrapper for vtkDataObject that makes it easier to access FielData
    arrays as VTKArrays
    c                     |t           j        k    r(t          | j                                        | |          S t          | j                            |          | |          S )zVReturns the attributes specified by the type as a DataSetAttributes
         instance.)r   r$   r  r+   GetFieldDatar   r-   r   s     r   r   zDataObject.GetAttributes  sU     #)))$T^%@%@%B%BD$OOO !=!=d!C!CT4PPPr   c                 "    |t           j        k    S z6Returns if current object support this attributes type)r   r$   r  s     r   r\  zDataObject.HasAttributes  s    '---r   c                 f    t          | j                                        | t          j                  S z7Returns the field data as a DataSetAttributes instance.)r  r+   r  r   r$   r   s    r   r  zDataObject.GetFieldData  s&     !<!<!>!>FVF\]]]r   Nz6This property returns the field data of a data object.)	r   r   r    r!   r   r\  r  r   	FieldDatar&   r   r   r  r    sc         Q Q Q. . .^ ^ ^ tT3kllIIIr   r  c                   :    e Zd ZdZd Zd Z eeddd          ZdS )TablezYA wrapper for vtkTable that makes it easier to access RowData array as
    VTKArrays
    c                 @    |                      t          j                  S )z5Returns the row data as a DataSetAttributes instance.)r   r   r%   r   s    r   
GetRowDatazTable.GetRowData  s    !!"2"6777r   c                 X    |t           j        k    pt                              | |          S r  )r   r%   r  r\  r  s     r   r\  zTable.HasAttributes  s&    '++Sz/G/Gd/S/SSr   Nz0This property returns the row data of the table.)r   r   r    r!   r  r\  r   RowDatar&   r   r   r  r    sQ         8 8 8T T T hz4/abbGGGr   r  c                   :    e Zd ZdZd Zd Z eeddd          ZdS )HyperTreeGridzdA wrapper for vtkHyperTreeGrid that makes it easier to access CellData
    arrays as VTKArrays.
    c                 @    |                      t          j                  S )z4Returns the cell data as DataSetAttributes instance.r   r   r#   r   s    r   GetCellDatazHyperTreeGrid.GetCellData      !!"2"7888r   c                 X    |t           j        k    pt                              | |          S r  )r   r#   r  r\  r  s     r   r\  zHyperTreeGrid.HasAttributes  s&    ',,T
0H0Ht0T0TTr   Nz:This property returns the cell data of the hypertree grid.)r   r   r    r!   r  r\  r   CellDatar&   r   r   r  r    sQ         9 9 9U U U xT41mnnHHHr   r  c                       e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Z eeddd          Z eeddd          Z eeddd          Z eeddd          ZdS )CompositeDataSetzA wrapper for vtkCompositeData and subclasses that makes it easier
    to access Point/Cell/Field data as VTKCompositeDataArrays. It also
    provides a Python type iterator.c                 t    t                               | |           d | _        d | _        d | _        d | _        d S r*   )r  r/   
_PointData	_CellData
_FieldData_Pointsr,   s     r   r/   zCompositeDataSet.__init__  s8    D),,,r   c                      t          |           S )z/Creates an iterator for the contained datasets.)ra  r   s    r   rj  zCompositeDataSet.__iter__  s    $T***r   c                 ^    d}| D ]}||                     |          z  }t          |          S )zReturns the total number of cells or points depending
        on the value of assoc which can be ArrayAssociation.POINT or
        ArrayAssociation.CELL.r   )GetNumberOfElementsr  )r-   r_  resultr9   s       r   r  z$CompositeDataSet.GetNumberOfElements  s>      	9 	9Gg11%888FF6{{r   c                 @    |                      t          j                  S )zReturns the total number of points of all datasets
        in the composite dataset. Note that this traverses the
        whole composite dataset every time and should not be
        called repeatedly for large composite datasets.)r  r   r"   r   s    r   r0  z"CompositeDataSet.GetNumberOfPoints  s    
 ''(8(>???r   c                 @    |                      t          j                  S )zReturns the total number of cells of all datasets
        in the composite dataset. Note that this traverses the
        whole composite dataset every time and should not be
        called repeatedly for large composite datasets.)r  r   r#   r   s    r   r1  z!CompositeDataSet.GetNumberOfCells  s    
 ''(8(=>>>r   c                 "    t          | |          S )z^Returns the attributes specified by the type as a
        CompositeDataSetAttributes instance.)rH  r  s     r   r   zCompositeDataSet.GetAttributes  s     *$555r   c                 @    | D ]}|                     |          s dS dS )zUReturns true if every leaves of current composite object support this attributes typeFT)r\  )r-   r   r9   s      r   r\  zCompositeDataSet.HasAttributes  s:     	 	G((.. uu tr   c                     | j         |                                  8|                     t          j                  }t	          j        |          | _         |                                  S z7Returns the point data as a DataSetAttributes instance.)r  r   r   r"   rV  rW  )r-   pdatas     r   GetPointDatazCompositeDataSet.GetPointData  Q    ?"doo&7&7&?&&'7'=>>E%k%00DO   r   c                     | j         |                                  8|                     t          j                  }t	          j        |          | _         |                                  S z6Returns the cell data as a DataSetAttributes instance.)r  r   r   r#   rV  rW  )r-   cdatas     r   r  zCompositeDataSet.GetCellData  sQ    >!T^^%5%5%=&&'7'<==E$[//DN~~r   c                     | j         |                                  8|                     t          j                  }t	          j        |          | _         |                                  S r  )r  r   r   r$   rV  rW  )r-   fdatas     r   r  zCompositeDataSet.GetFieldData  r  r   c                    | j         |                                  g }| D ]O}	 |j        }n# t          $ r d}Y nw xY w||                    t                     :|                    |           Pt          |          dk    st          d |D                       rt          }nt          ||           }t          j	        |          | _         |                                  S )z7Returns the points as a VTKCompositeDataArray instance.Nr   c                      g | ]}|t           u S r&   r   ).0r   s     r   
<listcomp>z.CompositeDataSet.GetPoints.<locals>.<listcomp>  s    $A$A$AQ)^$A$A$Ar   r  )
r  Pointsr   r   r   r   allr   rV  rW  )r-   ptsr   _ptscptss        r   	GetPointszCompositeDataSet.GetPoints  s    <4<<>>#9C 	% 	% 9DD%      DDD  <JJy))))JJt$$$$3xx1}}$A$AS$A$A$A B B} ,S$???";t,,DL||~~s   +::N4This property returns the point data of the dataset.1This property returns the cell data of a dataset.z2This property returns the field data of a dataset.z0This property returns the points of the dataset.)r   r   r    r!   r/   rj  r  r0  r1  r   r\  r  r  r  r  r   	PointDatar  r  r  r&   r   r   r  r    s       ( (  + + +  @ @ @? ? ?6 6 6
  ! ! !     ! ! !  * tT3ijjIxT41deeHtT3ghhIXit-_``FFFr   r  c                   \    e Zd ZdZd Zd Zd Z eeddd          Z eeddd          Z	dS )r   z[This is a python friendly wrapper of a vtkDataSet that defines
    a few useful properties.c                 @    |                      t          j                  S r  )r   r   r"   r   s    r   r  zDataSet.GetPointData)  s    !!"2"8999r   c                 @    |                      t          j                  S r  r  r   s    r   r  zDataSet.GetCellData-  r  r   c                 x    |t           j        k    p*|t           j        k    pt                              | |          S r  )r   r"   r#   r  r\  r  s     r   r\  zDataSet.HasAttributes1  s7    '--v9I9N1NvR\RjRjkoquRvRvvr   Nr  r  )
r   r   r    r!   r  r  r\  r   r  r  r&   r   r   r   r   %  sv           : : :9 9 9w w w tT3ijjIxT41deeHHHr   r   c                   :    e Zd ZdZd Zd Z eeedd          ZdS )PointSetz\This is a python friendly wrapper of a vtkPointSet that defines
    a few useful properties.c                     | j                                         sdS t          | j                                                                         |           }t          j        |_        |S )zcReturns the points as a VTKArray instance. Returns None if the
        dataset has implicit points.N)r+   r  r?   GetDatar   r"   r   )r-   r8   s     r   r  zPointSet.GetPoints;  s]     ~'')) 	4&N$$&&..00$8 8,2r   c                     ddl m} t          ||          r|}n.t          |          } |            }|                    |           | j                            |           dS )z:Given a VTKArray instance, sets the points of the dataset.r   )	vtkPointsN)vtkCommonCorer  r   rG   SetDatar+   	SetPoints)r-   r  r  ps       r   r  zPointSet.SetPointsE  sp    ------c9%% 	AA%c**C	AIIcNNN  #####r   Nz7This property returns the point coordinates of dataset.)r   r   r    r!   r  r  r   r  r&   r   r   r  r  8  sN             	$ 	$ 	$ XiD2kllFFFr   r  c                   4    e Zd ZdZd Z eeddd          ZdS )PolyDataz\This is a python friendly wrapper of a vtkPolyData that defines
    a few useful properties.c                     | j                                         sdS t          | j                                                                         |           S )z)Returns the polys as a VTKArray instance.N)r+   GetPolysr?   r  r   s    r   GetPolygonszPolyData.GetPolygonsV  N    ~&&(( 	4%N##%%--//7 7 	7r   Nz3This property returns the connectivity of polygons.)r   r   r    r!   r  r   Polygonsr&   r   r   r  r  R  s?           7 7 7 xT41fggHHHr   r  c                   ~    e Zd ZdZd Zd Zd Zd Z eeddd          Z	 eeddd          Z
 eeddd	          ZdS )
UnstructuredGridzdThis is a python friendly wrapper of a vtkUnstructuredGrid that defines
    a few useful properties.c                     | j                                         sdS t          | j                                         |           S )z.Returns the cell types as a VTKArray instance.N)r+   GetCellTypesArrayr?   r   s    r   GetCellTypeszUnstructuredGrid.GetCellTypesc  sB    ~//11 	4%N,,..6 6 	6r   c                     | j                                         sdS t          | j                                         |           S )z2Returns the cell locations as a VTKArray instance.N)r+   GetCellLocationsArrayr?   r   s    r   GetCellLocationsz!UnstructuredGrid.GetCellLocationsj  sB    ~3355 	4%N0022D: : 	:r   c                     | j                                         sdS t          | j                                                                         |           S )z)Returns the cells as a VTKArray instance.N)r+   GetCellsr?   r  r   s    r   r  zUnstructuredGrid.GetCellsq  r  r   c                    ddl m} ddlm} t	          |          }t	          ||          }t	          ||          } |            }|                    |                                |           | j                            |||           dS )zlGiven cellTypes, cellLocations, cells as VTKArrays,
        populates the unstructured grid data structures.r   )VTK_ID_TYPE)vtkCellArrayrB   N)util.vtkConstantsr  vtkCommonDataModelr  rG   SetCellsGetNumberOfTuplesr+   )r-   	cellTypescellLocationscellsr  r  cas          r   r  zUnstructuredGrid.SetCellsx  s     	433333555555'	22	+MkRRR#EkBBB\^^
I//115999	="=====r   Nz)This property returns the types of cells.z-This property returns the locations of cells.z0This property returns the connectivity of cells.)r   r   r    r!   r  r  r  r  r   	CellTypesCellLocationsCellsr&   r   r   r  r  _  s           6 6 6: : :7 7 7
> 
> 
> tT3^__IH-tT;jkkMHXtT+]^^EEEr   r  c                   V    e Zd ZdZd Zd Z eeddd          Z eeddd          ZdS )GraphzYThis is a python friendly wrapper of a vtkGraph that defines
    a few useful properties.c                 @    |                      t          j                  S )z8Returns the vertex data as a DataSetAttributes instance.)r   r   VERTEXr   s    r   GetVertexDatazGraph.GetVertexData  s    !!"2"9:::r   c                 @    |                      t          j                  S )z6Returns the edge data as a DataSetAttributes instance.)r   r   EDGEr   s    r   GetEdgeDatazGraph.GetEdgeData  r  r   Nz3This property returns the vertex data of the graph.z1This property returns the edge data of the graph.)	r   r   r    r!   r  r  r   
VertexDataEdgeDatar&   r   r   r  r    sd           ; ; ;9 9 9 -t5jkkJxT41deeHHHr   r  c                   V    e Zd ZdZd Zd Z eeddd          Z eeddd          ZdS )Moleculez\This is a python friendly wrapper of a vtkMolecule that defines
    a few useful properties.c                 *    |                                  S )z6Returns the atom data as a DataSetAttributes instance.)r  r   s    r   GetAtomDatazMolecule.GetAtomData  s    !!###r   c                 *    |                                  S )z6Returns the bond data as a DataSetAttributes instance.)r  r   s    r   GetBondDatazMolecule.GetBondData  s    !!!r   Nz4This property returns the atom data of the molecule.z4This property returns the bond data of the molecule.)	r   r   r    r!   r  r  r   AtomDataBondDatar&   r   r   r  r    sd           $ $ $" " " xT41ghhHxT41ghhHHHr   r  c                    |                      d          rt          |           S |                      d          rt          |           S |                      d          rt          |           S |                      d          rt	          |           S |                      d          rt          |           S |                      d          rt          |           S |                      d          rt          |           S |                      d          rt          |           S |                      d	          rt          |           S |                      d
          rt          |           S dS )z4Returns a Numpy friendly wrapper of a vtkDataObject.vtkPolyDatavtkUnstructuredGridvtkPointSet
vtkDataSetvtkCompositeDataSetvtkTablevtkMoleculevtkGraphvtkHyperTreeGridr   N)
IsAr  r  r  r   r  r  r  r  r  )r   s    r   r   r     sU   	vvm ||	%	&	& ###			 ||			 r{{	%	&	& ###	
		 	Ryy			 ||	
		 Ryy	"	#	# R   		 	  "~~ r   r*   )r@   N)3r!   r   ImportErrorRuntimeErrorr  __version__splitr   	itertoolsr   r:  r  r   utilr   r  r   r   rV  r   r   objectr(   r?   rG   rP   r]   r   r_   r   r=   r   r   r   r   r   r  rH  ra  rx  r  r  r  r  r   r  r  r  r  r  r   r&   r   r   <module>r     s  > >~&LLLL & & &
, % & & &&
 c%+11#66q9::       



 ) ) ) ) ) )             . . . . . . , , , , , ,   :       
- 
- 
- 
- 
-v 
- 
- 
-
: 
: 
: 
:   
 
 
  B5 B5 B5 B5 B5 B5 B5 B5H \! \! \! \! \!u} \! \! \!|-5 -5 -5 -5 -5D -5 -5 -5^ !""    6   #"2 LNN	55 55 55 55 55T 55 55 55n *++ZI ZI ZI ZI ZIF ZI ZI ,+ZIzN% N% N% N% N%( N% N% N%bQR QR QR QR QR QR QR QRf, , , , ,F , , ,B    !6   :m m m m m! m m m,c c c c cJ c c co o o o oJ o o oaa aa aa aa aaz aa aa aaFf f f f fj f f f&m m m m mw m m m4h h h h hx h h h'_ '_ '_ '_ '_x '_ '_ '_Rf f f f fJ f f fi i i i iz i i i    s   	 