ó
    {ñ:iz3  ã                   óZ   • S r SSKrSSKJr  SSKJr  SSKr " S S5      r " S S\5      r	g)	z'
Mesh refinement for triangular grids.
é    N)Ú_api)ÚTriangulationc                   ó   • \ rS rSrSrS rSrg)Ú
TriRefineré   a+  
Abstract base class for classes implementing mesh refinement.

A TriRefiner encapsulates a Triangulation object and provides tools for
mesh refinement and interpolation.

Derived classes must implement:

- ``refine_triangulation(return_tri_index=False, **kwargs)`` , where
  the optional keyword arguments *kwargs* are defined in each
  TriRefiner concrete implementation, and which returns:

  - a refined triangulation,
  - optionally (depending on *return_tri_index*), for each
    point of the refined triangulation: the index of
    the initial triangulation triangle to which it belongs.

- ``refine_field(z, triinterpolator=None, **kwargs)``, where:

  - *z* array of field values (to refine) defined at the base
    triangulation nodes,
  - *triinterpolator* is an optional `~matplotlib.tri.TriInterpolator`,
  - the other optional keyword arguments *kwargs* are defined in
    each TriRefiner concrete implementation;

  and which returns (as a tuple) a refined triangular mesh and the
  interpolated values of the field at the refined triangulation nodes.
c                 óB   • [         R                  " [        US9  Xl        g )N)Útriangulation)r   Úcheck_isinstancer   Ú_triangulation)Úselfr	   s     Ú\/srv/projetos/modelo_ml_acdoc/venv/lib/python3.13/site-packages/matplotlib/tri/_trirefine.pyÚ__init__ÚTriRefiner.__init__*   s   € Ü×Òœm¸=ÒIØ+Õó    )r   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   Ú__static_attributes__© r   r   r   r      s   † ñõ:,r   r   c                   óT   ^ • \ rS rSrSrU 4S jrSS jrS	S jr\S
S j5       r	Sr
U =r$ )ÚUniformTriRefineré/   z®
Uniform mesh refinement by recursive subdivisions.

Parameters
----------
triangulation : `~matplotlib.tri.Triangulation`
    The encapsulated triangulation (to be refined)
c                 ó$   >• [         TU ]  U5        g ©N)Úsuperr   )r   r	   Ú	__class__s     €r   r   ÚUniformTriRefiner.__init__=   s   ø€ Ü‰Ñ˜Õ'r   c                 óä  • U R                   nUR                  R                  S   n[        R                  " U[        R
                  S9n[        U5       H  nU R                  X55      u  p5M     UR                  R                  S   nUR                  nU(       aÖ  [        R                  " US[        R
                  S9n	U R                   R                  n
U
c,  [        R                  " US5      R                  SS5      X˜'   X94$ X¥   n[        R                  " X[   S5      R                  SS5      X˜USS24   '   [        R                  " X[)    S5      R                  SS5      X˜U) SS24   '   X94$ U$ )a  
Compute a uniformly refined triangulation *refi_triangulation* of
the encapsulated :attr:`triangulation`.

This function refines the encapsulated triangulation by splitting each
father triangle into 4 child sub-triangles built on the edges midside
nodes, recursing *subdiv* times.  In the end, each triangle is hence
divided into ``4**subdiv`` child triangles.

Parameters
----------
return_tri_index : bool, default: False
    Whether an index table indicating the father triangle index of each
    point is returned.
subdiv : int, default: 3
    Recursion level for the subdivision.
    Each triangle is divided into ``4**subdiv`` child triangles;
    hence, the default results in 64 refined subtriangles for each
    triangle of the initial triangulation.

Returns
-------
refi_triangulation : `~matplotlib.tri.Triangulation`
    The refined triangulation.
found_index : int array
    Index of the initial triangulation containing triangle, for each
    point of *refi_triangulation*.
    Returned only if *return_tri_index* is set to True.
r   ©ÚdtypeéÿÿÿÿNé   )r   Ú	trianglesÚshapeÚnpÚarangeÚint32ÚrangeÚ_refine_triangulation_onceÚxÚfullÚmaskÚrepeatÚreshape)r   Úreturn_tri_indexÚsubdivÚrefi_triangulationÚntriÚ	ancestorsÚ_Ú	refi_nptsÚrefi_trianglesÚfound_indexÚtri_maskÚancestor_masks               r   Úrefine_triangulationÚ&UniformTriRefiner.refine_triangulation@   sp  € ð< "×0Ñ0ÐØ!×+Ñ+×1Ñ1°!Ñ4ˆô —I’I˜d¬"¯(©(Ñ3ˆ	Ü�v–ˆAØ,0×,KÑ,KØ"ó-/Ñ)Ð¡	ñ ð '×(Ñ(×.Ñ.¨qÑ1ˆ	Ø+×5Ñ5ˆö ô Ÿ'š' )¨R´r·x±xÑ@ˆKØ×*Ñ*×/Ñ/ˆHØÑÜ.0¯iªi¸	Ø89ó/;ß;B¹7À2Àq»>ð Ñ+ð &Ð2Ð2ð !)Ñ 3�ä "§	¢	¨)Ñ*BØ*+ó!-ß-4©W°R¸«^ð ¨=º!Ð+;Ñ<ñ ô !#§	¢	¨)°NÑ*CØ*+ó!-ß-4©W°R¸«^ð ¨M¨>º1Ð+<Ñ=ñ ð &Ð2Ð2à%Ð%r   c                 ó6  • Uc+  [         R                  R                  U R                  U5      nO/[        R
                  " [         R                  R                  US9  UnU R                  USS9u  pVUR                  UR                  UR                  US9S   nXW4$ )a%  
Refine a field defined on the encapsulated triangulation.

Parameters
----------
z : (npoints,) array-like
    Values of the field to refine, defined at the nodes of the
    encapsulated triangulation. (``n_points`` is the number of points
    in the initial triangulation)
triinterpolator : `~matplotlib.tri.TriInterpolator`, optional
    Interpolator used for field interpolation. If not specified,
    a `~matplotlib.tri.CubicTriInterpolator` will be used.
subdiv : int, default: 3
    Recursion level for the subdivision.
    Each triangle is divided into ``4**subdiv`` child triangles.

Returns
-------
refi_tri : `~matplotlib.tri.Triangulation`
     The returned refined triangulation.
refi_z : 1D array of length: *refi_tri* node count.
     The returned interpolated field (at *refi_tri* nodes).
)ÚtriinterpolatorT)r2   r1   )Ú	tri_indexr   )Ú
matplotlibÚtriÚCubicTriInterpolatorr   r   r
   ÚTriInterpolatorr<   Ú_interpolate_multikeysr,   Úy)r   Úzr?   r2   ÚinterpÚrefi_trir9   Úrefi_zs           r   Úrefine_fieldÚUniformTriRefiner.refine_field…   s    € ð0 Ñ"Ü—^‘^×8Ñ8Ø×#Ñ# Qó(‰Fô ×!Ò!¤*§.¡.×"@Ñ"@Ø2AòCà$ˆFà $× 9Ñ 9Ø¨Dð !:ð !2Ñˆà×.Ñ.Ø�J‰J˜Ÿ
