# Sizing a box by negative numbers

edited August 2016 in General
Whenever I size a box with a negative number (ie try to shrink it), it gets square mickey-mouse ears at each corner. Is there a way to avoid this? Any help is greatly appreciated. Thanks.

• edited November -1

Hi jakub,

If the problem still exists, I'd ask you to send a simple test case (GDS file with a description how to reproduce the bug) to the mail address on the contact page. The effect you describe is pretty strange. Box sizing is something very straightforward so the only way you can produce such an effect are small features at the corners or duplicate points.

Regards,

Matthias

• edited November -1
Hi Matthias,
Sorry for the delay, we made our scripts to only add size. However we are rewriting them this year and still have the same issue. This is my code:

layout.dbu = 0.001
\$dbu = layout.dbu

p = RBA::Polygon::new(RBA::Box::new((0)*(1.0 / \$dbu) , (-10)*(1.0 / \$dbu), (10)*(1.0 / \$dbu),(10)*(1.0 / \$dbu)))
#cellmain.shapes(layer_MEM).insert(p)
p2 = p.size(-2*(1.0 / \$dbu))
cellmain.shapes(layer_MEM).insert(p)

The initial p shape has no issues, but when sized with -2 microns the rectangle adds 4 2x2um squares at each corners. Any hints?

Jakub
MIT
• edited July 2017

Hi jakub,

`Polygon.size()` is not the full truth - in general, polygon sizing does not necessarily render a single polygon, hence there is no true "size in place" method. The `Polygon.size()` function is rather a preparation step and needs postprocessing, as the documentation says http://www.klayout.de/doc/code/class_Polygon.html#method61:

In order to obtain a proper polygon in the general case, the sized polygon must be merged in 'greater than zero' wrap count mode.

However, in your case it's rather simple - you can enlarge the box itself with a negative value which will render the right results. If you still want to use polygons, I'd recommend the `Region` class which is a collection of polygons and offers many high-level functions such as booleans and a consistent sizing function.

Matthias

• edited November -1
Hi Matthias,
Thank you very much. Following your advice, I did get it to work once I processed the generated polygons with the edge processor simple_merge_p2p function. It would be nice to have a clean sizing function for polygons that doesn't require that.
Anyway the kLayout software is really quite great, our group is using it more and more.
Thanks again,
Jakub
MIT
• edited November -1

Hi Jakub,

you don't need simple_merge_p2p any more ... that's a legacy function. Just use "RBA::Region" - it's basically a set of polygons and offers all the functionality you need. For the reasons I explained, a single polygon cannot have a size function, but "Region" has. And it's as convenient to use as a single polygon.

Matthias