Changeset 4574
- Timestamp:
- Jul 2, 2007, 3:04:26 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/utilities/polygon.py
r4241 r4574 742 742 """Calcalutes the approximate number of triangles inside the bounding polygon 743 743 and the other interior regions 744 745 Polygon areas are converted to square Kms 746 744 747 FIXME: Add tests for this function 745 748 """ 749 746 750 from anuga.utilities.polygon import polygon_area 747 751 752 748 753 # TO DO check if any of the regions fall inside one another 754 755 print '----------------------------------------------------------------------------' 756 print 'Polygon Max triangle area (m^2) Total area (km^2) Estimated #triangles' 757 print '----------------------------------------------------------------------------' 758 749 759 no_triangles = 0.0 750 760 area = polygon_area(bounding_poly) 751 # print 'area of bounding_poly with res ',remainder_res,' is ', area/1000000. 752 for i,jin interior_regions:753 this_area = polygon_area( i)754 this_triangles = this_area/ j761 762 for poly, resolution in interior_regions: 763 this_area = polygon_area(poly) 764 this_triangles = this_area/resolution 755 765 no_triangles += this_triangles 756 766 area -= this_area 757 #convert to square Kms 758 print 'area of',j, 'trigs', this_triangles, 'this area', this_area/1000000. 767 768 print 'Interior ', 769 print ('%.0f' %resolution).ljust(25), 770 print ('%.2f' %(this_area/1000000)).ljust(19), 771 print '%d' %(this_triangles) 772 759 773 bound_triangles = area/remainder_res 760 774 no_triangles += bound_triangles 761 print 'area of',remainder_res,'bound triangles:', bound_triangles, 'bound area:', area/1000000. 762 return int(no_triangles/0.7) 775 776 print 'Bounding ', 777 print ('%.0f' %remainder_res).ljust(25), 778 print ('%.2f' %(area/1000000)).ljust(19), 779 print '%d' %(bound_triangles) 780 781 total_number_of_triangles = no_triangles/0.7 782 783 print 'Estimated total number of triangles: %d' %total_number_of_triangles 784 print 'Note: This is generally about 20% less than the final amount' 785 786 return int(total_number_of_triangles) 763 787 764 788
Note: See TracChangeset
for help on using the changeset viewer.