
    tjl                        d dl Z d dlZd dlZd dlZd dlZd dlmZmZmZm	Z	m
Z
 d dlmZ d dlmZ d dlmZ d dlmZ  ej$                  e      Zej+                  ej,                         d Zd Zd	 Z G d
 d      Zi ai adZd Zd Zd Z d Z!d Z"d Z#d Z$i Z%d Z&d Z'd Z(ddgfdZ)d Z*d Z+d Z,d Z-d Z.d Z/d Z0d  Z1d! Z2d" Z3ddgfd#Z4ddgfd$Z5ddgfd%Z6d& Z7d' Z8d( Z9d) Z:d* Z;d+ Z<d, Z=d- Z>d. Z?d/ Z@y)0    N)base64EncodehashDataArraygetJSArrayTypearrayTypesMappinggetReferenceId)vtkTypeUInt32Array)vtkCompositeDataGeometryFilter)vtkDataSetSurfaceFilter)vtkColorTransferFunctionc                 8   t        j                         5 }t        j                  |d      5 }|j	                  d| z  |t        j
                         d d d        |j                  d       |j                         cd d d        S # 1 sw Y   3xY w# 1 sw Y   y xY w)Nw)modezdata/%sr   )ioBytesIOzipfileZipFilewritestrZIP_DEFLATEDseekread)namedata	in_memoryzfs       T/DATA/.local/lib/python3.12/site-packages/vtkmodules/web/render_window_serializer.pyzipCompressionr      si    	__YS1RKK	D($0D0DE 2q~~	 
11 
s"   B%B(BB		BBc           	         t         | j                            }t        j                  |      }| j	                         }| j                         }||z  }|dk7  rt        j                  t        |             5 }t        t        j                  ||z  |j                  |                  }d d d        t        ||z        D cg c]  }||z  |dz   |z    c}S y # 1 sw Y   2xY wc c}w )N    )r   GetDataTypestructcalcsizeGetNumberOfValuesGetNumberOfComponentsr   r   
memoryviewlistunpackr   range)		dataTabledataTypeelementSizenbValuesnbComponentsnbytesstreamr   idxs	            r   dataTableToListr1   $   s     !6!6!89H//(+K**,H224L8#F3ZZ
9-.&h&96;;v;NOPD / X56
6 |#sQw,&>?6
 	

  /.
