o
    h                     @   sB   d dl Zd dlmZ d dlmZ G dd dZG dd deZdS )    N)_api)Triangulationc                   @   s    e Zd ZdZdd Zdd ZdS )	TriFindera  
    Abstract base class for classes used to find the triangles of a
    Triangulation in which (x, y) points lie.

    Rather than instantiate an object of a class derived from TriFinder, it is
    usually better to use the function `.Triangulation.get_trifinder`.

    Derived classes implement __call__(x, y) where x and y are array-like point
    coordinates of the same shape.
    c                 C   s   t jt|d || _d S )N)triangulation)r   check_isinstancer   _triangulation)selfr    r	   m/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/matplotlib/tri/_trifinder.py__init__   s   
zTriFinder.__init__c                 C   s   t )N)NotImplementedError)r   xyr	   r	   r
   __call__   s   zTriFinder.__call__N)__name__
__module____qualname____doc__r   r   r	   r	   r	   r
   r      s    r   c                       s@   e Zd ZdZ fddZdd Zdd Zdd	 Zd
d Z  Z	S )TrapezoidMapTriFindera  
    `~matplotlib.tri.TriFinder` class implemented using the trapezoid
    map algorithm from the book "Computational Geometry, Algorithms and
    Applications", second edition, by M. de Berg, M. van Kreveld, M. Overmars
    and O. Schwarzkopf.

    The triangulation must be valid, i.e. it must not have duplicate points,
    triangles formed from colinear points, or overlapping triangles.  The
    algorithm has some tolerance to triangles formed from colinear points, but
    this should not be relied upon.
    c                    s4   ddl m} t | || | _|   d S )Nr   )_tri)
matplotlibr   superr   r   get_cpp_triangulation_cpp_trifinder_initialize)r   r   r   	__class__r	   r
   r   (   s   zTrapezoidMapTriFinder.__init__c                 C   sV   t j|t jd}t j|t jd}|j|jkrtd| j| | |j}|S )aj  
        Return an array containing the indices of the triangles in which the
        specified *x*, *y* points lie, or -1 for points that do not lie within
        a triangle.

        *x*, *y* are array-like x and y coordinates of the same shape and any
        number of dimensions.

        Returns integer array with the same shape and *x* and *y*.
        )dtypez.x and y must be array-like with the same shape)	npasarrayfloat64shape
ValueErrorr   	find_manyravelreshape)r   r   r   indicesr	   r	   r
   r   /   s   zTrapezoidMapTriFinder.__call__c                 C   s
   | j  S )a  
        Return a python list containing the statistics about the node tree:
            0: number of nodes (tree size)
            1: number of unique nodes
            2: number of trapezoids (tree leaf nodes)
            3: number of unique trapezoids
            4: maximum parent count (max number of times a node is repeated in
                   tree)
            5: maximum depth of tree (one more than the maximum number of
                   comparisons needed to search through the tree)
            6: mean of all trapezoid depths (one more than the average number
                   of comparisons needed to search through the tree)
        )r   get_tree_statsr   r	   r	   r
   _get_tree_statsD   s   
z%TrapezoidMapTriFinder._get_tree_statsc                 C      | j   dS )z
        Initialize the underlying C++ object.  Can be called multiple times if,
        for example, the triangulation is modified.
        N)r   
initializer(   r	   r	   r
   r   T      z!TrapezoidMapTriFinder._initializec                 C   r*   )zo
        Print a text representation of the node tree, which is useful for
        debugging purposes.
        N)r   
print_treer(   r	   r	   r
   _print_tree[   r,   z!TrapezoidMapTriFinder._print_tree)
r   r   r   r   r   r   r)   r   r.   __classcell__r	   r	   r   r
   r      s    r   )numpyr   r   r   matplotlib.trir   r   r   r	   r	   r	   r
   <module>   s
    