It looks like you're new here. If you want to get involved, click one of these buttons!
Hi,
I found the order of multi_clip output is not same as input boxes list.
Part of my python script is,
print 'first 5 bboxes'
clist = layout.multi_clip(top_id, bblist)
for cid, ii in zip(clist,range(len(clist))):
cc = layout.cell(cid)
print cid, cc.bbox().to_s(), bblist[ii].to_s()
print 'first 4 bboxes'
bblist = bblist[0:4]
clist = layout.multi_clip(top_id, bblist)
for cid, ii in zip(clist,range(len(clist))):
cc = layout.cell(cid)
print cid, cc.bbox().to_s(), bblist[ii].to_s()
The output is blow,
first 5 bboxes
6018 (-406876,-292272;-405292,-290587) (-464094,-61533;-462056,-59423)
6019 (-464053,-61112;-462056,-59848) (-463756,-46673;-461645,-44653)
6020 (-463756,-46673;-461645,-44653) (-427809,22824;-425706,24936)
6021 (-427422,9928;-425537,11618) (-427422,9506;-425345,11618)
6022 (-427358,23248;-426041,24512) (-406876,-292698;-404847,-290587)
first 4 bboxes
6023 (-464053,-61112;-462056,-59848) (-464094,-61533;-462056,-59423)
6024 (-463756,-46673;-461645,-44653) (-463756,-46673;-461645,-44653)
6025 (-427422,9928;-425537,11618) (-427809,22824;-425706,24936)
6026 (-427358,23248;-426041,24512) (-427422,9506;-425345,11618)
You could found when 4 bboxes used in multi_clip, the output order is same as bboxes.
All clipped cell is in input bbox.
However, when I use 5 bboxes, the order output is SHIFT.
Is it a bug? Or how could I get correct clipped cells matched with input bboxes?
Thanks,
Dion
Comments
Hi Dion,
please try to use Markdown markup to properly format the code - for Python this is in particular important. You just have to add four blanks in front of the code lines.
Regarding your problem: the order of the output cells is not guaranteed right now. There may be even less output cells if two clip boxes happen to be the same.
I have not tried it, but if I read my code correctly, the clip function uses a STL map with a "pair<cell_index, clip_box>" key. The output is taken from those entries where cell_index == index of top cell of input, so the remaining sorting will be according to the box (using < and == relations). So maybe it's sufficient to sort the clip boxes before you pass them to the multi_clip function (with < and == - maybe even <=> is synthesized correctly) and to make sure there are no duplicates.
Regards,
Matthias
You are right, clip function use STL map.
However, there are two problems.
1. the output results looks sorted the bbox of cut results, not the input bboxes.
2. if input bboxes cut nothing, no result will output. Then the count of output is different from input.
So even I sorted the input bboxes, these are still miss match cases.
Thanks,
Dion
Hi Matthias,
I add patch to output clip results as order. when no data in clip bbox, it will return cell idx 0.
Maybe you could add an option in next release.
Thanks,
Dion
Hi Dion,
I'll do it slightly differently.
You should confine your solution to the top level (set
b2b_map
for the first recursion only). Otherwise you may risk that cells below may overwrite your entries. Plus 0 is a valid cell index - so if you intend to mark "non-existing cells" you need to do it in a different way.Find my patch below (line numbers may not match the current release).
Regards,
Matthias
Thanks for you patch. It's much better than mine :)
Thanks,
Dion
Is your above patch included in 0.24.10 release?
Or there is no plan to add it to future release ?
Thanks,
Dion
Hi Dion,
sorry, but considering that a somewhat "more than trivial" change I did not include that into 0.24.10.
I'm moving everything to GitHub now (https://github.com/klayoutmatthias/klayout). In the master, this patch is already included.
Matthias