s   52C?C$C!c                 `    || z
  |dz
  z  }t        |      D cg c]
  }| ||z  z    c}S c c}w )Nr   r(   )startstopnumdeltais        r   linspacer9   8   s9    E\cAg&E',Sz2z!EAIz222s   +c                   @    e Zd Zd Zd Zd Zd
dZddZd Zd Z	d Z
y	)SynchronizationContextc                 .    i | _         i | _        d| _        y )NF)dataArrayCachelastDependenciesMappingingoreLastDependencies)selfs    r   __init__zSynchronizationContext.__init__D   s     ')$&+#    c                     || _         y N)r?   )r@   forces     r   setIgnoreLastDependenciesz0SynchronizationContext.setIgnoreLastDependenciesI   s
    &+#rB   c                 "    || j                   |<   y rD   )r=   )r@   pMd5r   s      r   cacheDataArrayz%SynchronizationContext.cacheDataArrayL   s    $(D!rB   c                    | j                   |   }|d   }|d   }||j                         k7  rt        j                  d       |j	                         dk(  r|j                         |j                         z  }t               }|j                  |       t        |      D ]9  }	|j                  |	|j                  |	      dk  rdn|j                  |	             ; t        |      }
nt        |      }
|r,|s|
j                         S t        ||
j                               S t        |s|
      S t        ||
j                                     S )NarraymTimez4 ***** ERROR: you asked for an old cache key! *****    r   )r=   GetMTimeloggerdebugr    GetNumberOfTuplesr$   r   SetNumberOfTuplesr(   SetValueGetValuer%   tobytesr   r   )r@   rH   binarycompressioncacheObjrK   	cacheTime	arraySizenewArrayr8   pBuffers              r   getCachedDataArrayz)SynchronizationContext.getCachedDataArrayO   s4   &&t,!W%	((LLOP"$//1E4O4O4QQI)+H&&y19%!!!5>>!+<q+@RennUVFWX & *G 'G
 # ! $D'//*;< &G
 	
,:4AR,S
 	
rB   c                    t        j                          |z
  }g }| j                  D ]F  }| j                  |   }|d   }|j                         }|dk(  s-|d   |k  s6|j                  |       H |D ]  }| j                  |=  y )NrK   r   ts)timer=   GetReferenceCountappend)r@   
timeWindow
cutOffTimeshasToDeletesharecordrK   counts           r   checkForArraysToReleasez.SynchronizationContext.checkForArraysToReleaseo   s    YY[:-
&&C((-F7OE++-EzfTlZ7##C( '  C##C(  rB   c                 \    g }|| j                   v r| j                  s| j                   |   }|S rD   )r>   r?   )r@   idstrlastDepss      r   getLastDependencyListz,SynchronizationContext.getLastDependencyList}   s2    D0009T9T33E:HrB   c                 "    || j                   |<   y rD   )r>   )r@   rl   depLists      r   setNewDependencyListz+SynchronizationContext.setNewDependencyList   s    .5$$U+rB   c                     | j                  |      }g }||D cg c]  }||vs|t        |      gg c}z  }||D cg c]  }||vs|t        |      gg c}z  }| j                  ||       |S c c}w c c}w rD   )rn   wrapIdrq   )r@   rl   newList	addMethodremoveMethodoldListcallsxs           r   buildDependencyCallListz.SynchronizationContext.buildDependencyCallList   s    ,,U3GPGqq?O9vayk*GPPwSw!!7BR<&)-wSS!!%1	 QSs   	A0A0	A5A5N)FF)   )__name__
__module____qualname__rA   rF   rI   r^   rj   rn   rq   rz    rB   r   r;   r;   C   s+    ,
,)
@)6rB   r;   c                     |t         | <   y rD   )SERIALIZERS)r   methods     r   registerInstanceSerializerr      s    KrB   c                     |t         | <   y rD   )JS_CLASS_MAPPING)	vtk_classjs_classs     r   registerJSClassr      s    "*YrB   c                 H    | j                         }|t        v r	t        |   S |S rD   )GetClassNamer   )vtk_objr   s     r   
class_namer      s*    $$&I$$	**rB   c                     t        |      }|t        v r	t        |   nd }|r || ||||      S t        j                  d| d|        y )Nz!!!No serializer for z	 with id )r   r   rP   error)parentinstance
instanceIdcontextdepthinstanceType
serializers          r   serializeInstancer      sR    h'L.:k.I\*tJ&(JGG
LL(i
|LMrB   c                     t        dt               t        dt               t        dt               t        dt               t        dt               t        dt               t        dt               t        dt               t        d	t               t        d
t               t	        dd       t	        dd       t	        d	d       t	        d
d       t        dt
               t        dt
               t	        dd       t        dt               t        dt               t        dt               t        dt               t        dt               t        dt               t        dt               t        dt               t        dt               t        dt               t        dt               t        dt               t        dt               t        dt               t	        dd       t        dt                t        dt                t        dt                t        dt                t        dt                t        d t                t        d!t                t        d"t                t        d#t                t        d$t                t        d%t                t        d&t                t        d't                t        d(t"               t        d)t"               t        d*t$               t        d+t$               t        d,t&               t        d-t&               t        d.t&               t        d/t(               t        d0t*               y )1NvtkActorvtkOpenGLActorvtkPVLODActor	vtkVolume	vtkMappervtkDataSetMappervtkPolyDataMappervtkImageDataMappervtkOpenGLPolyDataMappervtkCompositePolyDataMapper2vtkVolumeMapper vtkFixedPointVolumeRayCastMappervtkLookupTable'vtkPVDiscretizableColorTransferFunctionr   vtkPiecewiseFunction
vtkTexturevtkOpenGLTexturevtkPropertyvtkOpenGLPropertyvtkVolumePropertyvtkPolyDatavtkImageDatavtkUnstructuredGridvtkMultiBlockDataSetvtkStructuredPointsvtkRenderWindowvtkCocoaRenderWindowvtkXOpenGLRenderWindowvtkWin32OpenGLRenderWindowvtkEGLRenderWindowvtkOpenVRRenderWindowvtkOpenXRRenderWindowvtkGenericOpenGLRenderWindowvtkOSOpenGLRenderWindowvtkOpenGLRenderWindowvtkIOSRenderWindowvtkExternalOpenGLRenderWindowvtkOffscreenOpenGLRenderWindowvtkRenderervtkOpenGLRenderer	vtkCameravtkOpenGLCameravtkLight
vtkPVLightvtkOpenGLLightvtkCubeAxesActorvtkScalarBarActor)r   genericActorSerializergenericVolumeSerializergenericMapperSerializerr   genericVolumeMapperSerializerlookupTableSerializer2,discretizableColorTransferFunctionSerializercolorTransferFunctionSerializerpwfSerializertextureSerializerpropertySerializervolumePropertySerializerpolydataSerializerimagedataSerializermergeToPolydataSerializerrenderWindowSerializerrendererSerializercameraSerializerlightSerializercubeAxesSerializerscalarBarActorSerializerr   rB   r   initializeSerializersr      s   z+AB/1GH0FG {,CD {,CD13JK24KL35LM8:QR<>UV'5&4-{;1;?02OPAC`a68IJ /1GH13_ "$C 5}E |->?13DE }.@A24FG 24LM }.@A~/BC46OP57PQ46IJ)>: 02HI57MN79OP;=ST35KL68NO68NO=?UV8:PQ68NO35KL>@VW?AWX }.@A24FG {,<=02BC z?;|_=/A 13EF24LMrB   c                 4    d}t        |       D ]  }|dz  }	 |S )N z  r3   )r   padding_s      r   padr     s#    G5\4 NrB   c                     d| z  S )Nzinstance:${%s}r   )idStrs    r   rs   rs   '  s    e##rB   c                     t        |       }d }|t        v r	t        |   }|r|d   | j                         k(  r|d   S t        |       | j                         d}|t        |<   |d   S )Nmtimerg   )rg   r   )r   dataArrayShaMappingrO   r   )rK   objIdrh   s      r   digestr   0  sn    5!EF##$U+&/U^^%55e}"5)ENN4DEF!'%=rB   c                 t    | j                  |      }i }|d   |d<   |d   |d<   | j                  |      |d<   |S )Nr   minr   max	component)GetRangeGetComponentName)rK   r   r	compRanges       r   getRangeInfor   C  sL    y!AItIetIe"33I>IkrB   c                 N   | sy t        |       }|j                  || | j                         t        j                         d       i }||d<   d|d<   | j	                         |d<   t        |       |d<   | j                         |d<   | j                         | j                         z  |d<   g |d	<   |d   d
kD  rQt        |d         D ]   }|d	   j                  t        | |             " |d	   j                  t        | d             |S |d	   j                  t        | d             |S )N)rK   rL   r`   hashvtkDataArrayvtkClassr   r*   numberOfComponentssizerangesr   rN   r   )r   rI   rO   ra   GetNamer   r$   rR   r(   rc   r   )rK   r   rH   rootr8   s        r   getArrayDescriptionr   O  s)   %=D(8		L DDL%D==?DL%e,D!&!<!<!>D	..053J3J3LLDLDN !A%t012AN!!,ua"89 3Xl5"56 K 	Xl5!45KrB   NormalsTCoordsc                    t               }d|v }|s|rk|j                  d      rY|}|j                         }|j                         }	|	dk(  r|j	                         n|j                         }
|j                         }|rT|dv rP|j                         j                  |
      }||j                         j                         }|j                  |       |rT|dv rP|j                         j                  |
      }||j                         j                         }|j                  |       |rT|dk(  rO|j                         j                         }||j                         j                         }|j                  |       |r\|j                  d      rK|j                         j                         r-|j                  |j                         j                                |j                  |D cg c]&  } t        |j                         d|z   d	              ( c}       d
