|
| 1 | +from compas_cgal.straight_skeleton_2 import create_interior_straight_skeleton |
| 2 | +from compas_cgal.straight_skeleton_2 import create_interior_straight_skeleton_with_holes |
| 3 | +from compas_cgal.straight_skeleton_2 import create_offset_polygons_2 |
| 4 | +from compas_cgal.straight_skeleton_2 import create_weighted_offset_polygons_2 |
| 5 | + |
| 6 | + |
| 7 | +def test_straight_polygon(): |
| 8 | + points = [ |
| 9 | + (-1, -1, 0), |
| 10 | + (0, -12, 0), |
| 11 | + (1, -1, 0), |
| 12 | + (12, 0, 0), |
| 13 | + (1, 1, 0), |
| 14 | + (0, 12, 0), |
| 15 | + (-1, 1, 0), |
| 16 | + (-12, 0, 0), |
| 17 | + ] |
| 18 | + graph = create_interior_straight_skeleton(points) |
| 19 | + assert graph.number_of_edges() == 16 |
| 20 | + |
| 21 | + |
| 22 | +def test_straight_skeleton_with_holes(): |
| 23 | + points = [ |
| 24 | + (-1, -1, 0), |
| 25 | + (0, -12, 0), |
| 26 | + (1, -1, 0), |
| 27 | + (12, 0, 0), |
| 28 | + (1, 1, 0), |
| 29 | + (0, 12, 0), |
| 30 | + (-1, 1, 0), |
| 31 | + (-12, 0, 0), |
| 32 | + ] |
| 33 | + hole = [(-1, 0, 0), (0, 1, 0), (1, 0, 0), (0, -1, 0)] |
| 34 | + graph = create_interior_straight_skeleton_with_holes(points, [hole]) |
| 35 | + assert graph.number_of_edges() == 32 |
| 36 | + |
| 37 | + |
| 38 | +def test_offset(): |
| 39 | + points = [ |
| 40 | + (-1, -1, 0), |
| 41 | + (0, -12, 0), |
| 42 | + (1, -1, 0), |
| 43 | + (12, 0, 0), |
| 44 | + (1, 1, 0), |
| 45 | + (0, 12, 0), |
| 46 | + (-1, 1, 0), |
| 47 | + (-12, 0, 0), |
| 48 | + ] |
| 49 | + offset = 0.5 |
| 50 | + polygons = create_offset_polygons_2(points, offset) |
| 51 | + assert len(polygons) == 1, len(polygons) |
| 52 | + polygons = create_offset_polygons_2(points, -offset) |
| 53 | + assert len(polygons) == 1, len(polygons) |
| 54 | + weights = [0.1, 0.5, 0.3, 0.3, 0.9, 1.0, 0.2, 1.0] |
| 55 | + polygons = create_weighted_offset_polygons_2(points, offset, weights) |
| 56 | + assert len(polygons) == 1, len(polygons) |
| 57 | + polygons = create_weighted_offset_polygons_2(points, -offset, weights) |
| 58 | + assert len(polygons) == 1, len(polygons) |
0 commit comments