Find self-intersecting polygons

edited August 2013 in General


I have a large layout which another tool (L-Edit) tells me has self-intersecting polygons. However of course it doesn't tell me how many or where they are on the layout - so I cannot find them.

Is there a way I can select all objects on the layout and write a macro that points out any self-intersecting polygons (e.g. draws a box around them, or zooms to them, or outputs the xy coordinates)



  • edited November -1

    Hi David,

    Right now that is somewhat tedious, but the next release will contain a DRC feature which among other checks includes a "strange polygon" check that detects self-intersecting polygons.


  • edited November -1

    Aha. OK well no problem. For now I found a friend to import it into Cadence and tell me the locations.

    Looking forward to the next version too. Great program by the way!

  • edited November -1

    I am also trying to find self-intersecting polygons, and have been reading the DRC coding guidelines/definitions.

    I am not seeing a "strange polygon" check, or other function like this. Could you point out where that function is, or suggest some way to use the (excellent!) DRC scripting to find/select/mark such polygons?
  • edited November -1
    Nevermind, I found it when I realized I should search for "polygon" - I guess it's the "odd_polygon()" function!
  • edited November 2015
    I'm getting a hard-crash of KLayout when using the "odd_polygons" function.
    The DRC appears to import ('input') the layers properly, and output them, but if I run "odd_polygons" on a layer with or without self-intersecting polygons, it crashes.

    Would you like the crash report, or other info to debug it?
  • edited November -1

    Hi Demis,

    I can't confirm this for 0.24.3 at least on Ubuntu 14.

    Here is my test DRC script:

    report("odd-polygon DRC")
    inp = input(1)
    inp.odd_polygons.output("OP test")

    The test layout is a single path folding back onto itself. As expected, the odd_polygon check reports the area where the path intersects with itself.

    Could you give some more details about how to reproduce the problem (OS, version, script used, error message or crash dump shown)? Ideally you may send a small testcase by mail.



  • edited November 2015
    Thanks Matthias,
    The report method is useful - i was outputting it to a layout. I'll give that a shot first. However even when i commented out the `output` command it would crash - by commenting out everything else, it seemed that it was the `odd_polygons` function itself.

    There was no error message upon crashing - Klayout just vanishes entirely and I have to reopen it.
    This is on Mac OS 10.11

    I'll email you with the details.
  • edited November -1
    Ah, updating to 0.24.3 fixed it! Great suggestion, sorry I didn't try that before posting.
  • edited November -1

    Great. But this was not my achievement. There is an active community taking care of MacOS!

    Thanks to all of you, by the way. Specifically to Kazzz!


Sign In or Register to comment.