|j                         fd|j                         ffD ]  \  }}t        |j                               D ]n  }|j                  |      }|s||v st!        ||      }|s*||d<   |j#                  |      }|dk\  rd|j%                  |      z   nd|d<   | j'                  |       p  y c c}w )N*r   r   )r      )      r   r   Getc                       y rD   r   r   rB   r   <lambda>z'extractRequiredFields.<locals>.<lambda>  s    PTrB   	pointDatacellDatalocationsetaddArrayregistration)r  IsAGetScalarVisibilityGetArrayAccessModeGetArrayName
GetArrayIdGetScalarModeGetPointDataGetArray
GetScalarsaddGetCellDataupdategetattrr(   GetNumberOfArraysr   IsArrayAnAttributeGetAttributeTypeAsStringrc   )extractedFieldsr   datasetr   requestedFieldsarrays_to_export
export_allmapperscalarVisibilityarrayAccessModecolorArrayName
scalarModearray_to_exportrequestedFieldr  
field_dataarray_indexrK   	arrayMeta	attributes                       r   extractRequiredFieldsr+  m  s    u'Jfjj-F%99;$779O)8A)=##%6CTCTCV   --/JJ&$8")"6"6"8"A"A."Q"*&-&:&:&<&G&G&IO $$_5J&$8")"5"5"7"@"@"P"*&-&9&9&;&F&F&HO $$_5J!O")"6"6"8"C"C"E"*&-&9&9&;&F&F&HO $$_5fjj.73G3G3I3T3T3V  !5!5!7!B!B!DE '6&5N V,,.0FUW&5	
 
g**,-	W((*+!* !!=!=!?@K''4EU&66/w?	,4Ij) * = =k JI %> 
 C CI NN' n-
 $**95 A	!s   -+Kc                    |j                         }d }d }g }g }	|rd }
t        |d      st        j                  d       n|j	                         }
|
rMt        |
      }t        ||
