Exemplo n.º 1
0
def load_file_and_average():
    logging.info("Opening DCEL pickle")
    the_dcel = DCEL.loadfile(DCEL_PICKLE)

    #Select a number of faces to fill:
    if len(the_dcel.faces) > 0:
        NUM_OF_FACES = min(VORONOI_SIZE, 10)
        aface = choice(list(the_dcel.faces), NUM_OF_FACES)

        for x in aface:
            x.data = {FaceE.FILL: True}

    #Draw
    if DRAW_FINAL:
        logging.info("Drawing final diagram")
        utils.drawing.clear_canvas(ctx, bbox=bbox)
        utils.dcel.drawing.drawDCEL(ctx, the_dcel)
        utils.drawing.write_to_png(surface, "{}__FINAL".format(savePath))
Exemplo n.º 2
0
            if isOrigin:
                #origin is closer, replace the twin
                he.addVertex(orig1)
                he.addVertex(newVert)
            else:
                #twin is closer, replace the origin
                he.addVertex(newVert)
                he.addVertex(orig2)
            modified_edges.append(he)

    #todo: fixup faces
    dcel.complete_faces()


if __name__ == "__main__":
    the_dcel = DCEL.loadfile(DCEL_PICKLE)
    the_dcel.verify_faces_and_edges()
    #Pre MOD
    utils.drawing.clear_canvas(ctx, colour=[0, 0, 0, 1])
    utils.dcel.dcel_drawing.drawDCEL(ctx, the_dcel, edges=True, faces=False)
    ctx.set_source_rgba(0, 1, 0, 1)
    ctx.set_line_width(0.002)
    utils.drawing.drawCircle(ctx, 0.5, 0.5, RADIUS, fill=False)
    utils.drawing.write_to_png(surface, save_string_unmod)
    #Post MOD
    utils.drawing.clear_canvas(ctx, colour=[0, 0, 0, 1])
    utils.dcel.dcel_drawing.drawDCEL(ctx,
                                     the_dcel,
                                     edges=False,
                                     faces=True,
                                     verts=True)