source: trunk/anuga_core/source/anuga/file/pts.py @ 8813

Last change on this file since 8813 was 7859, checked in by hudson, 14 years ago

Cleaned up some code.

File size: 1012 bytes
Line 
1"""
2    Fit a boundary polygon around arbitrary points.
3"""
4
5
6def load_pts_as_polygon(points_file, minimum_triangle_angle=3.0):
7    """
8    WARNING: This function is not fully working.
9
10    Function to return a polygon returned from alpha shape, given a points file.
11
12    WARNING: Alpha shape returns multiple polygons, but this function only
13             returns one polygon.
14    """
15
16    from anuga.pmesh.mesh import importMeshFromFile
17    from anuga.shallow_water.shallow_water_domain import Domain
18
19    mesh = importMeshFromFile(points_file)
20    mesh.auto_segment()
21    mesh.exportASCIIsegmentoutlinefile("outline.tsh")
22    mesh2 = importMeshFromFile("outline.tsh")
23    mesh2.generate_mesh(maximum_triangle_area=1000000000,
24                        minimum_triangle_angle=minimum_triangle_angle,
25                        verbose=False)
26    mesh2.export_mesh_file('outline_meshed.tsh')
27    domain = Domain("outline_meshed.tsh", use_cache = False)
28    polygon =  domain.get_boundary_polygon()
29    return polygon
Note: See TracBrowser for help on using the repository browser.