Polygon => Box: add switch?

edited July 2012 in KLayout Development
Hello Matthias,
In GDS2ReaderBase::read_boundary, I see that a rectangular Boundary is always converted into a Box.
This saves some space, but if I want to check a GDS file, i'd prefer to have a one-on-one map between KLayout types and GDSII types.
Would it be possible to add a configuration switch to turn this conversion on or off?


  • edited November -1
    Btw: while you support reading GDSII Box elements, it seems that all boxes (the ones that were a Box in GDSII and those that were converted from Boundary elements) are written to a boundary in GDS2WriterBase. Correct?
  • edited August 2012


    there is some confusion about BOX records in GDS. The original GDS specification considered BOX records not to be necessarily rectangles, but instead BOX objects where some kind of "hollow" polygon. I think the original intention was to provide some way to draw a marking boundary without a fill. Hence such an object would not appear on a mask.

    Some tools however used take the BOX literally and uses these records for "filled" rectangles. Today, BOX records are usually deprecated because of their potentially misleading interpretation.

    KLayout like many other tools supports both the "hollow" and "filled" interpretation in the reader, hence there is a switch. Since KLayout does not have "hollow objects", BOX objects can either be ignored or read as "filled" objects. They can also be converted to polygons (allowing different shapes than rectangles) or treated as errors.

    To make the matter even more confusing, KLayout also features boxes, but in the sense of special (more efficient) polygons. When writing boxes, they are converted to BOUNDARY objects, because that is the only reliable representation of a "filled" object in GDS. When reading, BOUNDARY objects that form a rectangle are converted to boxes internally.

    When editing, boxes behave slightly different than polygons, for example, when moving a corner or when editing the properties. But beside that you won't notice much differences between polygons and boxes.

    Best regards,


  • Hello,
    Is there a python way to root out (detect) BOX RECORDS?

Sign In or Register to comment.