Hi Matthias,
I have found some disagreement in the docs regarding Shape.each_point() iterator.
This page https://www.klayout.de/doc/programming/database_api.html#h2-1056 says:
**Methods applying for polygon and simple polygon shapes**
...
Shape#each_point will deliver every point of the polygon, including that of the holes.
...
The docs for the Shape.each_shape() method on https://www.klayout.de/doc/code/class_Shape.html#method97 say:
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:
from klayout.dbcore import SimplePolygon, Shapes
# Create a simple polygon
pp = '(1632300,-130000;1631800,-129500;1632050,-129500)'
sp = SimplePolygon.from_s(pp)
print([p for p in sp.each_point()]) # [1632300,-130000, 1631800,-129500, 1632050,-129500]
# Create a shapes container, add a simple polygon there
shapes = Shapes()
shapes.insert(sp)
s = list(shapes.each())[0]
print(type(s)) # <class 'klayout.dbcore.Shape'>
print(s) # simple_polygon (1632300,-130000;1631800,-129500;1632050,-129500)
if s.is_simple_polygon:
# This iterator works
for p in s.simple_polygon.each_point():
print(p)
# This iterator does not work
for p in p in s.each_point(): # raises RuntimeError
print(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...
Hi Matthias,
I have found some disagreement in the docs regarding
Shape.each_point()iterator.This page https://www.klayout.de/doc/programming/database_api.html#h2-1056 says:
The docs for the
Shape.each_shape()method on https://www.klayout.de/doc/code/class_Shape.html#method97 say: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:
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...