Ejemplo n.º 1
0
    def testBadPlacment(self):
        self.store.placed_boxes = [Box((0, 0, 1, 1)), Box((2, 2, 1, 1))]

        self.assertFalse(self.store.checkPlacementConditions(Box(
            (0, 1, 1, 1))))
        self.assertFalse(
            self.store.checkPlacementConditions(Box((0, -2, 1, 1))))
Ejemplo n.º 2
0
 def testTopBox(self):
     self.store.placed_boxes = [
         Box((5, 0, 1, 1)),
         Box((11, 3, 2, 4)),
         Box((5, 0, 2, 1))
     ]
     top_box = self.store.getTopBox()
     self.assertTrue(top_box == Box((11, 3, 2, 4)))
Ejemplo n.º 3
0
 def testSimplePlaceBoxesBottomLeftFit(self):
     self.store.placeBoxesBottomLeftFit(
         [Box((0, 0, 1, 1)),
          Box((0, 0, 1, 1)),
          Box((0, 0, 1, 1))])
     expected = [(0, 0, 1, 1), (2, 0, 1, 1), (4, 0, 1, 1)]
     self.assertCountEqual(
         expected, [box.getTuple() for box in self.store.placed_boxes])
Ejemplo n.º 4
0
 def testMoveToLeftIfPosibleButStopOnOtherBox(self):
     self.store.placed_boxes = [Box((0, 0, 3, 3)), Box((4, 0, 2, 2))]
     self.store.holes = [
         (7, 0),
     ]
     self.store.placeBoxesBottomLeftFit([Box((0, 0, 1, 3))])
     expected = [(9, 0), (4, 4), (7, 4)]
     self.assertCountEqual(expected, [hole for hole in self.store.holes])
Ejemplo n.º 5
0
 def testMoveToLeftIfPosible(self):
     self.store.placed_boxes = [Box((0, 0, 3, 3))]
     self.store.holes = [
         (4, 0),
     ]
     self.store.placeBoxesBottomLeftFit([Box((0, 0, 4, 4))])
     expected = [(9, 0), (0, 5), (4, 5)]
     self.assertCountEqual(expected, [hole for hole in self.store.holes])
Ejemplo n.º 6
0
 def testSimplePlaceBoxBottomLeftFit(self):
     self.store.width = 6
     self.store.placed_boxes = [
         Box((4, 0, 1, 1)),
     ]
     self.store.holes = [(0, 0), (4, 2), (6, 0)]
     self.store.placeBoxBottomLeftFit(self.box)
     self.store.placed_boxes.append(self.box)
     self.assertEqual(self.box.position, (0, 2))
Ejemplo n.º 7
0
    def testBoxIntersect(self):
        boxes = [Box((0, 0, 1, 1)), Box((1, 1, 1, 1))]
        self.assertTrue(self.store.checkIntersection(boxes[0], boxes[1]))

        boxes = [Box((0, 0, 1, 1)), Box((0.5, 0.5, 1, 1))]
        self.assertTrue(self.store.checkIntersection(boxes[0], boxes[1]))

        boxes = [Box((2, 2, 1, 1)), Box((1, 1, 1, 1))]
        self.assertTrue(self.store.checkIntersection(boxes[0], boxes[1]))
Ejemplo n.º 8
0
    def testBoxNotIntersect(self):
        boxes = [Box((0, 0, 1, 1)), Box((2, 2, 1, 1))]
        self.assertFalse(self.store.checkIntersection(boxes[0], boxes[1]))

        boxes = [Box((2, 0, 1, 1)), Box((2, 2, 1, 1))]
        self.assertFalse(self.store.checkIntersection(boxes[0], boxes[1]))

        boxes = [Box((0, 0, 4, 1)), Box((2, 2, 1, 1))]
        self.assertFalse(self.store.checkIntersection(boxes[0], boxes[1]))
Ejemplo n.º 9
0
import matplotlib.path as mpath
import matplotlib.patches as mpatches
import matplotlib.pyplot as plt
import numpy as np

from utils import removeNotNeededHoles
from store import Box, Store

boxes_test = [Box((0, 0, 1, 1)), Box((2, 2, 1, 1))]


# rysuje obok siebie magazyny z listy
def showResults(store_list=[Store(width=10, height=10, boxes=boxes_test)]):
    fig, ax = plt.subplots()
    Path = mpath.Path

    # store_bottom_left_corner
    c = 0

    for store in store_list:
        # draw store
        store_path = path_data = [
            (Path.MOVETO, (0 + c, store.height)),
            (Path.LINETO, (0 + c, 0)),
            (Path.LINETO, (store.width + c, 0)),
            (Path.CLOSEPOLY, (store.width + c, store.height)),
        ]
        codes, verts = zip(*path_data)
        path = mpath.Path(verts, codes)
        x, y = zip(*path.vertices)
        line, = ax.plot(x, y)
Ejemplo n.º 10
0
 def testPlacment(self):
     self.store.placed_boxes = [Box((0, 0, 1, 1)), Box((2, 2, 1, 1))]
     self.assertTrue(self.store.checkPlacementConditions(Box((0, 2, 1, 1))))
Ejemplo n.º 11
0
 def setUp(self):
     self.boxes = boxes_test
     self.box = Box((0, 0, 4, 2))
     # domyslnie d = 1
     self.store = Store()
     self.store.optimaze = True