|||dz         }|r.|	j                  |       |j                  dt        |      gg       d }t        |d      r|j                         }nt        j                  d       |rMt        |      }t        |||||dz         }|r.|	j                  |       |j                  dt        |      gg       d }t        |d      r|j                         }nt        j                  d	       |rMt        |      }t        |||||dz         }|r.|	j                  |       |j                  d
t        |      gg       |dk(  s|r|rt        |       |t        |      ||j                         |j                         |j                         |j                         |j!                         |j#                         |j%                         |j'                         d	||	dS y )N	GetMapper+This actor does not have a GetMapper methodr   	setMapperGetProperty-This actor does not have a GetProperty methodsetProperty
GetTexturez,This actor does not have a GetTexture method
addTexturer   )	
visibilitypickabledragable	useBoundsoriginpositionscaleforceOpaqueforceTranslucentr   idtype
propertiesrx   dependencies)GetVisibilityhasattrrP   rQ   r-  r   r   rc   rs   r0  r3  r   GetPickableGetDragableGetUseBounds	GetOriginGetPositionGetScaleGetForceOpaqueGetForceTranslucent)r   actoractorIdr   r   actorVisibilitymapperInstancepropertyInstancerx   rB  r   mapperIdproppropIdtexture	textureIdtextureInstances                    r   r   r     s<    ))+ONELuk*LLFG__&F%f-H.vx%!)N ##N3kF8,<+=>?5-($$&DLLHI#D)F0tVWeai   ##$45mfVn-=>? 5,'&&(GLLGH&w/I/w	7EAIO ##O4lVI->,?@A!3C$V,u% .!--/!--/"//1//+!--/)$335$)$=$=$? ('
 	
, rB   c                 F   |j                         }d }d }g }g }	|rd }
t        |d      st        j                  d       n|j	                         }
|
rMt        |
      }t        ||
|||dz         }|r.|	j                  |       |j                  dt        |      gg       d }t        |d      r|j                         }nt        j                  d       |rMt        |      }t        |||||dz         }|r.|	j                  |       |j                  dt        |      gg       |dk(  s|ry|rwt        |       |t        |      ||j                         |j                         |j                         |j                         |j                         |j!                         d	||	d
S y )Nr-  r.  r   r/  r0  r1  r2  r   )r5  r6  r7  r8  r9  r:  r;  r>  )rC  rD  rP   rQ   r-  r   r   rc   rs   r0  r   rE  rF  rG  rH  rI  rJ  )r   rM  rN  r   r   rO  rP  rQ  rx   rB  r   rR  rS  rT  s                 r   r   r     s    ))+ONELuk*LLFG__&F%f-H.vx%!)N ##N3kF8,<+=>?5-($$&DLLHI#D)F0tVWeai   ##$45mfVn-=>?!3C$V,u% .!--/!--/"//1//+!--/)
 (!
 	
& rB   c                    d }d }g }g }t        |d      r|j                         }nt        j                  d       |rGd|z  }	t	        |||	||dz         }|r.|j                  |       |j                  dt        |	      gg       |r@t        |       |d|j                         |j                         |j                         d||dS y )	NGetInputz*This texture does not have GetInput methodz
%s-texturer   setInputDatar   )interpolaterepeat	edgeClampr>  )rD  rZ  rP   rQ   r   rc   rs   r   GetInterpolate	GetRepeatGetEdgeClamp)
r   rU  rV  r   r   
dataObjectdataObjectInstancerx   rB  dataObjectIds
             r   r   r   F  s     JELw
#%%'
AB#i/.Zw	
  23LL.6,+?*@AB$V, &557!++-$113
 (
 	
 rB   c                    d }d }d }g }g }	t        |d      r1|j                         j                          |j                  dd      }nt        j                  d       |r|j                  d      r;t               }
|
j                  |       |
j                          |
j                         }d|z  }t        |||||dz         }|r.|	j                  |       |j                  dt        |      gg       d }t        |d      r|j                         }nt        j                  d	       |rMt        |      }t        |||||dz         }|r.|	j                  |       |j                  d
t        |      gg       |r|j                         dk(  r|j!                         n|j#                         }t        |       |t%        |      |j'                         |j)                         |j                         |j+                         |j-                         rdnd|j/                         ||j1                         |j3                         |j5                         rdndd
||	dS y )NGetInputDataObjectr   3This mapper does not have GetInputDataObject method
vtkDataSet
%s-datasetr   r[  GetLookupTablez/This mapper does not have GetLookupTable methodsetLookupTable)
resolveCoincidentTopology
renderTimer"  scalarRangeuseLookupTableScalarRanger!  colorByArrayName	colorModer$  interpolateScalarsBeforeMappingr>  )rD  GetInputAlgorithmUpdaterf  rP   rQ   r  r
   SetInputData	GetOutputr   rc   rs   rj  r   r  r  r  r   GetResolveCoincidentTopologyGetRenderTimeGetScalarRangeGetUseLookupTableScalarRanger  GetColorModer  "GetInterpolateScalarsBeforeMapping)r   r   rR  r   r   rb  rc  lookupTableInstancerx   rB  algrd  lookupTablelookupTableIdr#  s                  r   r   r   p  sQ    JELv+,  "))+..q!4
