Ë
    ¯·g”$  ã                   óx   — d dl mZ d dlmZ d dlmZ d dlmZ d dlmZ d dlm	Z	  G d„ de
«      Z G d	„ d
e	«      Zy)é    )ÚvtkInformation)ÚvtkDataObject)ÚvtkAlgorithm)ÚvtkDemandDrivenPipeline)Ú vtkStreamingDemandDrivenPipeline)ÚvtkPythonAlgorithmc                   óX   — e Zd ZdZ	 	 dd„Zd„ Zd„ Zd„ Zd„ Zd„ Z	d„ Z
d	„ Zd
„ Zd„ Zd„ Zy)ÚVTKAlgorithma  This is a superclass which can be derived to implement
    Python classes that work with vtkPythonAlgorithm. It implements
    Initialize(), ProcessRequest(), FillInputPortInformation() and
    FillOutputPortInformation().

    Initialize() sets the input and output ports based on data
    members.

    ProcessRequest() calls RequestXXX() methods to implement
    various pipeline passes.

    FillInputPortInformation() and FillOutputPortInformation() set
    the input and output types based on data members.
    c                 ó<   — || _         || _        || _        || _        y)z’Sets up default NumberOfInputPorts, NumberOfOutputPorts,
        InputType and OutputType that are used by various initialization
        methods.N)ÚNumberOfInputPortsÚNumberOfOutputPortsÚ	InputTypeÚ
OutputType©ÚselfÚnInputPortsÚ	inputTypeÚnOutputPortsÚ
outputTypes        ú<lib/python3.12/site-packages/vtkmodules/util/vtkAlgorithm.pyÚ__init__zVTKAlgorithm.__init__   s"   € ð #.ˆÔØ#/ˆÔ Ø"ˆŒØ$ˆ�ó    c                 óp   — |j                  | j                  «       |j                  | j                  «       y)zeSets up number of input and output ports based on
        NumberOfInputPorts and NumberOfOutputPorts.N)ÚSetNumberOfInputPortsr   ÚSetNumberOfOutputPortsr   ©r   Úvtkselfs     r   Ú
InitializezVTKAlgorithm.Initialize#   s,   € ð 	×%Ñ% d×&=Ñ&=Ô>Ø×&Ñ& t×'?Ñ'?Õ@r   c                 ól   — ||   j                  |«      j                  t        j                  «       «      S ©zsConvenience method that returns an input data object
        given a vector of information objects and two indices.©ÚGetInformationObjectÚGetr   ÚDATA_OBJECT©r   ÚinInfoÚiÚjs       r   ÚGetInputDatazVTKAlgorithm.GetInputData*   ó-   € ð �a‰y×-Ñ-¨aÓ0×4Ñ4´]×5NÑ5NÓ5PÓQÐQr   c                 óf   — |j                  |«      j                  t        j                  «       «      S ©zgConvenience method that returns an output data object
        given an information object and an index.r!   ©r   ÚoutInfor'   s      r   ÚGetOutputDatazVTKAlgorithm.GetOutputData0   ó)   € ð ×+Ñ+¨AÓ.×2Ñ2´=×3LÑ3LÓ3NÓOÐOr   c                  ó   — y©z³Overwritten by subclass to manage data object creation.
        There is not need to overwrite this class if the output can
        be created based on the OutputType data member.é   © ©r   r   Úrequestr&   r.   s        r   ÚRequestDataObjectzVTKAlgorithm.RequestDataObject5   ó   € ð r   c                  ó   — y©zLOverwritten by subclass to provide meta-data to downstream
        pipeline.r3   r4   r5   s        r   ÚRequestInformationzVTKAlgorithm.RequestInformation;   ó   € ð r   c                  ó   — y©zROverwritten by subclass to modify data request going
        to upstream pipeline.r3   r4   r5   s        r   ÚRequestUpdateExtentz VTKAlgorithm.RequestUpdateExtent@   r<   r   c                 ó   — t        d«      ‚©z1Overwritten by subclass to execute the algorithm.zRequestData must be implemented©ÚNotImplementedErrorr5   s        r   ÚRequestDatazVTKAlgorithm.RequestDataE   ó   € ä!Ð"CÓDÐDr   c                 ó¼  — |j                  t        j                  «       «      r| j                  ||||«      S |j                  t        j                  «       «      r| j                  ||||«      S |j                  t        j                  «       «      r| j                  ||||«      S |j                  t        j                  «       «      r| j                  ||||«      S y©z)Splits a request to RequestXXX() methods.r3   ©ÚHasr   ÚREQUEST_DATA_OBJECTr7   ÚREQUEST_INFORMATIONr;   r   ÚREQUEST_UPDATE_EXTENTr?   ÚREQUEST_DATArD   r5   s        r   ÚProcessRequestzVTKAlgorithm.ProcessRequestI   s¹   € à�;‰;Ô.×BÑBÓDÔEØ×)Ñ)¨'°7¸FÀGÓLÐLØ�[‰[Ô0×DÑDÓFÔGØ×*Ñ*¨7°G¸VÀWÓMÐMØ�[‰[Ô9×OÑOÓQÔRØ×+Ñ+¨G°W¸fÀgÓNÐNØ�[‰[Ô0×=Ñ=Ó?Ô@Ø×#Ñ# G¨W°f¸gÓFÐFàr   c                 ó`   — |j                  t        j                  «       | j                  «       y©z*Sets the required input type to InputType.r3   ©ÚSetr   ÚINPUT_REQUIRED_DATA_TYPEr   ©r   r   ÚportÚinfos       r   ÚFillInputPortInformationz%VTKAlgorithm.FillInputPortInformationV   ó    € à�‰”×6Ñ6Ó8¸$¿.¹.ÔIØr   c                 ó`   — |j                  t        j                  «       | j                  «       y©z+Sets the default output type to OutputType.r3   ©rR   r   ÚDATA_TYPE_NAMEr   rT   s       r   ÚFillOutputPortInformationz&VTKAlgorithm.FillOutputPortInformation[   ó    € à�‰”×-Ñ-Ó/°·±ÔAØr   N©r3   Ú
