diff --git a/masque/shapes/poly_collection.py b/masque/shapes/poly_collection.py index 6c23da7..0b5543f 100644 --- a/masque/shapes/poly_collection.py +++ b/masque/shapes/poly_collection.py @@ -119,6 +119,22 @@ class PolyCollection(Shape): if numpy.any(offset): self.translate(offset) + @classmethod + def _from_raw( + cls, + *, + vertex_lists: NDArray[numpy.float64], + vertex_offsets: NDArray[numpy.integer[Any]], + annotations: annotations_t = None, + repetition: Repetition | None = None, + ) -> Self: + new = cls.__new__(cls) + new._vertex_lists = vertex_lists + new._vertex_offsets = vertex_offsets + new._repetition = repetition + new._annotations = annotations + return new + def __deepcopy__(self, memo: dict | None = None) -> Self: memo = {} if memo is None else memo new = copy.copy(self) diff --git a/masque/shapes/polygon.py b/masque/shapes/polygon.py index a743de2..42c2f78 100644 --- a/masque/shapes/polygon.py +++ b/masque/shapes/polygon.py @@ -131,6 +131,20 @@ class Polygon(Shape): if numpy.any(offset): self.translate(offset) + @classmethod + def _from_raw( + cls, + *, + vertices: NDArray[numpy.float64], + annotations: annotations_t = None, + repetition: Repetition | None = None, + ) -> Self: + new = cls.__new__(cls) + new._vertices = vertices + new._repetition = repetition + new._annotations = annotations + return new + def __deepcopy__(self, memo: dict | None = None) -> 'Polygon': memo = {} if memo is None else memo new = copy.copy(self)