Changeset 8057
 Timestamp:
 Oct 30, 2010, 5:51:31 PM (12 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/anuga_core/source/anuga/geometry/polygon.py
r8053 r8057 350 350 return bool(_is_inside_triangle(point, triangle, int(closed), rtol, atol)) 351 351 352 def is_complex(polygon, verbose=False):352 def is_complex(polygon, closed=True, verbose=False): 353 353 """Check if a polygon is complex (selfintersecting). 354 354 Uses a sweep algorithm that is O(n^2) in the worst case, but … … 378 378 for i in range(0, len(polygon)1): 379 379 unsorted_segs.append([list(polygon[i]), list(polygon[i+1])]) 380 unsorted_segs.append([list(polygon[0]), list(polygon[1])]) 380 381 if closed: 382 unsorted_segs.append([list(polygon[0]), list(polygon[1])]) 381 383 382 384 # all segments must point in same direction … … 855 857 ################################################################################ 856 858 857 def read_polygon(filename, delimiter=','): 858 """ Read points assumed to form a polygon. 859 860 Also checks to make sure polygon is not complex (selfintersecting). 859 def read_polygon(filename, delimiter=',', closed='True'): 860 """ Read points assumed to form a (closed) polygon. 861 Can also be used toread in a polyline (closed = 'False') 862 863 Also checks to make sure polygon (polyline) 864 is not complex (selfintersecting). 861 865 862 866 filename Path to file containing polygon data. … … 876 880 polygon.append([float(fields[0]), float(fields[1])]) 877 881 878 # check this is a valid polygon .879 if is_complex(polygon, verbose=True):882 # check this is a valid polygon (polyline). 883 if is_complex(polygon, closed, verbose=True): 880 884 msg = 'ERROR: Selfintersecting polygon detected in file ' 881 885 msg += filename +'. A complex polygon will not '
Note: See TracChangeset
for help on using the changeset viewer.