vtkDataSetr3   ÚvtkPolyData)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r)   r/   r7   r;   r?   rD   rN   rW   r]   r4   r   r   r
   r
      sJ   „ ñð 1=Ø2?ó	%òAòRòPò
òò
ò
Eòòó
r   r
   c                   óh   — e Zd ZdZ G d„ de«      Z	 	 dd„Zd„ Zd„ Zd„ Z	d„ Z
d	„ Zd
„ Zd„ Zd„ Zd„ Zy)ÚVTKPythonAlgorithmBaseai  This is a superclass which can be derived to implement
    Python classes that act as VTK algorithms in a VTK pipeline.
    It implements ProcessRequest(), FillInputPortInformation() and
    FillOutputPortInformation().

    ProcessRequest() calls RequestXXX() methods to implement
    various pipeline passes.

    FillInputPortInformation() and FillOutputPortInformation() set
    the input and output types based on data members.

    Common use is something like this:

    class HDF5Source(VTKPythonAlgorithmBase):
        def __init__(self):
            VTKPythonAlgorithmBase.__init__(self,
                nInputPorts=0,
                nOutputPorts=1, outputType='vtkImageData')

        def RequestInformation(self, request, inInfo, outInfo):
            f = h5py.File("foo.h5", 'r')
            dims = f['RTData'].shape[::-1]
            info = outInfo.GetInformationObject(0)
            info.Set(vtkmodules.vtkCommonExecutionModel.vtkStreamingDemandDrivenPipeline.WHOLE_EXTENT(),
                (0, dims[0]-1, 0, dims[1]-1, 0, dims[2]-1), 6)
            return 1

        def RequestData(self, request, inInfo, outInfo):
            f = h5py.File("foo.h5", 'r')
            data = f['RTData'][:]
            output = dsa.WrapDataObject(vtkmodules.vtkCommonDataModel.vtkImageData.GetData(outInfo))
            output.SetDimensions(data.shape)
            output.PointData.append(data.flatten(), 'RTData')
            output.PointData.SetActiveScalars('RTData')
            return 1

    alg = HDF5Source()

    cf = vtkmodules.vtkFiltersCore.vtkContourFilter()
    cf.SetInputConnection(alg.GetOutputPort())
    cf.Update()
    c                   ó(   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zy)ú(VTKPythonAlgorithmBase.InternalAlgorithmzInternal class. Do not use.c                  ó   — y ©Nr4   r   s     r   r   z3VTKPythonAlgorithmBase.InternalAlgorithm.InitializeŽ   s   € Ør   c                 ó&   — |j                  ||«      S rk   )rW   rT   s       r   rW   zAVTKPythonAlgorithmBase.InternalAlgorithm.FillInputPortInformation‘   s   € Ø×3Ñ3°D¸$Ó?Ð?r   c                 ó&   — |j                  ||«      S rk   )r]   rT   s       r   r]   zBVTKPythonAlgorithmBase.InternalAlgorithm.FillOutputPortInformation”   s   € Ø×4Ñ4°T¸4Ó@Ð@r   c                 ó(   — |j                  |||«      S rk   )rN   r5   s        r   rN   z7VTKPythonAlgorithmBase.InternalAlgorithm.ProcessRequest—   s   € Ø×)Ñ)¨'°6¸7ÓCÐCr   N)rb   rc   rd   re   r   rW   r]   rN   r4   r   r   ÚInternalAlgorithmri   Œ   s   „ Ù%ò	ò	@ò	Aó	Dr   ro   c                 óª   — | j                  t        j                  «       «       | j                  |«       | j	                  |«       || _        || _        y)z½Sets up default NumberOfInputPorts, NumberOfOutputPorts,
        InputType and OutputType that are used by various methods.
        Make sure to call this method from any subclass' __init__N)ÚSetPythonObjectrg   ro   r   r   r   r   r   s        r   r   zVTKPythonAlgorithmBase.__init__š   sF   € ð 	×ÑÔ3×EÑEÓGÔHà×"Ñ" ;Ô/Ø×#Ñ# LÔ1à"ˆŒØ$ˆ�r   c                 ól   — ||   j                  |«      j                  t        j                  «       «      S r    r!   r%   s       r   r)   z#VTKPythonAlgorithmBase.GetInputData¨   r*   r   c                 óf   — |j                  |«      j                  t        j                  «       «      S r,   r!   r-   s      r   r/   z$VTKPythonAlgorithmBase.GetOutputData®   r0   r   c                 ó`   — |j                  t        j                  «       | j                  «       yrP   rQ   ©r   rU   rV   s      r   rW   z/VTKPythonAlgorithmBase.FillInputPortInformation³   rX   r   c                 ó`   — |j                  t        j                  «       | j                  «       yrZ   r[   ru   s      r   r]   z0VTKPythonAlgorithmBase.FillOutputPortInformation¸   r^   r   c                 ó´  — |j                  t        j                  «       «      r| j                  |||«      S |j                  t        j                  «       «      r| j                  |||«      S |j                  t        j                  «       «      r| j                  |||«      S |j                  t        j                  «       «      r| j                  |||«      S yrG   rH   ©r   r6   r&   r.   s       r   rN   z%VTKPythonAlgorithmBase.ProcessRequest½   s±   € à�;‰;Ô.×BÑBÓDÔEØ×)Ñ)¨'°6¸7ÓCÐCØ�[‰[Ô0×DÑDÓFÔGØ×*Ñ*¨7°F¸GÓDÐDØ�[‰[Ô9×OÑOÓQÔRØ×+Ñ+¨G°V¸WÓEÐEØ�[‰[Ô0×=Ñ=Ó?Ô@Ø×#Ñ# G¨V°WÓ=Ð=àr   c                  ó   — yr2   r4   rx   s       r   r7   z(VTKPythonAlgorithmBase.RequestDataObjectÊ   r8   r   c                  ó   — yr:   r4   rx   s       r   r;   z)VTKPythonAlgorithmBase.RequestInformationÐ   r<   r   c                  ó   — yr>   r4   rx   s       r   r?   z*VTKPythonAlgorithmBase.RequestUpdateExtentÕ   r<   r   c                 ó   — t        d«      ‚rA   rB   rx   s       r   rD   z"VTKPythonAlgorithmBase.RequestDataÚ   rE   r   Nr_   )rb   rc   rd   re   Úobjectro   r   r)   r/   rW   r]   rN   r7   r;   r?   rD   r4   r   r   rg   rg   `   sS   „ ñ)ôVD˜Fô Dð 1=Ø2?ó%òRòPò
ò
ò
òòò
ó
Er   rg   N)Úvtkmodules.vtkCommonCorer   Úvtkmodules.vtkCommonDataModelr   Ú"vtkmodules.vtkCommonExecutionModelr   r   r   Úvtkmodules.vtkFiltersPythonr   r}   r
   rg   r4   r   r   Ú<module>r‚      s7   ðÝ 3Ý 7Ý ;Ý FÝ OÝ :ôV�6ô Vôp|EÐ/õ |Er   