Coder Social home page Coder Social logo

Comments (4)

heitzmann avatar heitzmann commented on August 19, 2024

@egholami I'm not sure I understand what you're trying to do, but probably cell.get_polygons(by_spec=True) should help.

If you can post a minimal example, it might be easier to help you.

from gdspy.

egholamy avatar egholamy commented on August 19, 2024

This is the Trim method that I add to Cell class:**
def Trim (self,
mash):
poly_dic = self.get_polygons(True)
self.elements = []
for ld in poly_dic.keys():
if ld[0]==mash:
self.add(PolygonSet( poly_dic[ld],ld[0], verbose=False))
return self

It is working for Cell layer isolation and for the Boolean cell Operation I am using Get_polygons in the following way but it is very slow:

layli=['EBL','Trenches','Mesa']
for i in range(1,4):
globals()['sepLayer%s'%i]=Ref_cell.copy('{}'.format(layli[i-1]), deep_copy=True)
globals()['sepLayer%s'%i].Trim(mash=i)
globals()['sepLayer%s'%i]=gdspy.fast_boolean(globals()['sepLayer%s'%i].get_polygons(False, None),Iqub0m,'not',layer=i)
re_cellmodified.add(globals()['sepLayer%s'%i])
for one of my layers that have a lot of points and elements it is very slow but it is working
**Now I have tried what you suggested **

for i in range(1,4):
globals()['sepLayer%s'%i]=flatten.copy('{}'.format(layli[i-1]), deep_copy=True)
globals()['sepLayer%s'%i].Trim(mash=i)
globals()['sepLayer%s'%i]=gdspy.fast_boolean(globals()['sepLayer%s'%i].get_polygons(by_spec=True),Iqub0m,'not',layer=i)
re_cellmodified.add(globals()['sepLayer%s'%i])
print(i)

It is giving me this error!

Traceback (most recent call last):

File "C:\Users\ehgh\AppData\Local\Continuum\anaconda3\lib\site-packages\gdspy_init_.py", line 4274, in fast_boolean
result = clipper.clip(polyA, polyB, operation, 1 / precision)
TypeError: 'numpy.int32' object does not support indexing

Is there any way to make Boolean Cell operation fast?

from gdspy.

heitzmann avatar heitzmann commented on August 19, 2024

@egholami get_polygons(by_spec=True) returns a dictionary, so you're a missing the key (similar to what you do with poly_dic. ALso, you probably don't need to use flatten() or copy().

In any case, boolean operations are slow. The only way around it is to use fewer points... I find people often overshoot the precision they need in curved geometries. Another option would be to try to avoid using boolean operations at all by drawing your geometry some other way.

Unrelated to the issue: it's quite dangerous to be abusing globals() like that. Global variables are in general a bad design choice, let alone using globals. You'd be better of using your own dictionary.

from gdspy.

egholamy avatar egholamy commented on August 19, 2024

Thanks a lot! It was a pseudo code and you are right that using the globals() is a bad design choice I would keep it in mind. Using the way that you have explained there would be no need for hard copy.
Unfortunately we deal with some special kind of text and we could not use regular text so I need my own designed text with opening. Because for some chemistry reasons some letters like "O" or "B" could not be used in closed form and need some opening.

from gdspy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.