JK>>,')+CZ(JJLJ#h..Jguqy
  23LL.6,+?*@ABKv'(++-FG&{3/K
  34LL!F=$9#:;  ((*a/ !""$ 	 %V,v&-3-P-P-R$224#)#<#<#>%446668 ./$*$>$>$@$2#002$224<<> 45  (+
 	
0 rB   c                    d }d }d }g }g }	t        |d      r1|j                         j                          |j                  dd      }nt        j                  d       |rGd|z  }
t        |||
||dz         }|r.|	j                  |       |j                  dt        |
      gg       |rXt        |       |t        |      |j                         |j                         |j                         |j                         d||	dS y )	Nrf  r   rg  ri  r   r[  )sampleDistanceimageSampleDistanceautoAdjustSampleDistances	blendModer>  )rD  rs  rt  rf  rP   rQ   r   rc   rs   r   r   GetSampleDistanceGetImageSampleDistanceGetAutoAdjustSampleDistancesGetBlendMode)r   r   rR  r   r   rb  rc  r}  rx   rB  rd  s              r   r   r     s    JELv+,  "))+..q!4
JK#h..Jguqy
  23LL.6,+?*@AB$V,v& #)":":"<'-'D'D'F-3-P-P-R#002
 (!
 	
& rB   c                 f   |j                         }ddg}t        |d      r	 |j                  |       |j	                         }|j                         }	t        |       |t        |      |j                         ||||j                         |j                         |j                         |j                         rdnd|j                         rdnd|j                         |j                         |j!                         |j#                         |j%                         ddS # t        $ r
}Y d }~d }~ww xY w)Ng      ?r   GetHueRangeTF)numberOfColors
valueRangehueRangesaturationRangenanColorbelowRangeColoraboveRangeColoruseAboveRangeColoruseBelowRangeColoralpha
vectorSizevectorComponent
vectorModeindexedLookupr   r?  r@  rA  )r   rD  r  	ExceptionGetSaturationRangeGetAlphaRanger   r   GetNumberOfColorsGetNanColorGetBelowRangeColorGetAboveRangeColorGetUseAboveRangeColorGetUseBelowRangeColorGetAlphaGetVectorSizeGetVectorComponentGetVectorModeGetIndexedLookup)
r   r  r  r   r   lookupTableRangelookupTableHueRangeinstlutSatRangelutAlphaRanges
             r   lookupTableSerializerr    s/    #++-({M*	##$78 002K--/M !(;');;=*+*#//1*==?*==?002 #'002 #' ))+%335*==?%335(99;'
	   		s   D 	D0+D0c           	         | j                         }t        |      }|rkt               }| j                         }t	        |dt        |      i}t        ||      D ],  \  }} |j                  |g|d d D cg c]  }|dz  	 c}  . |S y c c}w )Nr6   r      )GetTabler1   r   GetTableRanger9   lenzipAddRGBPoint)r  r)   tablectf
tableRangepointsry   rgbas           r   "lookupTableToColorTransferFunctionr  &  s    $$&II&E&( ..0
:63u:665)GAtCOOA<$r( ;(QS( ;< * 
	 !<s   3B
c                 <    t        |      }|rt        | ||||      S y rD   )r  r   )r   r  r  r   r   r  s         r   r   r   5  s,    
,[
9C
.C
 	
 rB   c                 @   t        |d      r|j                         nd}t        |d      r|j                         ng d}|dk(  rt        |d      r|j                         }t	        |       |t        |      i d|d|d	|j                         d
|j                         d|j                         d|j                         d|j                         d|j                         d|j                         d|j                         d|j                         d|j                         d|j                         rdndd|j!                         rdndd|j#                         rdndd|j%                         d|j'                         d|j)                         rdndidS )NGetRepresentationr   GetDiffuseColor)r   r   r   r   GetColorrepresentationdiffuseColorcolorambientColorspecularColor	edgeColorambientdiffusespecularspecularPoweropacityinterpolationedgeVisibilityr   backfaceCullingfrontfaceCulling	pointSize	lineWidthlightingr  )rD  r  r  r  r   r   GetAmbientColorGetSpecularColorGetEdgeColor
GetAmbient
GetDiffuseGetSpecularGetSpecularPower
GetOpacityGetInterpolationGetEdgeVisibilityGetBackfaceCullingGetFrontfaceCullingGetPointSizeGetLineWidthGetLighting)r   propObj	propObjIdr   r   r  
colorToUses          r   r   r   B  s   '.w8K'L!!#RS  &-W6G%H!i  ww
;%%'
 !(7#
n
J
 W%%'
 G335	

 W557
 --/
 w))+
 w))+
 ++-
 W557
 w))+
 W557
 7#<#<#>aA
 G$>$>$@qa
 W%@%@%B
  --/!
