a
    «ˆcÞ  ã                    @   s’  d Z ddlmZ ddlZejejejejejej	ej
ejejejejejejejejejejdœZejdejdejdejdejd	ej	d
ej
dejdejdejdejdejdejdejdejdejdiZejdejdejdejdejdej	dej
dejdejdejdejdejd ejd!ejd"ejd#ejd$iZd%d&„ Zd7d'd(„Zd)d*„ Zd+d,„ Zejd-k�rhG d.d/„ d/ƒZnG d0d/„ d/ƒZd1d2„ Zd3d4„ Zd5d6„ ZdS )8zJ
Utility functions to mimic the template support functions for vtkVariant
é    )ÚvtkCommonCoreN)ÚvoidÚcharzunsigned charzsigned charÚshortzunsigned shortÚintzunsigned intÚlongzunsigned longz	long longzunsigned long longÚfloatÚdoubleÚstringZvtkObjectBaseZ	vtkObjectÚ ZToCharZToUnsignedCharZToSignedCharZToShortZToUnsignedShortZToIntZToUnsignedIntZToLongZToUnsignedLongZ
ToLongLongZToUnsignedLongLongZToFloatZToDoubleZToStringZToVTKObjectÚIsValidZIsCharZIsUnsignedCharZIsSignedCharZIsShortZIsUnsignedShortZIsIntZIsUnsignedIntZIsLongZIsUnsignedLongZ
IsLongLongZIsUnsignedLongLongZIsFloatZIsDoubleZIsStringZIsVTKObjectc                 C   s"   t t|ƒtƒst| }t | |¡S )zñ
    Create a vtkVariant of the specified type, where the type is in the
    following format: 'int', 'unsigned int', etc. for numeric types,
    and 'string' for strings.  You can also use an
    integer VTK type constant for the type.
    )Ú
issubclassÚtyper   Ú_variant_type_mapr   Ú
vtkVariant©ÚvÚt© r   ú]/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/vtkmodules/util/vtkVariant.pyÚvtkVariantCreateC   s    r   c                 C   sZ   t  | ¡} |dkr|  ¡ }ntt|ƒtƒs2t| }t| t| ƒƒ rRt| t	| ƒƒ S dS dS )aA  
    Extract the specified value type from the vtkVariant, where the type is
    in the following format: 'int', 'unsigned int', etc. for numeric types,
    and 'string' for strings.  You can also use an
    integer VTK type constant for the type.  Set the type to 'None" to
    extract the value in its native type.
    N)
r   r   ÚGetTyper   r   r   r   ÚgetattrÚ_variant_check_mapÚ_variant_method_mapr   r   r   r   ÚvtkVariantExtractP   s    

r   c                 C   sB   t t|ƒtƒst| }t | |¡} |  ¡ r:t| t| ƒƒ S dS dS )z÷
    Cast the vtkVariant to the specified value type, where the type is
    in the following format: 'int', 'unsigned int', etc. for numeric types,
    and 'string' for strings.  You can also use an
    integer VTK type constant for the type.
    N)	r   r   r   r   r   r   r   r   r   r   r   r   r   ÚvtkVariantCaste   s    r   c                 C   sÄ   t  | ¡} t  |¡}|  ¡ }| ¡ }dd„ }||kr>|||ƒS |  ¡ }| ¡ }|rV|s`|||ƒS t| t| ƒƒ }t|t| ƒƒ }|t jkrº| ¡ }	| ¡ }
|	|
kr¬||	|
ƒS ||j|jƒS |||ƒS )a_  
    Compare variants by type first, and then by value.  When called from
    within a Python 2 interpreter, the return values are -1, 0, 1 like the
    cmp() method, for compatibility with the Python 2 list sort() method.
    This is in contrast with the Python 3 version of this method (and the
    VTK C++ version), which return true or false.
    c                 S   s    t jdkr| |k S t| |ƒS d S )Né   )ÚsysÚ
hexversionÚcmp)ÚxÚyr   r   r   Úvcmp†   s    
z'vtkVariantStrictWeakOrder.<locals>.vcmp)	r   r   r   r   r   r   Ú
VTK_OBJECTZGetClassNameZ__this__)Ús1Ús2Út1Út2r#   Úv1Úv2Úr1Úr2Zc1Úc2r   r   r   ÚvtkVariantStrictWeakOrderw   s(    





r.   r   c                   @   s    e Zd ZdZdd„ Zdd„ ZdS )ÚvtkVariantStrictWeakOrderKeyú2A key method (class, actually) for use with sort()c                 G   s
   || _ d S ©N©Úobj©Úselfr3   Úargsr   r   r   Ú__init__ª   s    ú%vtkVariantStrictWeakOrderKey.__init__c                 C   s   t | j|ƒS r1   ©r.   r3   ©r5   Úotherr   r   r   Ú__lt__¬   s    ú#vtkVariantStrictWeakOrderKey.__lt__N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r7   r<   r   r   r   r   r/   ¨   s   r/   c                   @   sH   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dS )r/   r0   c                 G   s
   || _ d S r1   r2   r4   r   r   r   r7   ±   s    r8   c                 C   s   t | j|ƒdk S ©Nr   r9   r:   r   r   r   r<   ³   s    r=   c                 C   s   t | j|ƒdkS rB   r9   r:   r   r   r   Ú__gt__µ   s    z#vtkVariantStrictWeakOrderKey.__gt__c                 C   s   t | j|ƒdkS rB   r9   r:   r   r   r   Ú__eq__·   s    z#vtkVariantStrictWeakOrderKey.__eq__c                 C   s   t | j|ƒdkS rB   r9   r:   r   r   r   Ú__le__¹   s    z#vtkVariantStrictWeakOrderKey.__le__c                 C   s   t | j|ƒdkS rB   r9   r:   r   r   r   Ú__ge__»   s    z#vtkVariantStrictWeakOrderKey.__ge__c                 C   s   t | j|ƒdkS rB   r9   r:   r   r   r   Ú__ne__½   s    z#vtkVariantStrictWeakOrderKey.__ne__N)r>   r?   r@   rA   r7   r<   rC   rD   rE   rF   rG   r   r   r   r   r/   ¯   s   c                 C   s€   t  | ¡} t  |¡}|  ¡ }| ¡ }||kr0dS |  ¡ }| ¡ }|sL|sLdS ||krXdS t| t| ƒƒ }t|t| ƒƒ }||kS )zC
    Check two variants for strict equality of type and value.
    FT)r   r   r   r   r   r   )r%   r&   r'   r(   r)   r*   r+   r,   r   r   r   ÚvtkVariantStrictEqualityÁ   s    

rH   c                 C   s   t  | ¡t  |¡k S )z!
    Return true if s1 < s2.
    ©r   r   ©r%   r&   r   r   r   ÚvtkVariantLessThanß   s    rK   c                 C   s   t  | ¡t  |¡kS )z"
    Return true if s1 == s2.
    rI   rJ   r   r   r   ÚvtkVariantEqualæ   s    rL   )N) rA   Z
vtkmodulesr   r   ZVTK_VOIDZVTK_CHARZVTK_UNSIGNED_CHARZVTK_SIGNED_CHARZ	VTK_SHORTZVTK_UNSIGNED_SHORTZVTK_INTZVTK_UNSIGNED_INTZVTK_LONGZVTK_UNSIGNED_LONGZVTK_LONG_LONGZVTK_UNSIGNED_LONG_LONGZ	VTK_FLOATZ
VTK_DOUBLEZ
VTK_STRINGr$   r   r   r   r   r   r   r.   r   r/   rH   rK   rL   r   r   r   r   Ú<module>   s€   ïðð
0