Changeset 3038
- Timestamp:
- Jun 1, 2006, 12:13:01 PM (18 years ago)
- Location:
- inundation/pmesh
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/pmesh/mesh_interface.py
r2430 r3038 63 63 #In addition I reckon the polygons could be of class Geospatial_data 64 64 65 66 # First check that interior polygons are fully contained in bounding polygon 67 68 # FIXME (Ole): This causes the tests to fail because coordinates have been 69 # converted to relative coordinates (I think). How can we simplify this? 70 # 71 #if interior_regions is not None: 72 # from utilities.polygon import inside_polygon 73 # 74 # for interior_polygon, res in interior_regions: 75 # indices = inside_polygon(interior_polygon, bounding_polygon, 76 # closed = True, verbose = False) 77 # 78 # if len(indices) <> len(interior_polygon): 79 # msg = 'Interior polygon %s is outside bounding polygon: %s'\ 80 # %(str(interior_polygon), str(bounding_polygon)) 81 # raise msg 82 83 84 85 # Resolve geo referencing 65 86 if mesh_geo_reference is None: 66 87 bounding_polygon = ensure_numeric(bounding_polygon, Float) … … 81 102 m = Mesh(geo_reference=mesh_geo_reference) 82 103 83 # Do bounding polygon104 # Do bounding polygon 84 105 m.add_region_from_polygon(bounding_polygon, 85 106 tags=boundary_tags, 86 107 geo_reference=poly_geo_reference) 87 108 88 # Find one point inside region automatically109 # Find one point inside region automatically 89 110 if interior_regions is not None: 90 111 excluded_polygons = [] … … 97 118 98 119 99 # convert bounding poly to absolute values120 # Convert bounding poly to absolute values 100 121 # this sort of thing can be fixed with the geo_points class 101 122 if poly_geo_reference is not None: … … 110 131 inner.setMaxArea(maximum_triangle_area) 111 132 112 # Do interior regions133 # Do interior regions 113 134 if interior_regions is not None: 114 135 for polygon, res in interior_regions: -
inundation/pmesh/test_mesh_interface.py
r3013 r3038 221 221 'FAILED!') 222 222 223 def test_create_mesh_from_regions_interior_regions(self): 224 """Test that create_mesh_from_regions fails when an interior region is 225 outside bounding polygon. 226 """ 227 228 # These are the absolute values 229 min_x = 10 230 min_y = 88 231 polygon = [[min_x,min_y],[1000,100],[1000,1000],[100,1000]] 232 233 234 boundary_tags = {'walls':[0,1],'bom':[2]} 235 236 # This one is inside bounding polygon - should pass 237 inner_polygon = [[800,400],[900,500],[800,600]] 238 239 interior_regions = [(inner_polygon, 5)] 240 m = create_mesh_from_regions(polygon, 241 boundary_tags, 242 10000000, 243 interior_regions=interior_regions) 244 245 246 # This one sticks outside bounding polygon - should fail 247 inner_polygon = [[800,400],[1100,500],[800,600]] 248 interior_regions = [(inner_polygon, 5)] 249 250 251 252 try: 253 m = create_mesh_from_regions(polygon, 254 boundary_tags, 255 10000000, 256 interior_regions=interior_regions) 257 except: 258 pass 259 else: 260 msg = 'Interior polygon sticking outside bounding polygon should ' 261 msg += 'cause an Exception to be raised' 262 raise msg 263 264 265 223 266 224 267 def test_create_mesh_from_regions_with_duplicate_verts(self):
Note: See TracChangeset
for help on using the changeset viewer.