
    h8&                     4    S SK r S SKrS SKJr   " S S5      rg)    N)_apic                       \ rS rSrSrSS jrS r\S 5       rS r	S r
\S	 5       r\S
 5       rS r\S 5       rS rSrg)Triangulation   a  
An unstructured triangular grid consisting of npoints points and
ntri triangles.  The triangles can either be specified by the user
or automatically generated using a Delaunay triangulation.

Parameters
----------
x, y : (npoints,) array-like
    Coordinates of grid points.
triangles : (ntri, 3) array-like of int, optional
    For each triangle, the indices of the three points that make
    up the triangle, ordered in an anticlockwise manner.  If not
    specified, the Delaunay triangulation is calculated.
mask : (ntri,) array-like of bool, optional
    Which triangles are masked out.

Attributes
----------
triangles : (ntri, 3) array of int
    For each triangle, the indices of the three points that make
    up the triangle, ordered in an anticlockwise manner. If you want to
    take the *mask* into account, use `get_masked_triangles` instead.
mask : (ntri, 3) array of bool or None
    Masked out triangles.
is_delaunay : bool
    Whether the Triangulation is a calculated Delaunay
    triangulation (where *triangles* was not specified) or not.

Notes
-----
For a Triangulation to be valid it must not have duplicate points,
triangles formed from colinear points, or overlapping triangles.
Nc                    SSK Jn  [        R                  " U[        R                  S9U l        [        R                  " U[        R                  S9U l        U R
                  R                  U R                  R                  :w  d  U R
                  R                  S:w  a;  [        SU R
                  R                  < SU R                  R                  < 35      eS U l
        S U l        S U l        SU l        Uc@  UR                  X[        R                   R"                  5      u  U l        U l        SU l        GOK [        R&                  " U[        R(                  S	S
9U l        U R$                  R                  S:w  d  U R$                  R                  S   S:w  a#  [        SU R$                  R                  < 35      eU R$                  R+                  5       [-        U R
                  5      :  a<  [        S[-        U R
                  5       SU R$                  R+                  5        35      eU R$                  R/                  5       S:  a<  [        S[-        U R
                  5       SU R$                  R/                  5        35      eS U l        S U l        U R5                  U5        g ! [         a  n[        SU< 35      UeS nAff = f)Nr   )_qhulldtype   z9x and y must be equal-length 1D arrays, but found shapes z and FTC)r
   orderz*triangles must be a (N, 3) int array, not       z6triangles must be a (N, 3) int array, but found shape zHtriangles are indices into the points and must be in the range 0 <= i < z but found value )
matplotlibr   npasarrayfloat64xyshapendim
ValueErrormask_edges
_neighborsis_delaunaydelaunaysysflagsverbose	trianglesarrayint32maxlenmin_cpp_triangulation
_trifinderset_mask)selfr   r   r!   r   r   es          O/var/www/html/env/lib/python3.13/site-packages/matplotlib/tri/_triangulation.py__init__Triangulation.__init__*   sC   %ARZZ0ARZZ066<<466<<'466;;!+; --1VV\\,<E $/1 2 2 	  /5ooaCIIDUDU.V+DNDO#D:!#)2883!O ~~""a'4>>+?+?+Ba+G L~~++.01 1 ~~!!#s466{2 &&)$&&k]2C~~))+,./ / ~~!!#a' &&)$&&k]2C~~))+,./ / #' d1  : !M$-="2 389::s   :)J$ $
K.J>>Kc                 @    U R                  5       R                  U5      $ )aE  
Calculate plane equation coefficients for all unmasked triangles from
the point (x, y) coordinates and specified z-array of shape (npoints).
The returned array has shape (npoints, 3) and allows z-value at (x, y)
position in triangle tri to be calculated using
``z = array[tri, 0] * x  + array[tri, 1] * y + array[tri, 2]``.
)get_cpp_triangulationcalculate_plane_coefficients)r*   zs     r,   r1   *Triangulation.calculate_plane_coefficients]   s     ))+HHKK    c                 z    U R                   c#  U R                  5       R                  5       U l         U R                   $ )a  
Return integer array of shape (nedges, 2) containing all edges of
non-masked triangles.

Each row defines an edge by its start point index and end point
index.  Each edge appears only once, i.e. for an edge between points
*i*  and *j*, there will only be either *(i, j)* or *(j, i)*.
)r   r0   	get_edgesr*   s    r,   edgesTriangulation.edgesg   s1     ;;446@@BDK{{r4   c           	      h   SSK Jn  U R                  c  UR                  U R                  U R
                  U R                  U R                  b  U R                  OSU R                  b  U R                  OSU R                  b  U R                  OSU R                  (       + 5      U l        U R                  $ )zK
Return the underlying C++ Triangulation object, creating it
if necessary.
r   )_tri )r   r;   r'   r   r   r   r!   r   r   r   r   )r*   r;   s     r,   r0   #Triangulation.get_cpp_triangulationu   s    
 	$""*&*&8&8!YY2		#{{6B#'??#>B$$$'&D# &&&r4   c                 h    U R                   b  U R                  U R                   )    $ U R                  $ )z<
