예제 #1
0
def test_empty_packer():
    packer = bp.Packer()
    assert packer.get_capacity() == 0.0
    assert packer.get_total_volume() == 0.0
    assert packer.get_total_weight() == 0.0
    assert packer.get_fill_ratio() == 0.0
    assert len(packer.unfitted_items) == 0
예제 #2
0
def test_single_bin_single_item():

    packer = bp.Packer()
    box = packer.add_bin("B0", 1, 1, 1)
    packer.add_item("I0", 1, 1, 1, 1)
    packer.pack()
    assert len(box.items) == 1
    assert len(packer.unfitted_items) == 0
예제 #3
0
def test_single_bin_multiple_items(w, h, d):
    packer = bp.Packer()
    box = packer.add_bin("B0", w, h, d)
    for index in range(max(w, h, d)):
        packer.add_item(f"I{index}", 1, 1, 1, 1)
    packer.pack()
    assert len(box.items) == 3
    assert len(packer.unfitted_items) == 0
예제 #4
0
def test_single_bin_different_sized_items():
    packer = bp.Packer()
    box = packer.add_bin("B0", 3, 3, 1)
    packer.add_item("I0", 1, 1, 1, 1)
    packer.add_item("I1", 2, 1, 1, 1)
    packer.add_item("I2", 3, 1, 1, 1)
    packer.pack()
    assert len(box.items) == 3
    assert len(packer.unfitted_items) == 0
예제 #5
0
def build_packer():
    packer = bp.Packer()
    packer.add_item("50g [powder 1]", 3.9370, 1.9685, 1.9685, 1)
    packer.add_item("50g [powder 2]", 3.9370, 1.9685, 1.9685, 2)
    packer.add_item("50g [powder 3]", 3.9370, 1.9685, 1.9685, 3)
    packer.add_item("250g [powder 4]", 7.8740, 3.9370, 1.9685, 4)
    packer.add_item("250g [powder 5]", 7.8740, 3.9370, 1.9685, 5)
    packer.add_item("250g [powder 6]", 7.8740, 3.9370, 1.9685, 6)
    packer.add_item("250g [powder 7]", 7.8740, 3.9370, 1.9685, 7)
    packer.add_item("250g [powder 8]", 7.8740, 3.9370, 1.9685, 8)
    packer.add_item("250g [powder 9]", 7.8740, 3.9370, 1.9685, 9)
    return packer
예제 #6
0
def make_3d_packer(items) -> bp.Packer:
    packer = bp.Packer()
    for index, (w, h, d) in enumerate(items):
        packer.add_item(str(index), w, h, d)
    return packer