-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
boundary with holes #3
Comments
This is really caused by one piece of still missing functionality in the underlying Clipper library that is used implement the polygon algebra. What's missing in Clipper is a way to convert complex polygons (e.g. polygons with holes) into simple ones. Clipper has the beginnings of polygon simplification, but it currently can't simplify polygons with holes. If I knew a general way to do the simplification, it would already be part of the toolbox. Right now it's best to avoid any holes, e.g. by dividing the outer polygon before subtracting the hole, or similar strategies. |
I believe Holes are not allowed in GDSII, but "self touching" is legal, because the lines will not "self crossing" as explained in this website: https://www.artwork.com/gdsii/gdsii/page3.htm Maybe the solution is to try to create an extra points to combine the edge of holes to the outside edge and have a close polygon. I am not good at programming to edit Clipper library. But I tested in Klayout. I added to boxes as describe in ycrichard example and I made a subtraction and finally I have a polygon with a hole with the "self touching" idea. |
hello 1、在作者原有重载的gdsii-Toolbox\Basic@gds_element\minus.m函数中,还不支持hole的创建。针对这个问题,在minus.m中增加了一段代码,用于解决该问题。
2、other:另外需要将 gdsii-Toolbox\Basic@gds_element\poly_cw.m中的笔误进行修正
3、使用一楼提供的测试代码,最终结果如图 % create a structure to hold elements |
@houxianfei Thanks for the nice fix. I tested it, and it works even when two polygons have partial overlap. It would be great if you can make a pull request to the official repo. |
Can you send it to me?
Ulf
…--
Ulf GRIESMANN \\ +1 301 339 4962
Somewhere on Earth...
On Sun, Dec 18, 2022, 08:48 ycrichard ***@***.***> wrote:
@houxianfei <https://github.com/houxianfei> Thanks for the nice fix. I
tested it, and it works even when two polygons have partial overlap. It
would be great if you can make a pull request to the official repo.
Or maybe the owner can implement the idea here.
—
Reply to this email directly, view it on GitHub
<#3 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACEGLNFLZRIIXRU7VTMIDYTWN4I4BANCNFSM4ISAOAPA>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Be aware there is still some limitation. With the solution from houxianfei, it only works for minus operation between 2 simple polygon. If I make another minus operation on top of the hole shape, it seems to do a XOR operation.
|
很抱歉,代码具有局限性,没考虑到这种情况,后续有机会我再想想更好的解决方案。 不过这个问题可以换一种写法
|
try again test1:
test2: hole - hole
test3: hole - hole
gdsii-Toolbox\Basic@gds_element\minus.m
gdsii-Toolbox\Basic@gds_element\poly_bool.m
|
@houxianfei hello, 您修改后的代码对于一个结构中只有一个hole的话很好用,但如果有两个或以上的hole的话就开始有问题了,如下例:这里一个方形结构中理论上有两个方孔,但实际画出来的版图只有一个孔,请问下有没有解决办法呢?
|
Unfortunately, there isn't an easy solution. The root problem is that the
Clipper library used for polygon algebra has a broader definition of
polygons than the GDSII standard. In GDSII all polygons must be strictly
simple. The toolbox doesn't have a way to convert (cut up) complex polygons
into simple ones. I have looked "all over the Internet" in vain to find the
missing pieces, and I never had the time to write them myself.
Ulf
…--
Ulf GRIESMANN \\ +1 301 339 4962
Somewhere on Earth...
On Thu, Aug 29, 2019, 06:13 ycrichard ***@***.***> wrote:
Hello,
I would like know if there any easy solution to properly write boundary
shape with holes.
Here is a simple example case:
% create a structure to hold elements
gs = gds_structure('BASIC');
% create two closed polygons
xy1 = [-1,-1; -1,1; 1,1; 1,-1; -1,-1];
xy2 = xy1/2;
% create boundary elements and substract the second one
ge1 = gds_element('boundary', 'xy',xy1, 'layer',1);
ge2 = gds_element('boundary', 'xy',xy2, 'layer',1);
ge3 = ge1-ge2;
gs(end+1) = ge3;
% create a library to hold the structure
glib = gds_library('standard', 'uunit',1e-6, 'dbunit',1e-9, gs);
% finally write the library to a file
write_gds_library(glib, 'basic.gds');
The resulting GDS does not have a hole, probably it is a known limitation
exists in the current version.
I know that we can do a pre-triangulation, but in the cases with more
complex holes, the triangulation is really not optimal.
Could you suggest any general method to split it into simple boundary
elements?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#3?email_source=notifications&email_token=ACEGLNHCROVLBROS2OA2YFTQG6OM7A5CNFSM4ISAOAPKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HIFAKDQ>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACEGLND2MSKPMGLWQODYEGDQG6OM7ANCNFSM4ISAOAPA>
.
|
@Billy6998 关于你的问题,目前算法上不够完善。如果只是为了实现功能,我的建议是改成下图版本。在写法上需要做约束:1、首先被减元素们不重叠;2、要减的元素需覆盖所有被减元素;3、写法上要求先把所有被减元素相加,最后统一给最大的元素减去; 例如上述的例子就应该写成 ge4 = ge1-(ge0+ge2); 关于被减元素重合,建议写成 ge4 = ge1 - poly_bool( ge0, ge2, 'or'); 参考这次回答 |
Hello,
I would like know if there is any easy solution to properly write boundary shape with holes.
Here is a simple example case:
The resulting GDS does not have a hole, probably it is a known limitation in the current version.
I know that we can do a pre-triangulation, but in the cases with more complex holes, the triangulation is really not optimal.
Could you suggest any general method to split it into simple boundary elements?
The text was updated successfully, but these errors were encountered: