Changeset 8031


Ignore:
Timestamp:
Oct 10, 2010, 5:13:51 PM (14 years ago)
Author:
habili
Message:

Added polygon_overlap function

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_core/source/anuga/geometry/polygon.py

    r8009 r8031  
    221221    return status, value
    222222
     223def polygon_overlap(triangles, polygon, verbose=False):
     224    """Determine if a polygon and triangle overlap
     225
     226    """
     227    polygon = ensure_numeric(polygon)
     228    triangles = ensure_numeric(triangles)
     229   
     230    M = triangles.shape[0]/3  # Number of triangles
     231
     232    indices = num.zeros(M, num.int)
     233
     234    count = _polygon_overlap(polygon, triangles, indices)
     235
     236    if verbose:
     237        log.critical('Found %d triangles (out of %d) that polygon' % (count, M))
     238
     239    return indices[:count]
     240   
     241def not_polygon_overlap(triangles, polygon, verbose=False):
     242    """Determine if a polygon and triangle overlap
     243
     244    """
     245    polygon = ensure_numeric(polygon)
     246    triangles = ensure_numeric(triangles)
     247   
     248    M = triangles.shape[0]/3  # Number of triangles
     249
     250    indices = num.zeros(M, num.int)
     251
     252    count = _polygon_overlap(polygon, triangles, indices)
     253
     254    if verbose:
     255        log.critical('Found %d triangles (out of %d) that polygon' % (count, M))
     256
     257    return indices[count:]   
     258
    223259def is_inside_triangle(point, triangle,
    224260                       closed=True,
     
    10981134    from polygon_ext import _separate_points_by_polygon
    10991135    from polygon_ext import _interpolate_polyline   
     1136    from polygon_ext import _polygon_overlap
    11001137    from polygon_ext import _is_inside_triangle       
    11011138    #from polygon_ext import _intersection
Note: See TracChangeset for help on using the changeset viewer.