™
¨kð /ð ;Ø;<ñ>ˆàÐÐr   c                 óf	  • U R                   nU R                  nU R                  nU R                  n[        R
                  " U5      S   n[        R
                  " U5      S   nUbj  [        R                  " U5      n[        R
                  " U5      U4:w  a9  [        S[        R
                  " U5       S[        R
                  " U5       35      e[        R                  " US:H  5      nSU-  U-   S-  n	Xi-   n
[        R                  " U
5      n[        R                  " U
5      nX+SU& X<SU& [        R                  " [        R                  " U[        R                  S9S5      n[        R                  " [        R                  " S[        R                  S9U5      nXMU4   nXß:„  nUU   nUU   nX%UU4      X%UUS	-   S-  4      -   S
-  nX5UU4      X5UUS	-   S-  4      -   S
-  nUX¶S& UXÆS& Un[        R                  " US/[        R                  S9nUn[        S5       HX  nUU:H  n[        R                  " U5      nUU   n[        R                  " U[        R                  S9U-   USS2U4   U'   UU-  nMZ     [        R                   " U5      nUU   nUU   n[        R"                  " UUSS24   [        R$                  " U[        R&                  " S[        R                  S95      -
  5      n[        R(                  " US	S9n UU   n!UUU 4   UUU!4'   [        R                  " US-  S/[        R                  S9n"[        R*                  " USS2S4   USS2S4   USS2S4   /5      R,                  U"SSS2SS24'   [        R*                  " USS2S	4   USS2S	4   USS2S4   /5      R,                  U"S	SS2SS24'   [        R*                  " USS2S4   USS2S4   USS2S	4   /5      R,                  U"SSS2SS24'   [        R*                  " USS2S4   USS2S	4   USS2S4   /5      R,                  U"SSS2SS24'   [/        X¼U"5      n#U R0                  b0  U#R3                  [        R                  " U R0                  S5      5        Uc  U#$ U#[        R                  " US5      4$ )aƒ  
Refine a `.Triangulation` by splitting each triangle into 4
child-masked_triangles built on the edges midside nodes.

Masked triangles, if present, are also split, but their children
returned masked.

If *ancestors* is not provided, returns only a new triangulation:
child_triangulation.

If the array-like key table *ancestor* is given, it shall be of shape
(ntri,) where ntri is the number of *triangulation* masked_triangles.
In this case, the function returns
(child_triangulation, child_ancestors)
child_ancestors is defined so that the 4 child masked_triangles share
the same index as their father: child_ancestors.shape = (4 * ntri,).
r   NzNIncompatible shapes provide for triangulation.masked_triangles and ancestors: z and r#   r$   é   r!   é   g      à?)Úaxisé   )r,   rF   Ú	neighborsr%   r'   r&   ÚasarrayÚ
ValueErrorÚsumÚzerosÚtiler(   r)   r/   Úemptyr*   Úlogical_notÚabsÚouterÚonesÚargminÚvstackÚTr   r.   Úset_mask)$r	   r5   r,   rF   rR   r%   Únptsr4   ÚbordersÚ	added_ptsr7   Úrefi_xÚrefi_yÚ
edge_elemsÚedge_apexesÚedge_neighborsÚmask_mastersÚmastersÚapex_mastersÚx_addÚy_addÚnew_pt_cornerÚnew_pt_midsideÚcum_sumÚimidÚmask_st_locÚn_masters_locÚelem_masters_locÚmask_slavesÚslavesÚslaves_mastersÚ
diff_tableÚslave_masters_apexÚslaves_apexÚchild_trianglesÚchild_triangulations$                                       r   r+   Ú,UniformTriRefiner._refine_triangulation_once«   sà  € ð( �O‰OˆØ�O‰Oˆð "×+Ñ+ˆ	Ø!×+Ñ+ˆ	Ü�xŠx˜‹{˜1‰~ˆÜ�xŠx˜	Ó" 1Ñ%ˆØÑ ÜŸ
š
 9Ó-ˆIÜ�xŠx˜	Ó" t gÓ-Ü ðEä—x’x 	Ó*Ð+¨5´·²¸)Ó1DÐ0EðGóHð Hô —&’&˜ b™Ó)ˆØ�t‘V˜gÑ%¨!Ñ+ˆ	ØÑ$ˆ	Ü—’˜)Ó$ˆÜ—’˜)Ó$ˆð ˆu�ˆØˆu�ˆô —W’WœRŸYšY t´2·8±8Ñ<¸aÓ@ˆ
Ü—i’i¤§	¢	¨!´2·8±8Ñ <¸dÓCˆØ"¨{Ð#:Ñ;ˆØ"Ñ3ˆð ˜\Ñ*ˆØ" <Ñ0ˆØ˜W lÐ2Ñ3Ñ4Ø˜W |°A¡~¸Ñ&:Ð:Ñ;Ñ<ñ=Ø@CñDˆà˜W lÐ2Ñ3Ñ4Ø˜W |°A¡~¸Ñ&:Ð:Ñ;Ñ<ñ=Ø@CñDˆàˆˆuˆØˆˆuˆð "ˆô Ÿš 4¨ )´2·8±8Ñ<ˆØˆÜ˜!–HˆDØ <Ñ/ˆKÜŸFšF ;Ó/ˆMØ& {Ñ3ÐÜ8:¿	º	Ø¤R§X¡Xñ9/Ø18ñ99ˆNš1˜d˜7Ñ#Ð$4Ñ5à�}Ñ$ŠGñ ô —n’n \Ó2ˆØ˜KÑ(ˆØ'¨Ñ4ˆÜ—V’V˜I n²aÐ&7Ñ8ÜŸHšH V¬R¯WªW°Q¼b¿h¹hÑ-GÓHñIó Jˆ
äŸYšY z¸Ñ:ÐØ! +Ñ.ˆØ.<ØÐ.Ð.ñ/0ˆ�v˜{Ð*Ñ+ô Ÿ(š( D¨¡F¨A ;´b·h±hÑ?ˆÜ#%§9¢9Øš!˜Q˜$Ñ ²°1°Ñ!5Øš1˜a˜4Ñ ð."ó $#ç#$¡1ð 	˜˜˜1˜ša˜Ñ ô $&§9¢9Øš!˜Q˜$Ñ ²°1°Ñ!5Øš1˜a˜4Ñ ð."ó $#ç#$¡1ð 	˜˜˜1˜ša˜Ñ ô $&§9¢9Øš!˜Q˜$Ñ ²°1°Ñ!5Øš1˜a˜4Ñ ð."ó $#ç#$¡1ð 	˜˜˜1˜ša˜Ñ ô $&§9¢9Øš1˜a˜4Ñ  .²°A°Ñ"6Øš1˜a˜4Ñ ð."ó $#ç#$¡1ð 	˜˜˜1˜ša˜Ñ ô ,¨F¸OÓLÐð ×ÑÑ)Ø×(Ñ(¬¯ª°=×3EÑ3EÀqÓ)IÔJàÑØ&Ð&à&¬¯	ª	°)¸QÓ(?Ð?Ð?r   r   )Fr$   )Nr$   r   )r   r   r   r   r   r   r<   rK   Ústaticmethodr+   r   Ú__classcell__)r   s   @r   r   r   /   s2   ø† ñõ(ôC&ôJ$ ðL óG@ó öG@r   r   )
r   Únumpyr'   rA   r   Úmatplotlib.tri._triangulationr   Úmatplotlib.tri._triinterpolater   r   r   r   r   Ú<module>rƒ      s3   ðñó å Ý 7Û %÷ ,ñ  ,ôFD@˜
õ D@r   