Home Forums Nazca polygons merge from cell

Tagged: , ,

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • #7102
    Nicolas Chimot
    Participant

    Hello,

    I am trying to merge some polygons from a cell (firstly with a single layer). I started with a simple case with only 2 rectangles. Please find below the code :

    #######################
    import nazca as nd
    from collections import defaultdict
    import nazca.mask_layers as msk
    
    msk.add_layer(name='layer1',layer=1,overwrite = True)
    # msk.add_layer(name='layer2',layer=2,overwrite = True)
    
    with nd.Cell() as cellule:
    nd.strt(length=20,layer = 'layer1').put(0,0,0)
    nd.strt(length=10,layer = 'layer1').put(0,-0.25,90)
    # nd.strt(length=10,layer = 'layer1').put(15,4,90)
    # nd.strt(length=5, layer = 'layer1').put(0,0,90)
    """
    CASE 1
    """
    def merge_cell_polygons_MERGE(cell):
    layerpgons = defaultdict(list)
    for P in nd.cell_iter(cellule, flat=True):
    if P.cell_start:
    for pgon, xy, bbox in P.iters['polygon']:
    layerpgons[pgon.layer].append(xy)
    with nd.Cell() as C:
    for layer, pgons in layerpgons.items():
    merge = nd.clipper.merge_polygons(pgons)
    for ii in range(len(merge)):
    nd.Polygon(points = merge[ii], layer = layer).put()
    
    return C
    merge_cell_polygons_MERGE(cellule).put()
    
    # """
    # CASE 2
    # """
    # def merge_cell_polygons_OR(cell):
    #     layerpgons = defaultdict(list)
    #     for P in nd.cell_iter(cellule, flat=True):
    #         if P.cell_start:
    #             for pgon, xy, bbox in P.iters['polygon']:
    #                 layerpgons[pgon.layer].append(xy)
    #     with nd.Cell() as C:
    #         for layer, pgons in layerpgons.items():
    #             merge = nd.clipper.polygons_OR(pgons)
    #         for ii in range(len(merge)):
    #             nd.Polygon(points = merge[ii], layer = layer).put()
    
    #     return C
    # merge_cell_polygons_OR(cellule).put()
    
    nd.export_gds(filename = 'trial.gds')
    
    ########################

    I tried with case 1 : “merge_polygons” or case 2 : “polygons_OR” methods.

    Whatever which case is tried, as long as the second rectangle is put this way : nd.strt(length=10,layer = ‘layer1’).put(0,-0.25,90), the merge operation is fine :

    However, again, whatever which case is tried, when the second rectangle is shifted “inside” the first rectangle for instance by 10µm : nd.strt(length=10,layer = ‘layer1’).put(10,-0.25,90), the merge operation is not fine :

    Could you please help ?

    Best regards

    Nicolas

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.