Skip to content

Commit

Permalink
Fix partition line generation for substrates with no spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
yaqwsx committed Oct 5, 2023
1 parent 3a33bba commit 102e4cd
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion kikit/substrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -869,10 +869,32 @@ def seedFilter(idA, idB, v, l):
return False
return idA not in ghosts or idB not in ghosts
self._partition = BoxPartitionLines(
boxes,
self._preprocessBoxes(boxes),
seedFilter,
safeHorizontalMargin, safeVerticalMargin)

def _preprocessBoxes(self, boxes):
"""
BoxPartitionLines assumes non-overlapping boxes. However, when we
specify zero spacing, the boxes share an edge which violates the initial
condition. It is safe to shrink the boxes if they are not the outer-most
edges.
"""
minx = min(map(lambda x: x[0], boxes.values()))
miny = min(map(lambda x: x[1], boxes.values()))
maxx = max(map(lambda x: x[2], boxes.values()))
maxy = min(map(lambda x: x[3], boxes.values()))

newBoxes = {}
for i, b in boxes.items():
newBoxes[i] = (
b[0] + SHP_EPSILON if b[0] != minx else minx,
b[1] + SHP_EPSILON if b[1] != miny else miny,
b[2] - SHP_EPSILON if b[2] != maxx else maxx,
b[3] - SHP_EPSILON if b[3] != maxy else maxy
)
return newBoxes

@property
def query(self):
return self._partition.query
Expand Down

0 comments on commit 102e4cd

Please sign in to comment.