ansys / pyedb

pyedb is a Python library to use the EDB client library.
https://edb.docs.pyansys.com/
MIT License
7 stars 4 forks source link

Optimize unite_polygons_on_layer #753

Open isaacwaldron opened 4 weeks ago

isaacwaldron commented 4 weeks ago

Description of the feature

Third-party end user reports that unite_polygons_on_layer appears to be slow for large polygon counts. The use case for this customer is uniting all polygons on every layer to produce a fully-merged set of polygons, so they are not using e.g. the selection by net name, etc.

Steps for implementing the feature

  1. Remove calculation of a dictionary of net name to list of polygon objects regardless of whether the caller specifies a set of nets or not.
  2. Rather than the current "unite the outlines, then add the voids" algorithm, I think we could loop over the original polygons and: a. Convert each polygon to a PolygonData. b. Loop over the voids in the polygon, convert each to PolygonData, and call AddHoles on the primary outline PolygonData with the void data. c. After the main loop completes, unite all the resulting PolygonData and then create new polygon objects and voids based on the returned data (e.g. each main list PolygonData becomes a polygon and that PolygonData's holes become voids in that polygon). This avoids the O(n*m) time checking intersection of every void with every polygon in the output stage.

Useful links and references

No response

svandenb-dev commented 3 weeks ago

Thanks @isaacwaldron we need to take a look on this.

svandenb-dev commented 3 weeks ago

@gkorompi could you please check this method wrt to PR #284 done some months ago ? I think performances are related to the code introduced.