It looks like you're new here. If you want to get involved, click one of these buttons!
Hello, I am looking for a function that returns true if a given point is inside a function.
The following function returns true if a point lies inside a polygon (specified by layer and a cell).
However I don't want to use this method because I don't want to iterate over all the shapes.
Is there a simpler way of finding if a point is inside or outside (touching or not touching) a specified layer.
iter = pya.RecursiveShapeIterator.new(layout, cell, layer_index)
specified_region = iter.shape().polygon
is_point_inside = specified_region.inside(pya.Point(x, y))
Thanks for the help!
Comments
Perhaps you could use
Layout.begin_shapes_touching
. You would need to make aRegion
out of your point.@jheinsoo You're right. Confining the search does the trick.
But you do not necessarily need a Region. Iterating probably won't hurt if you confine the search to a small area around the test point. This will return only those polygons whose bounding boxes already contain the point:
I think this is the most efficient way to do the test.
Matthias