[RectCollection] add a RectCollection shape
This commit is contained in:
parent
b6ee0d4929
commit
a279ccec21
5 changed files with 343 additions and 1 deletions
|
|
@ -37,7 +37,7 @@ from klamath import records
|
|||
|
||||
from .utils import is_gzipped, tmpfile
|
||||
from .. import Pattern, Ref, PatternError, LibraryError, Label, Shape
|
||||
from ..shapes import Polygon, Path
|
||||
from ..shapes import Polygon, Path, RectCollection
|
||||
from ..repetition import Grid
|
||||
from ..utils import layer_t, annotations_t
|
||||
from ..library import LazyLibrary, Library, ILibrary, ILibraryView
|
||||
|
|
@ -466,6 +466,20 @@ def _shapes_to_elements(
|
|||
properties=properties,
|
||||
)
|
||||
elements.append(path)
|
||||
elif isinstance(shape, RectCollection):
|
||||
for rect in shape.rects:
|
||||
xy_closed = numpy.empty((5, 2), dtype=numpy.int32)
|
||||
xy_closed[0] = rint_cast((rect[0], rect[1]))
|
||||
xy_closed[1] = rint_cast((rect[0], rect[3]))
|
||||
xy_closed[2] = rint_cast((rect[2], rect[3]))
|
||||
xy_closed[3] = rint_cast((rect[2], rect[1]))
|
||||
xy_closed[4] = xy_closed[0]
|
||||
boundary = klamath.elements.Boundary(
|
||||
layer=(layer, data_type),
|
||||
xy=xy_closed,
|
||||
properties=properties,
|
||||
)
|
||||
elements.append(boundary)
|
||||
elif isinstance(shape, Polygon):
|
||||
polygon = shape
|
||||
xy_closed = numpy.empty((polygon.vertices.shape[0] + 1, 2), dtype=numpy.int32)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue