rL i8&4ddlZddlZddlmZGddZy)N)_apicveZdZdZd dZdZedZdZdZ e dZ e d Z d Z ed Zd Zy) Triangulationa* 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. Ncddlm}tj|tj|_tj|tj|_|j j|j jk7s|j jdk7r9td|j jd|j jd|_ d|_ d|_ d|_ |A|j||tj j"\|_|_ d|_ nH tj&|tj(d |_|j$jd k7s|j$jdd k7r"td|j$j|j$j+t-|j k\r>+?+?+Ba+G L~~++.011~~!!#s466{2 &&)$&&k]2C~~))+,.//~~!!#a' &&)$&&k]2C~~))+,.// #' d1 : !M$-="2389: :s:+J!! J>*J99J>c@|jj|S)au 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_triangulationcalculate_plane_coefficients)r)zs r+r/z*Triangulation.calculate_plane_coefficients]s))+HHKKcx|j#|jj|_|jS)aM 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)*. )rr. get_edgesr)s r+edgeszTriangulation.edgesgs1 ;; 446@@BDK{{r1c Xddlm}|j|j|j|j |j |j |jnd|j |jnd|j |jnd|j |_|jS)zc Return the underlying C++ Triangulation object, creating it if necessary. r)_tri) rr7r&rrrr rrrr)r)r7s r+r.z#Triangulation.get_cpp_triangulationus $  " " *&*&8&8!YY2 #{{6 B#'??#>B$$$ '&D #&&&r1cf|j|j|jS|jS)zL Return an array of triangles taking the mask into account. )rr r4s r+get_masked_trianglesz"Triangulation.get_masked_triangless- 99 >>499*- ->> !r1ct|dtr7|^}}d|vrtjdd|vrAtjdn+tj ||\}}}}}}t||||}|||fS)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. rr zOPassing the keyword 'triangles' has no effect when also passing a TriangulationrzJPassing the keyword 'mask' has no effect when also passing a Triangulation) isinstancerr warn_external_extract_triangulation_params)argskwargs triangulationrrr rs r+get_from_args_and_kwargsz&Triangulation.get_from_args_and_kwargss d1g} -#' MDf$""./""./ ;;D&I 0Aq)T4)!Q 4@MdF**r1cL|^}}}|jdd}d}| |r|d}d}|& tj|tj}|#|j dk7s|j ddk7rd}||r|dd}|jd d}||||||fS#t$rd}YUwxYw) Nr FrTrr r rr)poprrr"rrr)r?r@rrr from_argsrs r+r>z+Triangulation._extract_triangulation_paramss 1tJJ{D1   QII   !JJyA   inn&9&/ooa&8A&=I  Y8Dzz&$'!YdF22 !  !s%B B#"B#cX|jddlm}|||_|jS)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._trifinderrG)r)rGs r+ get_trifinderzTriangulation.get_trifinders' ?? " G3D9DOr1cx|j#|jj|_|jS)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]``. )rr. get_neighborsr4s r+ neighborszTriangulation.neighborss1 ?? ""88:HHJDOr1c|d|_n\tj|t|_|jj|j jdfk7r t d|j3|jj|j |jndd|_ d|_ |j|jjyy)z Set or clear the mask array. Parameters ---------- mask : None or bool array of length ntri Nrrz3mask array must have same length as triangles arrayr8) rrrboolrr rr&r(rrr' _initialize)r)rs r+r(zTriangulation.set_masks <DI 4t4DIyy4>>#7#7#:"<< "344  " " .  # # , ,!YY2  <  ?? & OO ' ' ) 'r1)NN)__name__ __module__ __qualname____doc__r,r/propertyr5r.r: staticmethodrBr>rIrLr(r8r1r+rrsx B1fL  ' "++633,   *r1r)rnumpyrrrrr8r1r+rWs o*o*r1