|
| 1 | +from compas_cgal.straight_skeleton_2 import create_interior_straight_skeleton |
| 2 | +from compas.tolerance import TOL |
| 3 | + |
| 4 | + |
| 5 | +def test_straight_polygon(): |
| 6 | + points = [ |
| 7 | + (-1, -1, 0), |
| 8 | + (0, -12, 0), |
| 9 | + (1, -1, 0), |
| 10 | + (12, 0, 0), |
| 11 | + (1, 1, 0), |
| 12 | + (0, 12, 0), |
| 13 | + (-1, 1, 0), |
| 14 | + (-12, 0, 0), |
| 15 | + ] |
| 16 | + lines = create_interior_straight_skeleton(points) |
| 17 | + assert len(lines) == 8 |
| 18 | + |
| 19 | + |
| 20 | +def test_straight_polygon_2_compare(): |
| 21 | + points = [ |
| 22 | + (-1.91, 3.59, 0.0), |
| 23 | + (-5.53, -5.22, 0.0), |
| 24 | + (-0.39, -1.98, 0.0), |
| 25 | + (2.98, -5.51, 0.0), |
| 26 | + (4.83, -2.02, 0.0), |
| 27 | + (9.70, -3.63, 0.0), |
| 28 | + (12.23, 1.25, 0.0), |
| 29 | + (3.42, 0.66, 0.0), |
| 30 | + (2.92, 4.03, 0.0), |
| 31 | + (-1.91, 3.59, 0.0), |
| 32 | + ] |
| 33 | + lines = create_interior_straight_skeleton(points) |
| 34 | + |
| 35 | + expected = [ |
| 36 | + [[-1.91, 3.59, 0.0], [-0.139446292, 1.191439787, 0.0]], |
| 37 | + [[-5.53, -5.22, 0.0], [-0.139446292, 1.191439787, 0.0]], |
| 38 | + [[-0.39, -1.98, 0.0], [0.008499564, 1.241560466, 0.0]], |
| 39 | + [[2.98, -5.51, 0.0], [2.44972507, -1.674799065, 0.0]], |
| 40 | + [[4.83, -2.02, 0.0], [4.228131167, -0.522007766, 0.0]], |
| 41 | + [[8.663865218, -1.084821998, 0.0], [9.7, -3.63, 0.0]], |
| 42 | + [[12.23, 1.25, 0.0], [8.663865218, -1.084821998, 0.0]], |
| 43 | + [[3.42, 0.66, 0.0], [1.755862468, -1.404991433, 0.0]], |
| 44 | + [[2.92, 4.03, 0.0], [0.563706846, 1.033296141, 0.0]], |
| 45 | + [[4.228131167, -0.522007766, 0.0], [2.44972507, -1.674799065, 0.0]], |
| 46 | + [[4.228131167, -0.522007766, 0.0], [8.663865218, -1.084821998, 0.0]], |
| 47 | + [[1.755862468, -1.404991433, 0.0], [2.44972507, -1.674799065, 0.0]], |
| 48 | + [[0.563706846, 1.033296141, 0.0], [1.755862468, -1.404991433, 0.0]], |
| 49 | + [[-0.139446292, 1.191439787, 0.0], [0.008499564, 1.241560466, 0.0]], |
| 50 | + [[0.563706846, 1.033296141, 0.0], [0.008499564, 1.241560466, 0.0]], |
| 51 | + ] |
| 52 | + for act, exp in zip(lines, expected): |
| 53 | + sa, ea = act |
| 54 | + se, ee = exp |
| 55 | + # the line direction sometimes changes ... |
| 56 | + assert TOL.is_allclose(sa, se) or TOL.is_allclose(sa, ee) |
| 57 | + assert TOL.is_allclose(ea, ee) or TOL.is_allclose(ea, se) |
0 commit comments