Exemple #1
0
 def _gen_box_list(self, spu_ids=None):
     raw_box_list = self.data["boxes"]
     box_map_list = []
     for raw_box in raw_box_list:
         if spu_ids is not None and raw_box['spuBoxId'] not in spu_ids:
             continue
         box = {}
         box['box_id'] = raw_box['spuBoxId']
         box['box_type'] = ""
         box['length'] = raw_box['length']
         box['width'] = raw_box['width']
         box['height'] = raw_box['height']
         box['weight'] = raw_box['weight']
         box['all_directions'] = [0, 1]
         box['box_num'] = 1
         if 'platformCode' in raw_box:
             box['platform'] = raw_box['platformCode']
         else:
             box['platform'] = 'same'
         box['max_layer'] = sys.maxsize
         box['max_weight'] = float('inf')
         box['is_cylinder'] = False
         box_map_list.append(box)
     box_list = []
     for box in box_map_list:
         box_list.append(AlgorithmBox(**box))
     return box_list
Exemple #2
0
def assign_rectangle_box_in_block(space, block, packed_bin):
    """
        将块放入空间中
        :param space: 放入的空间
        :param block: 需要放入的块
        :param packed_bin: 放入的容器
    """
    lx, ly, lz = block.item_size
    base_x, base_y, base_z = space.min_coord
    order = packed_bin.order
    paceked_box_list = block.packed_box_list
    i = 0
    for num_z in range(block.nz):
        for num_x in range(block.nx):
            for num_y in range(block.ny):
                box = paceked_box_list[i]
                i += 1
                order += 1
                direction = utils.get_box_direction(box.length, box.width,
                                                    box.height, lx, ly, lz)
                copy_box = AlgorithmBox.copy_algorithm_box(box, 1)
                packed_box = PackedBox(base_x + num_x * lx,
                                       base_y + num_y * ly,
                                       base_z + num_z * lz, lx, ly, lz, box,
                                       order, direction, 0)
                if packed_bin.packed_box_list:
                    packed_bin.packed_box_list.append(packed_box)
                    packed_bin.box_list.append(copy_box)
                else:
                    packed_bin.packed_box_list = [packed_box]
                    packed_bin.box_list = [copy_box]
    packed_bin.order = order
    packed_bin.load_volume += block.vol
    packed_bin.load_weight += block.weight
    packed_bin.load_amount += block.amount
Exemple #3
0
 def _gen_box_list(self):
     raw_box_listdict = self.data["boxes"]
     box_list = []
     for raw_box in raw_box_listdict:
         box = {}
         box['box_id'] = raw_box['spuBoxId']
         box['box_type'] = ""
         box['length'] = raw_box['length']
         box['width'] = raw_box['width']
         box['height'] = raw_box['height']
         box['weight'] = raw_box['weight']
         box['all_directions'] = [0, 1]
         box['box_num'] = 1
         if 'platformCode' in raw_box:
             box['platform'] = raw_box['platformCode']
         else:
             box['platform'] = 'same'
         box['max_layer'] = sys.maxsize
         box['max_weight'] = float('inf')
         # box['volume'] = raw_box['length']*raw_box['width']*raw_box['height']
         box['is_cylinder'] = False
         box_list.append(box)
     box_listAlgorithmBox = []
     for box in box_list:
         box_listAlgorithmBox.append(AlgorithmBox(**box))
     return box_listAlgorithmBox
Exemple #4
0
def assign_box_2_bin(box, space, packed_bin, box_direction):
    """
        将箱子放置到容器中
        :param box: the box that has been packed
        :param space: the space packs the box
        :param packed_bin: the bin packs the box
        :param box_direction: 箱子的摆放方向
    """
    packed_bin.order += 1
    lx, ly, lz = utils.choose_box_direction_len(box.length, box.width,
                                                box.height, box_direction)
    packed_box = PackedBox(*space.min_coord, lx, ly, lz, box, packed_bin.order,
                           box_direction, 0)
    copy_box = AlgorithmBox.copy_algorithm_box(box, 1)
    if packed_bin.packed_box_list:
        packed_bin.packed_box_list.append(packed_box)
        packed_bin.box_list.append(copy_box)
    else:
        packed_bin.packed_box_list = [packed_box]
        packed_bin.box_list = [copy_box]
    packed_bin.load_volume += lx * ly * lz
    packed_bin.load_weight += box.weight
    packed_bin.load_amount += box.amount