" --/#
$ W002%
	 rB   c                    g }g }|j                         }|rNt        |      }t        |||||dz         }	|	r/|j                  |	       |j                  ddt	        |      gg       |j                         }
|
rNt        |
      }t        ||
|||dz         }|r/|j                  |       |j                  ddt	        |      gg       t        |       |t        |      |j                         |j                         |j                         |j                         |j                         |j                         |j                         d||dS )Nr   setRGBTransferFunctionr   setScalarOpacity)independentComponentsinterpolationTypeshader  r  r  r  r>  )GetRGBTransferFunctionr   r   rc   rs   GetScalarOpacityr   GetIndependentComponentsGetInterpolationTypeGetShader  r  r  r  )r   r  r  r   r   rx   rB  lutr  r}  pwfpwfIdpwfInstances                r   r   r   f  sW   EL 
(
(
*C
&s+/S-%!)
  34LL2Q}8M4NOP 
"
"
$C
s#'S%%!)
 ,LL,q&-.@AB !(7#%,%E%E%G!(!=!=!?%%'))+))+++-$557

 $! rB   c           	      N   t        |d      r7t        d      D cg c]"  }|j                         j                  d|      $ }}ng d}g }t	        || ||d       t        |       |t        |      |j                         |j                         |j                         ||ddS c c}w )NGetDirectionMatrix	   r   )	r   r   r   r   r   r   r   r   r   r   )spacingr9  
dimensions	directionfieldsr  )
rD  r(   r  
GetElementr+  r   r   
GetSpacingrH  GetDimensions)	r   r  	datasetIdr   r   requested_fieldsr8   r  r  s	            r   r   r     s    w,-LQRSHUHqW//1<<QBH	U/	 F&&'7C@ !(7#))+'')!//1"
	  Vs   'B"c                    |rE|j                         r4i }t        |j                         j                         |      }d|d<   ||d<   |j                         rd|j                         j                         j	                         dkD  r5t        |j                         j                         |      }||d<   d|d   d<   |j                         rd|j                         j                         j	                         dkD  r5t        |j                         j                         |      }	|	|d<   d|d   d<   |j                         rd|j                         j                         j	                         dkD  r5t        |j                         j                         |      }
|
|d<   d|d   d<   |j                         rd|j                         j                         j	                         dkD  r5t        |j                         j                         |      }||d	<   d|d	   d<   g |d
<   t        |d
   | |||       t        |       |t        |      |dS t        j                  d       y )N	vtkPointsr   r  r   vertsvtkCellArraylinespolysstripsr  r  zThis dataset has no points!)	GetPointsr   GetDataGetVertsrR   GetLinesGetPolys	GetStripsr+  r   r   rP   rQ   )r   r  r  r   r   r  rA  r  _verts_lines_polys_stripss               r   r   r     s?   7$$&
 %W%6%6%8%@%@%BGL(z%
8 '"2"2"4"<"<">"P"P"RUV"V()9)9);)C)C)EwOF"(Jw.<Jw
+ '"2"2"4"<"<">"P"P"RUV"V()9)9);)C)C)EwOF"(Jw.<Jw
+ '"2"2"4"<"<">"P"P"RUV"V()9)9);)C)C)EwOF"(Jw.<Jw
+ !!#++-??AAE)'*;*;*=*E*E*GQG#*Jx /=Jx ,  "
8j2FGWN^_ %V,w'$	
 	
 LL./rB   c                    d }|j                  d      r<t               }|j                  |       |j                          |j	                         }na|j                  d      r<t               }|j                  |       |j                          |j	                         }nt        j                         }t        | |||||      S )NvtkCompositeDataSetr   )	r  r	   ru  rt  rv  r
   r   rZ  r   )r   rb  rd  r   r   r  r  gfs           r   r   r     s    G~~+,+-

#
		,,.	-	.$&

#
		,,.//#fg|WeM]^^rB   c                    g }t        |j                               D ])  }g d}|j                  ||       |j                  |       + t	        |       |t        |      |j                         rdnd|j                         |j                         rdnd|j                         rdnd|j                         |j                         |j                         |j                         |j                         |d
dS )N)r   r   r   r   r   r   r   r   )
clamping
colorSpacehSVWrapallowDuplicateScalarsr  r  r  r  r  nodesr  )r(   GetSizeGetNodeValuerc   r   r   GetClampingGetColorSpace
GetHSVWrapGetAllowDuplicateScalarsr  r  r  r  r  r   r   r   r   r   r  r8   nodes           r   r   r     s    E8##%&!a&T	 ' !(8$%113"002$//1qq +3*K*K*MQST&&('::<"002"002%668
	 rB   c                 |    t        | ||||      }|j                         |d   d<   |j                         |d   d<   |S )NrA  
