Pastebin

Paste #2243: stack

< previous paste - next paste>

Pasted by Helene

Download View as text

# Stack Ceiling Algorithm
def stack_ceiling(strip_width, items):
    items.sort(key=lambda item: (item.height, item.width),reverse=True)
    levels = []
    strip_height = 0
    while len(items) > 0:
        #print '- New level -'
        #when this while loop is reached again the current level should be fully packed
        
        strip_height += items[0].height
        level = Level(strip_width, items[0].height)
        # items are packed at the buttom of the level, therefore extra=False
        packed_level = FFDH_single_level(level, items, False)
        info( 'level to be filled')
        show_level(packed_level)
        info('---')
        
        levels.append(packed_level)
        
        for item in packed_level.items:
            items.remove(item)  
        
        level_is_filled = False
        
        placement = placement_of_item(packed_level,items)
        if placement == None:
            level_is_filled = True
        else:
            placed_item = placement[0]
            left_rectangles  = placement[1]
            down_rectangles  = placement[2]
        
            items.remove(placed_item)
        
        

New Paste


Do not write anything in this field if you're a human.

Go to most recent paste.