This method applies to paths and delivers all points of the path's center line. It will throw an exception for other objects.
When I try to run the following code on pypi klayout package (v.0.26.4), the statement from the first page is not correct, and exception is raised:
fromklayout.dbcoreimportSimplePolygon, Shapes# Create a simple polygonpp='(1632300,-130000;1631800,-129500;1632050,-129500)'sp=SimplePolygon.from_s(pp)
print([pforpinsp.each_point()]) # [1632300,-130000, 1631800,-129500, 1632050,-129500]# Create a shapes container, add a simple polygon thereshapes=Shapes()
print(type(s)) # <class 'klayout.dbcore.Shape'>print(s) # simple_polygon (1632300,-130000;1631800,-129500;1632050,-129500)ifs.is_simple_polygon:
# This iterator worksforpins.simple_polygon.each_point():
# This iterator does not workforpinpins.each_point(): # raises RuntimeErrorprint(p)
The error raised is the following: RuntimeError: Internal error: src\db\db\dbShape.cc:159 false was not true in Shape.each_point. The error is an assert statement, so I guess the execution was not supposed to reach there at all...
The text was updated successfully, but these errors were encountered:
well, the error message could be somewhat more comprehensible ... but doc and code are consistent.
The message basically says "I'm expecting a path". A simple polygon isn't a path.
The explanation is: "each_point" only applies to paths. Paths are not polygons, but "wires": a path is a sequence of points and a width. The path connects the points by straight lines with the given width. A simple polygon is a closed loop of points (the vertexes). This is the "hull". A general polygon in addition may have zero to many holes. Holes are also closed loops, but with the opposite orientation of the hull (counterclockwise, while the hull is clockwise).
I see ... that's acutally easy to fix: there is no such method. "each_point" is only there for paths. It would not make much sense to iterate points over hulls and holes if there is no indication which loop the point belongs to. Better use "each_point_hull" and "each_point_hole".