discretizenumberOfValues)r   GetDiscretizer#   )r   r   r   r   r   r  s         r   r   r     sJ    
)&(E7E
RC&.&<&<&>Cl#*2*D*D*FC&'JrB   c                 2   g }t        |j                               D ])  }g d}|j                  ||       |j                  |       + t	        |       |t        |      t        |j                               |j                         |j                         |ddS )N)r   r   r   r   )r(   r  r  r  r  )
r(   r  r  rc   r   r   r&   r   r  r  r   s           r   r   r   '  s    E8##%&a&T	 ' !(8$(++-. ,,.%-%F%F%H	
	
 
rB   c                    g d}|j                         r|j                         |d<   |j                         r|j                         |d<   |j	                         r|j                         |d<   t        |       |di d|j                         d|j                         d|j                         d	|j                         d
|j                         d|j                         d|j                         d|j                         d|j                         d|j!                         ddddd|dddddddddddddd ddd!t#        t        |j%                                     gggg d"S )#a  
    Possible add-on properties for vtk.js:
        gridLines: True,
        axisLabels: None,
        axisTitlePixelOffset: 35.0,
        axisTextStyle: {
            fontColor: 'white',
            fontStyle: 'normal',
            fontSize: 18,
            fontFamily: 'serif',
        },
        tickLabelPixelOffset: 12.0,
        tickTextStyle: {
            fontColor: 'white',
            fontStyle: 'normal',
            fontSize: 14,
            fontFamily: 'serif',
        },
    )r   r   r   r   r   r   r   r5  r6  r7  r8  r9  r:  r;  r<  r=  
dataBoundsfaceVisibilityAngle   	gridLinesT
axisLabelsaxisTitlePixelOffsetg     A@axisTextStylewhitenormal   serif	fontColor	fontStylefontSize
fontFamilytickLabelPixelOffsetg      (@tickTextStyle   	setCamerar>  )GetXAxisLabelVisibility	GetXTitleGetYAxisLabelVisibility	GetYTitleGetZAxisLabelVisibility	GetZTitler   rC  rE  rF  rG  rH  rI  rJ  rK  rL  	GetBoundsrs   	GetCamera)r   rM  rN  r   r   r,  s         r   r   r   >  s   ( J$$&)
1$$&)
1$$&)
1 !(" 
%--/ 
 ))+ 
 ))+	 

 ++- 
 eoo' 
 ))+ 
 U^^% 
 5//1 
  9 9 ; 
 %//+ 
 "1 
  ! 
" *# 
$ #D% 
& $%%	' 
2 #D3 
4 $%%	5 
B u7H(I!J KLMM' 'rB   c                    g }g }|j                         }|sy t        |      }t        |||||dz         }	|	sy |j                  |	       |j                  dt	        |      gg       d }
t        |d      r|j                         }
ndt        j                  d       |
rMt        |
      }t        ||
|||dz         }|r.|j                  |       |j                  dt	        |      gg       |j                         }|j                         }|j                         }t        |       |d|j                         |j                         |j                         |j                         d|dd	g||gd
|j!                         j#                         ddddd|j!                         j#                         dddd|j%                         |j'                         |j)                         d||dS )Nr   setScalarsToColorsr0  z6This scalarBarActor does not have a GetProperty methodr2  r   Tg)\(?gq=
ףpg      B@r0  r1  r2  r3  g      ,@r:  )r5  r6  r7  r8  	automated	axisLabelboxPositionboxSizer-  r.  r8  r9  drawNanAnnotationdrawBelowRangeSwatchdrawAboveRangeSwatchr>  )rj  r   r   rc   rs   rD  r0  rP   rQ   GetTitleGetWidth	GetHeightrC  rE  rF  rG  GetTitleTextPropertyr  GetDrawNanAnnotationGetDrawBelowRangeSwatchGetDrawAboveRangeSwatch)r   rM  rN  r   r   rB  rx   r  lutIdlutInstancerS  rT  rQ  rG  widthheights                   r   r   r     s   LE



 C3E#E3w	JK$	LL&89Dum$  "MN#D)F0tVWeai   ##$45mfVn-=>? INNE__F !(#  --/))+))+++- " !%=v$("779BBD%%	 %)"779BBD%%	 "'!;!;!=$)$A$A$C$)$A$A$CE#
H $S* *rB   c                 P   g }g }g }g }|j                         }	t        |	      }
t        ||	|
||dz         }|r.|j                  |       |j                  dt	        |
      gg       |j                         }t        |j                               D ]U  }|j                  |      }t        |      }t        |||||dz         }|s4|j                  |       |j                  |       W ||j                  d|z  |dd      z  }|j                         }t        |j                               D ]U  }|j                  |      }t        |      }t        |||||dz         }|s4|j                  |       |j                  |       W ||j                  d|z  |dd      z  }t        |      dkD  rt        |       |t        |      |j                         |j                         |j                         |j!                         |j#                         |j%                         |j'                         |j)                         |j+                         |j-                         |j/                         |j1                         |j3                         |j5                         |j7                         d	||d
