def perform_thinning(self): print print 'sorting {0} points into layers'.format(len(self.points)) distances = self.get_sorted_points() if 0 in distances: # there are walls in it for point in distances[0]: del self.points[tuple(point[Block.POSITION])] del distances[0] total_points = len(self.points) print 'thinning {0} points'.format(total_points) print for distance in sorted(distances.keys()): layer = distances[distance] self.thin_layer(layer) #self.image.save('thin-' + str(distance) + '.png') #raw_input() for position in self.unremoved: Block.mark_final(self.points[position]) print 'Thinning finished with {0} points left out of {1}'.format(len(self.unremoved), total_points)
def perform_thinning(self): print print 'sorting {0} points into layers'.format(len(self.points)) distances = self.get_sorted_points() if 0 in distances: # there are walls in it for point in distances[0]: del self.points[tuple(point[Block.POSITION])] del distances[0] total_points = len(self.points) print 'thinning {0} points'.format(total_points) print for distance in sorted(distances.keys()): layer = distances[distance] self.thin_layer(layer) #self.image.save('thin-' + str(distance) + '.png') #raw_input() for position in self.unremoved: Block.mark_final(self.points[position]) print 'Thinning finished with {0} points left out of {1}'.format( len(self.unremoved), total_points)
def update_file(self, fid, status): fileobj = self.file_table[fid] fileobj.block_list = status["block_list"] fileobj.block_list = list( map( lambda b: Block( self.config["block_size"], b["length"], bid=b["bid"]), status["block_list"])) fileobj.adjust()
def load_blockpack(blockpack_name: str) -> set: blocks_ = set() block_list = load(open('rules/' + blockpack_name + '/blocks.json', 'r')) for block_name, data in block_list.items(): if block_name == 'import': for new_blockpack in data: blocks_ = blocks_.union(load_blockpack(new_blockpack)) continue blocks_.add(Block(block_name, **data)) log(0, block_name, 'block registered') return blocks_
def request_new_block(self, fid) -> dict: fileobj = self.file_table[fid] new_bid = self.block_id_manager.request_id() newblock = Block(self.config["block_size"], bid=new_bid) bid = newblock.bid fileobj.block_list.append(newblock) fileobj.adjust() max_replicas = min(self.config["num_replicas"], len(self.datanode_table)) datanodes = sample(self.datanode_table, max_replicas) self.block_to_datanode[bid] = datanodes return { "success": True, "message": { "block": newblock.blockinfo(), "datanodes": datanodes } }
def __init__(self, chunks): points = {} self.chunks = chunks for (cx, cy), chunk in chunks.items(): extended_blocks = chunk.extended_blocks for block in extended_blocks.flat: if Block.is_air(block) and block[Block.VISITED]: distance_from_wall = block[Block.DISTANCE_FROM_WALL] x, y, z = block[Block.POSITION] points[(x, y, z)] = block block[Block.VISITED] = False ProgressiveDistanceThinner.__init__(self, points)