Changeset 7699
- Timestamp:
- Apr 28, 2010, 5:32:21 PM (15 years ago)
- Location:
- anuga_core/source/anuga
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/pmesh/mesh_interface.py
r7317 r7699 5 5 import numpy as num 6 6 from anuga.utilities.polygon import inside_polygon 7 from anuga.utilities.polygon import polylist2points_verts 7 8 import anuga.utilities.log as log 8 9 … … 29 30 minimum_triangle_angle=28.0, 30 31 fail_if_polygons_outside=True, 32 breaklines=None, 31 33 use_cache=False, 32 34 verbose=True): … … 65 67 the lower left hand corner of bounding_polygon (absolute) 66 68 as the x and y values for the geo_ref. 69 70 breaklines is a list of polygons. These lines will be preserved by the 71 triangulation algorithm - useful for coastlines, walls, etc. 72 The polygons are not closed. 67 73 68 74 Returns the mesh instance if no filename is given … … 90 96 'minimum_triangle_angle': minimum_triangle_angle, 91 97 'fail_if_polygons_outside': fail_if_polygons_outside, 98 'breaklines': breaklines, 92 99 'verbose': verbose} # FIXME (Ole): Should be bypassed one day. See ticket:14 93 100 … … 124 131 minimum_triangle_angle=28.0, 125 132 fail_if_polygons_outside=True, 133 breaklines=None, 126 134 verbose=True): 127 135 """_create_mesh_from_regions - internal function. … … 216 224 # print 'check %s in production directory' %figname 217 225 # import sys; sys.exit() 218 219 226 220 227 if interior_holes is not None: … … 246 253 247 254 m = Mesh(geo_reference=mesh_geo_reference) 255 256 # build a list of discrete segments from the breakline polygons 257 if breaklines is not None: 258 points, verts = polylist2points_verts(breaklines) 259 m.add_points_and_segments(points, verts) 248 260 249 261 # Do bounding polygon … … 303 315 304 316 305 306 317 # NOTE (Ole): This was moved here as it is annoying if mesh is always 307 318 # stored irrespective of whether the computation -
anuga_core/source/anuga/pmesh/test_mesh_interface.py
r7276 r7699 249 249 self.failUnless(m.geo_reference.get_zone()==zone, 'FAILED!') 250 250 self.failUnless(m.geo_reference.get_xllcorner()==min_x, 'FAILED!') 251 self.failUnless(m.geo_reference.get_yllcorner()==min_y, 'FAILED!') 252 251 self.failUnless(m.geo_reference.get_yllcorner()==min_y, 'FAILED!') 252 253 253 def test_create_mesh_from_regions3(self): 254 254 # These are the absolute values … … 636 636 raise Exception, msg 637 637 638 639 640 638 def test_create_mesh_with_breaklines(self): 639 # These are the absolute values 640 polygon = [[100,100], [1000,100], [1000,1000], [100,1000]] 641 642 boundary_tags = {'walls': [0,1], 'bom': [2,3]} 643 644 m = create_mesh_from_regions(polygon, 645 boundary_tags, 646 10000000, 647 breaklines=[[[50,50],[2000,2000]]]) 648 649 self.failUnless(len(m.regions) == 1, 'FAILED!') 650 segs = m.getUserSegments() 651 self.failUnless(len(segs) == 5, 'FAILED!') 652 self.failUnless(len(m.userVertices) == 6, 'FAILED!') 653 641 654 def test_create_mesh_from_regions_with_duplicate_verts(self): 642 655 # These are the absolute values -
anuga_core/source/anuga/utilities/polygon.py
r7690 r7699 1355 1355 atol) 1356 1356 1357 1357 1358 return interpolated_values 1358 1359 1360 1361 def polylist2points_verts(polylist): 1362 """ Convert a list of polygons to discrete points and vertices. 1363 """ 1364 1365 offset = 0 1366 points = [] 1367 vertices = [] 1368 for poly in polylist: 1369 points.extend(poly) 1370 vertices.extend([[i, i+1] for i in range(offset, offset+len(poly)-1)]) 1371 offset += len(poly) 1372 1373 return points, vertices 1359 1374 ## 1360 1375 # @brief
Note: See TracChangeset
for help on using the changeset viewer.