コード例 #1
0
ファイル: test_node.py プロジェクト: gregersn/gsnlib
def test_some_node_stuff_2():
    n = Node()
    segments = [
        Segment([Vector(-15.0, -30.0), Vector(-30, -30)]),
        Segment([Vector(-10, -30), Vector(-15.0, -30.0)]),
        Segment([Vector(-10.0, -15.0), Vector(-10, -30)]),
        Segment([Vector(-30, -10), Vector(-15.0, -10.0)]),
        Segment([Vector(-30, -30), Vector(-30, -10)])
    ]

    n.build(segments.copy())
コード例 #2
0
ファイル: test_node.py プロジェクト: gregersn/gsnlib
def test_some_node_stuff():
    n = Node()
    segments = [
        Segment([Vector(-15, -30), Vector(-30, -30)]),
        Segment([Vector(-10, -30), Vector(-15, -30)]),
        Segment([Vector(-10, -15), Vector(-10, -30)]),
        Segment([Vector(-30, -10), Vector(-15, -10)]),
        Segment([Vector(-30, -30), Vector(-30, -10)])
    ]

    n.build(segments)
コード例 #3
0
ファイル: test_node.py プロジェクト: gregersn/gsnlib
def test_node_clone():
    segments = [
        Segment([Vector(0, 0), Vector(0, 10)]),
        Segment([Vector(0, 10), Vector(10, 10)]),
        Segment([Vector(10, 10), Vector(0, 0)])
    ]
    n = Node(segments)

    m = n.clone()

    assert m == n
    assert m is not n
コード例 #4
0
ファイル: test_node.py プロジェクト: gregersn/gsnlib
def test_init_node_2():
    segments = [
        Segment([Vector(0, 0), Vector(0, 10)]),
        Segment([Vector(0, 10), Vector(10, 10)]),
        Segment([Vector(10, 10), Vector(0, 0)])
    ]
    n = Node()
    n.build(segments)
    assert n is not None

    assert len(n.segments) == 1
    assert n.line == Segment([Vector(0, 0), Vector(0, 10)]).line
    assert not n.right
    assert n.left
コード例 #5
0
ファイル: test_node.py プロジェクト: gregersn/gsnlib
def test_node_invert():
    segments = [
        Segment([Vector(0, 0), Vector(0, 10)]),
        Segment([Vector(0, 10), Vector(10, 10)]),
        Segment([Vector(10, 10), Vector(0, 0)])
    ]
    n = Node(segments)
    n.invert()

    assert n is not None

    assert len(n.segments) == 1
    assert n.line == Segment([Vector(0, 0), Vector(0, -10)]).line
    assert n.right
    assert not n.left
コード例 #6
0
ファイル: test_union.py プロジェクト: gregersn/gsnlib
def test_manual_union():
    poly_a = CSG.from_polygons([[
        [0, 0],
        [15, 0],
        [15, 15],
        [0, 15]
        ]])

    poly_b = CSG.from_polygons([[
        [30, 30],
        [10, 30],
        [10, 10],
        [30, 10]
        ]])

    a = Node(poly_a.clone().segments)
    assert len(a.all_segments()) == 4

    b = Node(poly_b.clone().segments)
    assert len(a.all_segments()) == 4

    a.invert()
    assert len(a.all_segments()) == 4
    b.clip_to(a)
    assert len(b.all_segments()) == 5
    b.invert()
    assert len(b.all_segments()) == 5
    a.clip_to(b)
    a_all_segments = a.all_segments()
    assert len(a.all_segments()) == 5
    b.clip_to(a)
    b_all_segments = b.all_segments()
    assert len(b.all_segments()) == 5

    segs = b.all_segments()
    assert len(segs) == 5

    a.build(segs)
    a_all_segments = a.all_segments()
    assert len(a.all_segments()) == 10

    a.invert()
    a_all_segments = a.all_segments()
    assert len(a.all_segments()) == 10