|
| 1 | +from compas_plotters import Plotter |
| 2 | +from compas.geometry import Polygon, Translation |
| 3 | +from compas.datastructures import Mesh |
| 4 | +from compas_triangle.delaunay import conforming_delaunay_triangulation |
| 5 | + |
| 6 | +# ============================================================================== |
| 7 | +# Constraints |
| 8 | +# ============================================================================== |
| 9 | + |
| 10 | +boundary = Polygon.from_sides_and_radius_xy(4, 10) |
| 11 | +boundary = list(boundary) |
| 12 | + |
| 13 | +hole = Polygon.from_sides_and_radius_xy(8, 2) |
| 14 | + |
| 15 | +hole1 = hole.transformed(Translation.from_vector([4, 0, 0])) |
| 16 | +hole2 = hole.transformed(Translation.from_vector([-4, 0, 0])) |
| 17 | +hole3 = hole.transformed(Translation.from_vector([0, 4, 0])) |
| 18 | +hole4 = hole.transformed(Translation.from_vector([0, -4, 0])) |
| 19 | + |
| 20 | +holes = [list(hole1), list(hole2), list(hole3), list(hole4)] |
| 21 | + |
| 22 | +# ============================================================================== |
| 23 | +# Triangulation |
| 24 | +# ============================================================================== |
| 25 | + |
| 26 | +V, F = conforming_delaunay_triangulation(boundary, polygons=holes, area=0.3) |
| 27 | + |
| 28 | +mesh = Mesh.from_vertices_and_faces(V, F) |
| 29 | + |
| 30 | +# ============================================================================== |
| 31 | +# Viz |
| 32 | +# ============================================================================== |
| 33 | + |
| 34 | +plotter = Plotter(figsize=(8, 8)) |
| 35 | +plotter.add(mesh, sizepolicy='absolute', vertexsize=5) |
| 36 | +plotter.zoom_extents() |
| 37 | +plotter.show() |
0 commit comments