Home Forums Nazca Polygon clipping with interconnects

This topic contains 4 replies, has 2 voices, and was last updated by  weiming 2 months, 1 week ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #5463

    weiming
    Participant

    Dear Nazca team,

    I would like to substract layers from one interconnect from layers of another interconnect object and was wondering if this can be done with the nazca clipper module.

    As an example, I have interconnect1 define a bend in xsection1 with layer 1, layer 2. I have another straight defined as interconnect in xsection 2, with layer 3, layer 4. I would like to draw the bend with layer 1 but substracted from layer 3 of the straight.

    If I can get the polygons of specific layers from an interconnect object, that would maybe work?

    Thanks for the support!

     

    #5470

    Ronald
    Keymaster

    Dear Weiming,

    That should work, taking into account the remarks as described in the post

    Polygon subtraction function

    To access the polygons note that e.g. an interconnect is a Nazca Cell object that stores Polygon objects in it under self.polygons. In the Polygon object you find the attributes self.points and self.layer.

    Ronald

    #5471

    weiming
    Participant

    Dear Ronald,

    thanks for the reference to the other post. I am still struggling with getting the actual polygons from an interconnect object. In below example, only obj0 has a polygons property, although it is empty.

    
    import nazca as nd
    import nazca.interconnects as IC
    
    ic1 = IC.Interconnect(width=2.0, radius=20)
    ic2 = IC.Interconnect(width=1.0, radius=50)
    
    #use the interconnect objects to create layout:
    obj1 = ic1.strt(length=10).put(0)
    obj2 = ic1.bend(angle=45).put()
    obj0 = ic1.strt(length=10)
    obj3 = ic2.strt(length=20).put(20)
    obj4 = ic2.bend(angle=45).put()
    
    nd.export_gds(filename='testing.gds', clear=True)
    • This reply was modified 2 months, 2 weeks ago by  weiming.
    #5473

    Ronald
    Keymaster

    Dear Weiming,

    Your question needs a slightly more elaborate answer in case of reading polygons from interconnects. Take the following example based on your code:

    import nazca as nd
    
    ic1 = nd.interconnects.Interconnect(width=2.0, radius=20)
    bend_instance = ic1.bend(angle=45).put()
    print(bend_instance.cnode.cell.polygons)
    
    # prints an empty list: []

    The polygons you are after seem at first sight to be located in the ‘polygons’ attribute of the cell that the bend instance (here named ‘bend_instance’) is based on. To get to the cell object we have to look it up via the cnode (the “cell master node”) that is stored in the instance: bend_instance.cnode.cell. However, there are no Polygon objects there (capital P to denote it is a class), i.e. the polygon attribute is an empty list of Polygons: [].

    The catch is that the polygon that describes the bend geometry actually resides in a cell two levels deeper in the Nazca tree, but this is simplified in the gds export.

    Your easy way out is the ‘cell_iter’ method. The following example prints all the polygon points [(x1, y1), (x2, y2), …] in instance ‘bend_instance’ regardless of the level.

    cell_iter = nd.cell_iter(bend_instance)
    for params in cell_iter:
        if params.cell_start:
            for pgon, points, bbox in params.iters['polygon']:
                print(points)

    Actually, the Polygon object ‘pgon’ by itself already contains all polygon information, including the points, bounding box and layer information. Try replacing ‘print(points)’ by the line below to see how that works

    print(f"layer: '{pgon.layer}'\npoints: {pgon.points}\n")

    Ronald

    #5474

    weiming
    Participant

    Dear Ronald,

    thanks for the detailed example. With that, I managed to obtain the polygon information. However, I could not manage to perform the boolean substration using the pyclipper module and had to use the point addition/substration as suggested in the other thread. This is not the optimum solution for me but does the job for now.

    Many thanks!

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.