Changeset 7687
- Timestamp:
- Apr 19, 2010, 1:53:18 PM (13 years ago)
- Location:
- anuga_core/source/anuga/utilities
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/utilities/polygon.py
r7686 r7687 322 322 return False 323 323 324 def is_complex(polygon ):324 def is_complex(polygon, verbose=False): 325 325 """Check if a polygon is complex (self-intersecting) 326 326 """ … … 333 333 334 334 if (abs(i-j) > 1 and type == 1) or (type == 2 and list(point[0]) != list(point[1])) or (type == 3) and type != 4: 335 # print 'self-intersecting polygon, type ', type, ' point', point, 'vertex indices ', i, j 335 if verbose: 336 print 'Self-intersecting polygon found, type ', type, ' point', point, 'vertex indices ', i, j 336 337 return True 337 338 … … 996 997 997 998 # check this is a valid polygon 998 # JAMES: don't do this check yet, it's too slow, and there is already pathological data in the unit tests.999 999 # if is_complex(polygon): 1000 # msg = ' Self-intersecting polygon detected in file' + filename +'. '1000 # msg = 'ERROR: Self-intersecting polygon detected in file' + filename +'. ' 1001 1001 # msg += 'Please fix.' 1002 # raise Exception, msg 1002 # log.critical(msg) 1003 # # raise Exception, msg 1003 1004 1004 1005 return polygon -
anuga_core/source/anuga/utilities/test_polygon.py
r7686 r7687 1806 1806 assert res is False 1807 1807 1808 1808 1809 def test_is_polygon_complex(self): 1809 1810 concave_poly = [[0, 0], [10, 0], [5, 5], [10, 10], [0, 10]] 1810 complex_poly = [[0, 0], [10, 0], [5, 5], [5, 15], [5, 7], [10, 10], [0, 10]] 1811 1812 assert not is_complex(concave_poly) 1813 assert is_complex(complex_poly) 1814 1811 complex_poly = [[0, 0], [10, 0], [5, 5], [4, 15], [5, 7], [10, 10], [0, 10]] 1812 1813 not_complex = is_complex(concave_poly) 1814 complex = is_complex(complex_poly) 1815 1816 assert not not_complex 1817 assert complex 1818 1819 def test_is_polygon_complex2(self): 1820 concave_poly = [[0, 0], [10, 0], [11,0], [5, 5], [7,6], [10, 10], [1,5], [0, 10]] 1821 complex_poly = [[0, 0], [12,12], [10, 0], [5, 5], [3,18], [4, 15], [5, 7], [10, 10], [0, 10], [16, 12]] 1822 1823 not_complex = is_complex(concave_poly) 1824 complex = is_complex(complex_poly) 1825 1826 assert not not_complex 1827 assert complex 1815 1828 1816 1829 ################################################################################
Note: See TracChangeset
for help on using the changeset viewer.