Return an array of triangles taking the mask into account.
)r   r!   r7   s    r,   get_masked_triangles"Triangulation.get_masked_triangles   s-     99 >>499*-->>!r4   c                      [        U S   [        5      (       a<  U tp SU;   a  [        R                  " S5        SU;   a  [        R                  " S5        O%[        R	                  X5      u  p4pVp[        X4XV5      nX U4$ )a  
Return a Triangulation object from the args and kwargs, and
the remaining args and kwargs with the consumed values removed.

There are two alternatives: either the first argument is a
Triangulation object, in which case it is returned, or the args
and kwargs are sufficient to create a new Triangulation to
return.  In the latter case, see Triangulation.__init__ for
the possible args and kwargs.
r   r!   zOPassing the keyword 'triangles' has no effect when also passing a Triangulationr   zJPassing the keyword 'mask' has no effect when also passing a Triangulation)
isinstancer   r   warn_external_extract_triangulation_params)argskwargstriangulationr   r   r!   r   s          r,   get_from_args_and_kwargs&Triangulation.get_from_args_and_kwargs   s     d1g}--#' Mf$""./ ""./
 ;;DI 0A)4)!	@MF**r4   c                 b   U tp#n UR                  SS 5      nSnUc  U (       a  U S   nSnUb$   [        R                  " U[        R                  S9nUb%  UR
                  S:w  d  UR                  S   S:w  a  S nUb  U(       a  U SS  n UR                  S	S 5      nX#XFX4$ ! [         a    S n N\f = f)
Nr!   Fr   Tr	   r   r   r   r   )popr   r   r#   r   r   r   )rE   rF   r   r   r!   	from_argsr   s          r,   rD   +Triangulation._extract_triangulation_params   s    tJJ{D1		QII !JJyA	  inn&9&/ooa&8A&=I Y8Dzz&$'Yd22  ! 	!s   #B B.-B.c                 Z    U R                   c  SSKJn  U" U 5      U l         U R                   $ )z
Return the default `matplotlib.tri.TriFinder` of this
triangulation, creating it if necessary.  This allows the same
TriFinder object to be easily shared.
r   )TrapezoidMapTriFinder)r(   matplotlib.tri._trifinderrO   )r*   rO   s     r,   get_trifinderTriangulation.get_trifinder   s'     ??"G3D9DOr4   c                 z    U R                   c#  U R                  5       R                  5       U l         U R                   $ )a_  
Return integer array of shape (ntri, 3) containing neighbor triangles.

For each triangle, the indices of the three triangles that
share the same edges, or -1 if there is no such neighboring
triangle.  ``neighbors[i, j]`` is the triangle that is the neighbor
to the edge from point index ``triangles[i, j]`` to point index
``triangles[i, (j+1)%3]``.
)r   r0   get_neighborsr7   s    r,   	neighborsTriangulation.neighbors   s1     ??""88:HHJDOr4   c                    Uc  SU l         O[[        R                  " U[        S9U l         U R                   R                  U R
                  R                  S   4:w  a  [        S5      eU R                  b4  U R                  R                  U R                   b  U R                   OS5        SU l	        SU l
        U R                  b  U R                  R                  5         gg)z^
Set or clear the mask array.

Parameters
----------
mask : None or bool array of length ntri
Nr	   r   z3mask array must have same length as triangles arrayr<   )r   r   r   boolr   r!   r   r'   r)   r   r   r(   _initialize)r*   r   s     r,   r)   Triangulation.set_mask   s     <DI

4t4DIyy4>>#7#7#:"<<  "3 4 4 "".##,,!YY2		<  ??&OO'') 'r4   )	r'   r   r   r(   r   r   r!   r   r   )NN)__name__
__module____qualname____firstlineno____doc__r-   r1   propertyr8   r0   r?   staticmethodrH   rD   rQ   rU   r)   __static_attributes__r<   r4   r,   r   r      sx     B1fL  ' " + +6 3 3,
  *r4   r   )r   numpyr   r   r   r   r<   r4   r,   <module>rd      s    
  o* o*r4   