separate the donuts shape to 4 pieces of rectangle

Hi Matthias,
I'm wondering if I can separate the donuts shape (A) to 4 pieces of rectangle (B) ?

BG,
KM

Comments

  • You could cut (subtract) along the inner vertical edges and
    stretch (Partial) to re-butt the ends of the horizontal edges?
    At least that's how I'd do it, by hand knowing only what I know.

    If your question was how to script it, I got nuthin'.

  • Hi Dick, Thanks for your feedback, if I do it by hand, I'll use your method.
    Yes, my question is how to do it by python script.
    Anyway, really appreciate your comment. Thanks.

  • Hi kmho,

    the method you're looking for is "Polygon#decompose_trapezoids". It will give you a set of smaller (4 corners max) polygons from a bigger one.

    Regards,

    Matthias

  • Thanks Matthias. It's exactly what I'm need.

  • I have tried to use this decompose_trapezoids method, but my syntax is no good in my LVS file :

    POLY = polygons(1,0)
    ACTIVE = polygons(2,0)
    Gates = POLY & ACTIVE
    Gates_as_quadrilaters = Gates.decompose_trapezoids
    

    There is probably something missing between Gates and decompose_trapezoids ?
    Regards,
    Laurent

  • Hi Laurent,

    "decompose_trapezoids" is not available as a DRC or LVS function (yet). It is a method the of "Region" class.

    But there is a workaround: every DRC or LVS layer has a member called "data" which is the internal "Region" object. Here is how you can use "decompose_trapezoids":

    decomposed = layer.data.decompose_trapezoids_to_region
    

    "decomposed" is a "Region" object, not a DRC layer. If you want a DRC layer, you can use:

    decomposed = layer.dup
    decomposed.data = layer.data.decompose_trapezoids_to_region
    

    There is a related discussion on this: https://www.klayout.de/forum/discussion/1827

    As discussed in our other thread, you can also use"delaunay" instead of "decompose_trapezoids" which gives a constrained Delaunay triangulation avoiding skinny shapes for example.

    Best regards,

    Matthias

Sign In or Register to comment.