S y )Nr   setActiveCameraz%s-propsaddViewPropremoveViewPropz	%s-lightsaddLightremoveLight)
backgroundbackground2viewporttwoSidedLightinglightFollowCameralayerpreserveColorBufferpreserveDepthBuffernearClippingPlaneToleranceclippingRangeExpansion
useShadowsuseDepthPeelingocclusionRatiomaximumNumberOfPeelsinteractive)r   r?  r@  rA  rB  rx   )GetActiveCamerar   r   rc   rs   GetViewPropsr(   GetNumberOfItemsGetItemAsObjectrz   	GetLightsr  r   GetBackgroundGetBackground2GetViewportGetTwoSidedLightingGetLightFollowCameraGetLayerGetPreserveColorBufferGetPreserveDepthBufferGetNearClippingPlaneToleranceGetClippingRangeExpansionGetUseShadowsGetUseDepthPeelingGetOcclusionRatioGetMaximumNumberOfPeelsGetInteractive)r   r   r   r   r   rB  viewPropIds	lightsIdsrx   cameracameraIdcameraInstanceviewPropCollectionrpIdxviewProp
viewPropIdviewPropInstancelightCollectionlightIdxlightlightIdlightInstances                         r   r   r     s   LKIE %%'Ff%H&x7ETUIVNN+'&*:);<= "..0)::<=%55e<#H-
,h
GUQY
  01z* > 
W,,UK8H E
 ((*O/::<=//9 ')(E7GUUVYW.W% > 
W,,eY
M E <1$V,x(&446'668$002 %-$@$@$B%-%B%B%D!**,'/'F'F'H'/'F'F'H.6.T.T.V*2*L*L*N&446#+#>#>#@"*"<"<">(0(H(H(J'668), )7
 	
< rB   c                     t        |       |t        |      |j                         |j                         |j	                         |j                         ddS )N)
focalPointr:  viewUpclippingRanger  )r   r   GetFocalPointrI  	GetViewUpGetClippingRanger   r   r   r   r   s        r   r   r   )  sT     (8$"002 ,,.((*%668	
	
 
rB   c                     | dk(  ry| dk(  ryy)z
    #define VTK_LIGHT_TYPE_HEADLIGHT    1
    #define VTK_LIGHT_TYPE_CAMERA_LIGHT 2
    #define VTK_LIGHT_TYPE_SCENE_LIGHT  3

    'HeadLight';
    'SceneLight';
    'CameraLight'
    r   	HeadLightr   CameraLight
SceneLightr   )values    r   lightTypeToStringr  :  s     z	!rB   c                    t        |       |t        |      |j                         |j                         |j	                         |j                         |j                         |j                         |j                         |j                         |j                         t        |j                               |j                         ddS )N)switch	intensityr  r:  r  
positionalexponent	coneAngleattenuationValues	lightTypeshadowAttenuationr  )r   r   	GetSwitchGetIntensityr  rI  r  GetPositionalGetExponentGetConeAngleGetAttenuationValuesr  GetLightTypeGetShadowAttenuationr  s        r   r   r   L  s     (8$ ((*!..0--/ ,,."002"002 ,,.!..0!)!>!>!@*8+@+@+BC!)!>!>!@
	 rB   c           	         g }g }|j                         }t        |j                               D ]U  }|j                  |      }	t	        |	      }
t        ||	|
||dz         }|s4|j                  |       |j                  |
       W |j                  ||dd      }t	        |       |t        |      d|j                         i|||j                         dS )Nr   addRendererremoveRenderernumberOfLayers)r   r?  r@  rA  rB  rx   r   )GetRenderersr(   ro  rp  r   r   rc   rz   r   GetNumberOfLayersrO   )r   r   r   r   r   rB  rendererIdsrendererCollectionrIdxrenderer
rendererIdrendererInstancerx   s                r   r   r   f  s    LK!..0(99;<%55d;#H-
,h
GUQY
  01z* = ++{M+;E
 !(8$')C)C)EF$""$ rB   )Ar   loggingr!   ra   r   vtkmodules.webr   r   r   r   r   vtkmodules.vtkCommonCorer   vtkmodules.vtkFiltersGeometryr	   r
   vtkmodules.vtkRenderingCorer   	getLoggerr|   rP   setLevelDEBUGr   r1   r9   r;   r   r   r   r   r   r   r   r   r   rs   r   r   r   r   r+  r   r   r   r   r   r  r  r   r   r   r   r   r   r   r   r   r   r   r   r   r  r   r   r   rB   r   <module>r     sx   	      8 H A @			8	$   (3K Kd  
+	UNz$  &> AJ9?U<6FOj<B$TOj-d)^"H-d YbclWm 6 XabkVl 0l clmvaw _,@.CNLbMf"$4rB   