# add inundation dir to your pythonpath from pmesh.mesh import Mesh from coordinate_transforms.geo_reference import Geo_reference def create_mesh(maximum_triangle_area, mesh_file=None, triangles_in_name = False): """ triangles_in_name, if True is used to append the number of triangles in the mesh to the mesh file name. """ # create a mesh instance m = Mesh() # outer_polygon = [[0,0],[100,0],[100,100],[0,100]] m.add_region_from_polygon(outer_polygon, tags={'wall':[0,1,2], 'wave':[3]}) # inner polygons polygon = [[10,10],[20,10],[20,20],[10,20]] m.add_hole_from_polygon(polygon, tags={'wall':[0,1,2,3]}) polygon = [[40,40],[50,40],[50,50],[40,50]] m.add_hole_from_polygon(polygon, tags={'wall':[0,1,2,3]}) m.add_circle([20,70], 5, hole=True, tag='wall') m.generate_mesh(maximum_triangle_area=maximum_triangle_area) triangle_count = m.get_triangle_count() if mesh_file is None: return m, triangle_count else: if triangles_in_name is True: mesh_file = mesh_file[:-4] + '_' + str(triangle_count) \ + mesh_file[-4:] m.export_mesh_file(mesh_file) return mesh_file, triangle_count #------------------------------------------------------------- if __name__ == "__main__": _, triangle_count = create_mesh(10,mesh_file="test.tsh") print "triangle_count",triangle_count