Esempio n. 1
0
def test_split_edges_diamond():

    shape = [Point(8, 4), Point(12, 12), Point(8, 20), Point(4, 12)]
    shapes = [shape]
    sf = ShapeFiller(shapes)

    assert (sf.split_edge_endpoints(Point(0, 0), Point(16,
                                                       0)) == [Point(16, 0)])
    assert (sf.split_edge_endpoints(Point(0, 4),
                                    Point(16,
                                          4)) == [Point(8, 4),
                                                  Point(16, 4)])
    assert (sf.split_edge_endpoints(Point(0, 6), Point(
        16, 6)) == [Point(7, 6), Point(9, 6),
                    Point(16, 6)])
    assert (sf.split_edge_endpoints(Point(0, 8), Point(
        16, 8)) == [Point(6, 8), Point(10, 8),
                    Point(16, 8)])
    assert (sf.split_edge_endpoints(Point(0, 12), Point(
        16, 12)) == [Point(4, 12), Point(12, 12),
                     Point(16, 12)])
    assert (sf.split_edge_endpoints(Point(0, 16), Point(
        16, 16)) == [Point(6, 16), Point(10, 16),
                     Point(16, 16)])
    assert (sf.split_edge_endpoints(Point(0, 18), Point(
        16, 18)) == [Point(7, 18), Point(9, 18),
                     Point(16, 18)])
    assert (sf.split_edge_endpoints(Point(0, 20), Point(
        16, 20)) == [Point(8, 20), Point(16, 20)])
    assert (sf.split_edge_endpoints(Point(0, 24),
                                    Point(16, 24)) == [Point(16, 24)])
Esempio n. 2
0
def test_split_edges_square():

    shape = [Point(1, 1), Point(1, 3), Point(3, 3), Point(3, 1)]
    shapes = [shape]
    sf = ShapeFiller(shapes)

    assert (sf.split_edge_endpoints(Point(0, 1), Point(
        4, 1)) == [Point(1, 1), Point(3, 1),
                   Point(4, 1)])
    assert (sf.split_edge_endpoints(Point(0, 2), Point(
        4, 2)) == [Point(1, 2), Point(3, 2),
                   Point(4, 2)])
    assert (sf.split_edge_endpoints(Point(0, 3), Point(
        4, 3)) == [Point(1, 3), Point(3, 3),
                   Point(4, 3)])

    assert (sf.split_edge_endpoints(Point(0, 0), Point(4, 0)) == [Point(4, 0)])
    assert (sf.split_edge_endpoints(Point(0, 4), Point(4, 4)) == [Point(4, 4)])