Ejemplo n.º 1
0
def fill_holes(obj, dx=10e3, dy=8e3, width=5e3, height=5e3, d=0):
    if (obj.is_cell_inst()):
        return None
    poly = obj.shape.polygon
    bbox = poly.bbox()
    poly_reg = Region(poly)
    t_reg = Region()

    y = bbox.p1.y + height
    while (y < bbox.p2.y - height):
        x = bbox.p1.x + width
        while (x < bbox.p2.x - width):
            box = pya.Box().from_dbox(
                pya.DBox(DPoint(x, y), DPoint(x + width, y + height)))
            x += dx
            t_reg.clear()
            t_reg.insert(box)
            qwe = t_reg.select_inside(poly_reg)
            if (qwe.is_empty()):
                continue
            edge_pairs = qwe.inside_check(poly_reg, d)
            if (edge_pairs.is_empty()):
                poly.insert_hole(box)
        y += dy
    obj.shape.polygon = poly
Ejemplo n.º 2
0
    def fill_poly(poly):
        bbox = poly.bbox()
        poly_reg = Region(poly)
        t_reg = Region()

        # Draw boundary around holes in the polygon
        for hole_i in range(0, poly.holes()):
            points = [p for p in poly.each_point_hole(hole_i)]
            points.append(points[0])
            boundary = Path(points, 2 * d)
            poly_reg -= Region(boundary)

        # Draw boundary around the outer edge of the polygon
        points = [p for p in poly.each_point_hull()]
        points.append(points[0])
        boundary = Path(points, 2 * d)
        poly_reg -= Region(boundary)

        # Fill the boundary box with holes
        y = bbox.p1.y + height
        while y < bbox.p2.y - height:
            x = bbox.p1.x + width
            while x < bbox.p2.x - width:
                box = pya.Box().from_dbox(
                    pya.DBox(DPoint(x, y), DPoint(x + width, y + height)))
                x += dx
                t_reg.insert(box)
            y += dy

        # Select only inner holes
        holes_inside = t_reg.select_inside(poly_reg)
        for box in holes_inside.each():
            poly.insert_hole(list(box.each_point_hull()))

        return poly
Ejemplo n.º 3
0
def fill_holes(cell,
               layer,
               obj,
               dx=15e3,
               dy=15e3,
               width=10e3,
               height=10e3,
               d=50e3):
    """ @brief:     Fills an object with a grid of holes
                    Warning: don't use this method for the same region twice
        @params:    cell
                    layer
                    obj
                    dx : int
                        period of a grid in horizonatal direction
                    dy : int
                        period of a grid in vertical direction
                    width : int
                        width of a hole
                    height : int
                        height of a hole
                    d : int
                        padding
    """
    if (obj.is_cell_inst()):
        return None
    poly = obj.shape.polygon
    print(poly.holes())
    bbox = poly.bbox()
    poly_reg = Region(poly)
    t_reg = Region()

    # Fill the boundary box with holes
    y = bbox.p1.y + height
    while y < bbox.p2.y - height:
        x = bbox.p1.x + width
        while x < bbox.p2.x - width:
            box = pya.Box().from_dbox(
                pya.DBox(DPoint(x, y), DPoint(x + width, y + height)))
            x += dx
            t_reg.insert(box)
        y += dy

    # Draw boundary around holes in the polygon
    for hole_i in range(0, poly.holes()):
        points = [p for p in poly.each_point_hole(hole_i)]
        points.append(points[0])
        boundary = Path(points, d)
        poly_reg -= Region(boundary)

    # Draw boundary around the outer edge of the polygon
    points = [p for p in poly.each_point_hull()]
    points.append(points[0])
    boundary = Path(points, d)
    poly_reg -= Region(boundary)

    # Select only inner holes
    qwe = t_reg.select_inside(poly_reg)

    # Subtract holes from the layer
    r_cell = Region(cell.begin_shapes_rec(layer))
    temp_i = cell.layout().layer(pya.LayerInfo(PROGRAM.LAYER1_NUM, 0))
    cell.shapes(temp_i).insert(r_cell - qwe)
    cell.layout().clear_layer(layer)
    cell.layout().move_layer(temp_i, layer)
    cell.layout().delete_layer(temp_i)