Forum Replies Created

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • in reply to: Image import: concentric shapes #6812
    Wiebke Jahr
    Participant

    SOLVED:

    issue is with transparencies in the .png, not with inversion of white / black. The “white background” was in fact transparent.

    in reply to: Image import: concentric shapes #6810
    Wiebke Jahr
    Participant

    Dear Xaveer,

    As you’ve seen from the registration mail, I had previously tried with pyclipper installed, but then uninstalled it when I ran into the bug. I’m pasting the original question from my email here, so anyone who runs into the issue the info also in the forum.

     

     

    I’m trying to convert an image to gds. Without pyclipper installed, conversion completes, but the gds file is missing some of the structures. With pyclipper installed, I get the following error message:

    nz.image(fn+”.png”,
    4                         size = 8992, pixelsize = 2.7, threshold = 0.5,
    5                         cellname = ‘SP’).put()

    File ~\Anaconda3\envs\nazca\lib\site-packages\nazca\bb_util.py:1622, in image(name, layer, size, pixelsize, threshold, cellname, invert, align, box_layer, box_buf)
    1620         xy = [(x0, y0), (x1, y0), (x1, y0 – p), (x0, y0 – p)]
    1621         polygons.append(xy)
    -> 1622 for pol in nd.clipper.merge_polygons(polygons):
    1623     nd.Polygon(points=pol, layer=layer).put()
    1625 if box_layer is not None:

    File ~\Anaconda3\envs\nazca\lib\site-packages\nazca\clipper.py:269, in merge_polygons(paths, accuracy)
    267 clipper.AddPaths(st(paths, sc), pc.PT_SUBJECT, True)
    268 mp = clipper.Execute(pc.CT_UNION, pc.PFT_NONZERO, pc.PFT_NONZERO)
    –> 269 mp = _clipper2GDS(mp)
    270 for p in rev:
    271     p.reverse()

    File ~\Anaconda3\envs\nazca\lib\site-packages\nazca\clipper.py:230, in _clipper2GDS(clipper_result)
    227 for i, pi in enumerate(inner):  # Remove each hole from the outer polygon
    228     if i in todo and pc.PointInPolygon(pi[0], po):
    229         # Subtract with tether.
    –> 230         po = _subtract_polygon(po, pi)
    231         todo.remove(i)
    232 result.append(po)

    File ~\Anaconda3\envs\nazca\lib\site-packages\nazca\clipper.py:186, in _subtract_polygon(XYo, XYi)
    184     xo, yo = x, y
    185 # Construct polygon
    –> 186 poly = XYo[0:ndxo] + [point] + XYi[ndxi:] + XYi[0:ndxi + 1] + [point] + XYo[ndxo:]
    187 return poly

    UnboundLocalError: local variable ‘ndxo’ referenced before assignment

     

    I checked the source code, and it seems it never jumps into the if-condition starting at line 180? I have two concentric circles in the design, the smaller one white, the larger one black, could they be causing the issue

     

     

        for i, (x, y) in enumerate(XYo[1:]):
    # print(f”{i} -> {i+1}: {(xo, yo)} -> {x, y}”)
    if yo >= yp and y <= yp and (xo < xp or x < xp):
    # Line segment intersecting with horizontal.
    # Calculate distance to intersection point
    xi = _x_intersect((xo, yo), (x, y), yp)
    d = xp – xi
    if d > 0 and d < dmin:
    dmin = d
    ndxo = i + 1
    point = (xi, yp)
    xo, yo = x, y
    # Construct polygon
    poly = XYo[0:ndxo] + [point] + XYi[ndxi:] + XYi[0:ndxi + 1] + [point] + XYo[ndxo:]
    return poly

     

    I then tried with the new version of Nazca you sent via email and re-installed pyclipper. Indeed, the error message is gone now and conversion completes. However, the behaviour is unchanged: in the white background / black outer circle / white inner circle, only the inner circle is shown, whereas for the inverted blac background / white outer circle / black inner circle, all structures are converted.

    I am now working around the problem by first inverting the .png image, and then using

    nz.image(fn+”.png”, invert=True).put()

    which works for my immediate problem.

    Thank you!

    • This reply was modified 2 months, 1 week ago by Wiebke Jahr.
Viewing 2 posts - 1 through 2 (of 2 total)